in reply to Re^3: eof not recognised when applying diamond operator to invocation arguments?
in thread eof not recognised when applying diamond operator to invocation arguments?
Getting more contentious, if you spell "foreach" as "for", add the normal indentation and brace style, lexical filehandles, and convert the while into an inline form, you get the more idiomatic:foreach my $file (@ARGV) { open (FILE, "<", $file) || die "could not open '$file': $!"; while (<FILE>) { print $_; } print "whatever you wanted to use as a separator $file\n"; }
for my $file (@ARGV) { open (my $fh, "<", $file) || die "could not open '$file': $!"; print while <$fh>; print "whatever you wanted to use as a separator $file\n"; }
Edit: Argel is right. The for/foreach distinction belongs in the stylistic nitpicks, not in the more substantive section.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: eof not recognised when applying diamond operator to invocation arguments?
by Argel (Prior) on Jan 12, 2011 at 23:59 UTC | |
by ikegami (Patriarch) on Jan 13, 2011 at 00:49 UTC | |
by Argel (Prior) on Jan 14, 2011 at 17:07 UTC | |
by ikegami (Patriarch) on Jan 14, 2011 at 17:49 UTC | |
by Argel (Prior) on Jan 14, 2011 at 23:48 UTC | |
|