Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Reading file into an array and working with it.

by davorg (Chancellor)
on Jun 25, 2000 at 21:16 UTC ( [id://19758]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @data;
    open(DATA, $file) || die "Can't open $file: $!\n";
    while (<DATA>) {
      push @data, [split /\t/];
    }
    
  2. or download this
    my $town = 'London';
    my ($lat, $long);
    ...
      ($lat, $long) = ($_->[1], $_->[2]);
      last;
    }
    
  3. or download this
    my %data;
    open(DATA, $file) || die "Can't open $file: $!\n";
    ...
      my ($town, @vals) = split(/\t/);
      $data{$town} = \@vals;
    }
    
  4. or download this
    my ($lat, $long) = @{$data{$town}};
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-23 16:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found