note
packetstormer
<p>Another way, will only work for later versions of Perl</p>
<code>
#!/usr/bin/perl
use strict;
my @arr = ("making","each","day","of","the","year","1");
while ( my($idx,$val) = each (@arr) ){
print "Index is: $idx. Value is: $val\n";
if($val =~ /^\d+$/){
do_my_function($val)
}
}
sub do_my_function {
my $v = shift;
print "We're in the sub for value: $v\n"
}
</code>
EDIT: Not sure what happened with my initial post but the comment I had about the regex was, as pointed out by AnomalousMonk, incorrect!
1039882
1039882