Is it possible to simplify my procedure? Could it be more perlish?
1) Get rid of garbage like $_[0], $_1. Instead use shift():
sub do_stuff { my $dir = shift; my $pattern = shift; ...
... or list assignment if you want to keep @_ intact:
my ($dir, $pattern) = @_;
Do either of those as the *first* line(s) of your sub.
2) In general, your variable names are atrocious:
$what --> $pattern_str @t --> @patterns $f --> $pattern $file2md5 --> $fname
3) As an alternative to split() and looping, you could chdir($dir) and then glob($pattern_str).
4) What do you think the quote marks do here:
"$file2md5"
5) Don't use bareword filehandles. Use a my() variable instead(which you can capitalize if you want to):
my $fname_out = 'name.txt'; open my $OUTFILE, '>', $fname_out or die "Couldn't open $fname_out: $!"; #and then... print $OUTFILE "whatever";
In reply to Re: Pass the arguments to the procedure in an easier way
by 7stud
in thread Pass the arguments to the procedure in an easier way
by Scottie
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |