[Chicago-talk] @ARGV while(<>)

Jay Strauss me at heyjay.com
Fri Jan 4 19:26:52 PST 2008


(Why is it you only notice your errors AFTER you post)

should be:
open my $FILE, '<', $infile or croak "can't open file $infile: $!\n";

On Jan 4, 2008 9:22 PM, Jay Strauss <me at heyjay.com> wrote:
> > Randal what does a single undef mean?  Does it mean only one file?
> >
> > should I do:
> >
> > @ARGV = qw($in_file);
>
> Not to put words in Randal's mouth, but I believe he's refering to
> your original post where you have:
>
> @ARGV = $infile;
>
> And $infile has no value, i.e. undefined (based on the original post).
>
> [group] Is it just me, or does look funny to explicitly set @ARGV?
>
> I believe it is better style to open a file handle upon $infile, and
> do some error checking on the open.
>
> Somthing along the lines of:
>
> use strict;
> use Carp;
>
> my $infile = shift;
> my $body;
>
> open my $FILE, '<', $infile or croak "can\'t open file $infile: $!n";
> while (<$FILE>) {
>    unless(/epsf\[/) {
>         $body = $body . $_;
>    }
> }
>
>
> Jay
>


More information about the Chicago-talk mailing list