Skip to content

Instantly share code, notes, and snippets.

@unixpickle
Created November 5, 2010 02:33
Show Gist options
  • Save unixpickle/663563 to your computer and use it in GitHub Desktop.
Save unixpickle/663563 to your computer and use it in GitHub Desktop.
count the number of command-line arguments in perl
#!/usr/bin/perl
use strict;
sub arrcount {
my ($arr) = @_;
my $c = 0;
foreach my $str (@{$arr}) {
++$c;
}
return $c;
}
my $count = &arrcount(\@ARGV);
print "$count arguments\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment