[EMAIL PROTECTED] writes:
> > "Michael R. Wolf" <[EMAIL PROTECTED]> said:
>
> > Since <> is used so often in a while loop to mean the
> > diamond operator, I prefer to spell out "glob" as follows.
> >
> >
> > while (glob "sn.") {
> > print "$_\n";
> > }
> >
> > Just a *preference*. T
Michael Pratt asked:
> How can I open several files with this format sn..txt where
> is 0001 0002 so on and so on?
>
Since noone else suggested it :
opendir DIR, $dir;
while ($file = readdir DIR) {
next if $file !~ /^sn\.\d\d\d\d\.txt$/i;
> "Michael R. Wolf" <[EMAIL PROTECTED]> said:
> Since <> is used so often in a while loop to mean the
> diamond operator, I prefer to spell out "glob" as follows.
>
>
> while (glob "sn.") {
> print "$_\n";
> }
>
> Just a *preference*. They're both *right*.
I agree. Your way is som
[EMAIL PROTECTED] writes:
> You can use the globbing (shell pattern matching) magic of the <>
> operator to get the names of the files. Try this to see how it works.
NB: Did you notice that "glob" is sometimes spelled "<>"? It's
easy to miss. "<>" in the following example is glob, *not*
(did
> "Michael Pratt" <[EMAIL PROTECTED]> said:
> How can I open several files with this format sn..txt where is 0001
> 0002 so on and so on?
You can use the globbing (shell pattern matching) magic of the <>
operator to get the names of the files. Try this to see how it works.
while () {
On Dec 15, Michael Pratt said:
>How can I open several files with this format sn..txt where is
>0001 0002 so on and so on?
Use a glob, and use Perl's @ARGV magic:
{
local @ARGV = glob "sn..txt";
while (<>) {
# opening each file from @ARGV, one at a time
# $ARG
How can I open several files with this format sn..txt where is 0001
0002 so on and so on?
Thanks!
Mike
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]