in reply to how to get the input file name when perl script runs from the command line?

As described in perlvar, $ARGV "contains the name of the current file when reading from <>."

When iterating over a file using the -n switch (as you're doing ... described in perlrun), the <> operator is silently being invoked behind the scenes, which is why $ARGV is relevant.


Dave

Replies are listed 'Best First'.
Re^2: how to get the input file name when perl script runs from the command line?
by greatshots (Pilgrim) on Oct 20, 2006 at 03:10 UTC
    perl -nle '/<meta-property type=\"meta-attribute\">(.*)\<\/meta-proper +ty\>/ and print "$ARGV:$1"' *
    worked as expected. thanks a bunch