in reply to File Stricture Help

foreach my $file (@files) { $count++; }

This is usually simpler as:

my $count = @files;

And this:

unlink <$file>;

... reads from the filehandle $file (which isn't a filehandle, and is the source of your problems. The <> operator is the same as readline; it doesn't signify a file at all. I think that's what's confused you here.

Replies are listed 'Best First'.
Re^2: File Stricture Help
by ysth (Canon) on May 14, 2008 at 05:46 UTC
    reads from the filehandle $file (which isn't a filehandle
    Yes and no. It's a string being passed to 1-arg open and readline, which are glob contexts. So it's interpreted as a symbolic glob reference (and a glob reference is the typical type of a filehandle), which makes strict complain.

    But without strict, it works just fine as a filehandle:

    $ perl -we'$file = "foo.bak"; ${"foo.bak"} = "seq 10|"; open $file or +die "nope:$!"; print for <$file>' 1 2 3 4 5 6 7 8 9 10

      I just didn't want to say "symbolic filehandle coercion".