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

Randal L. Schwartz merlyn at stonehenge.com
Sat Jan 5 08:42:54 PST 2008


>>>>> "Jay" == Jay Strauss <me at heyjay.com> writes:

Jay> [group] Is it just me, or does look funny to explicitly set @ARGV?

I do it all the time.  It's a convenient way to set up a 'while (<>)' loop
which in turn is a convenient way to read a series of files.

For example, look through all text files in the current directory:

    @ARGV = grep -T, glob '*';
    while (<>) { ... }

Look through all the '.htaccess' files in my webserver area:

   use File::Finder;
   @ARGV = File::Finder->type('f')->name('.htaccess')->in($HTDOC);
   ...

etc etc.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


More information about the Chicago-talk mailing list