Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^3: Open in for loop/array structure

by pc88mxer (Vicar)
on Jun 02, 2008 at 23:47 UTC ( #689776=note: print w/replies, xml ) Need Help??

in reply to Re^2: Open in for loop/array structure
in thread Open in for loop/array structure

Oh that makes sense now - forgot about the glob operator.

Replies are listed 'Best First'.
Re^4: Open in for loop/array structure
by ikegami (Patriarch) on Jun 03, 2008 at 00:02 UTC
    $filename = <$FN[$k]>; is still bad, though. Using glob without looping over its results makes no sense.
    use strict; use warnings; my @FN = qw( a b ); for my $k (0..$#FN) { my $filename = <$FN[$k]>; print("$filename\n"); }
    a Use of uninitialized value in concatenation (.) or string at + line 6.

    If @FN contains glob patterns, then he wants

    for (@FN) { while (defined(my $filename = glob($_))) { ... } }

    If @FN contains file names (as it seems to), then he wants

    for my $filename (@FN) { ... }

    Although it looks like @FN isn't needed at all.

    for (0..18, 20..28, 30..38) { my $filename = sprintf('out-02-%02d.txt', $_); ... }

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://689776]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2023-12-10 01:27 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (38 votes). Check out past polls.