Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^2: Open in for loop/array structure

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

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

The expression <$FN$k> reads from the file handle $FN$k

I don't think so. If the text inside <> isn't a simple scalar then the diamond operator turns into glob

Replies are listed 'Best First'.
Re^3: Open in for loop/array structure
by pc88mxer (Vicar) on Jun 02, 2008 at 23:47 UTC
    Oh that makes sense now - forgot about the glob operator.
      $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
Node Status?
node history
Node Type: note [id://689775]
[LanX]: avoiding unreadable brackets
[MidLifeXis]: Although the previous one could be a b0rken PATH, I would need to dig for that.
[thezip]: I've got to go to meetings now. If anyone has further comments regarding Spreadsheet::XLSX deployment to Strawberry Perl 5.24.1, please /msg me -- thanks!
LanX has to go ... plans to crash with a car into a group of pythonistas while screaming "LARRY IS THE GREATEST"
LanX ... darn ... where is my car?
[choroba]: Haven't you crashed into a boar recently?
[1nickt]: TCLion how is that going?
[LanX]: could someone lend me a car?

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (10)
As of 2017-03-23 17:30 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (291 votes). Check out past polls.