Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Warning is right or not ?

by Anonymous Monk
on Dec 20, 2012 at 19:50 UTC ( #1009783=note: print w/replies, xml ) Need Help??

in reply to Warning is right or not ?

Here is the result ( and then both running versions);


[root@testrhel AFAStest]# perl #Right now $hash [root@testrhel AFAStest]# vi #I change $hash to @hash [root@testrhel AFAStest]# perl # Running as @hash Scalar value @hash{'AirIATA'} better written as $hash{'AirIATA'} at te line 12. P C

pl files

#!/usr/bin/perl use warnings; use strict; use XML::Simple; my $programNAME= 'This line is required to work.'; sub get_IATA { my $file = shift; my $airline = shift; my @data; my $count=0; open(my $fh, '<', $file) or die "Can't read file '$file' [$!]\ +n"; while (my $line = <$fh>) { my @fields = split(/;/, $line); push @data, @fields; } foreach my $data ( @data) { if ($data eq $airline) { return $data[$count-1],"\n"; } $count++; } }

#!/usr/bin/perl use warnings; use strict; use XML::Simple; require ''; my $airlineLoc = "definitions/airline.csv"; my %hash; @hash{'AirIATA'}=get_IATA($airlineLoc,'PGT'); my $letter1 = substr($hash{'AirIATA'},0,1); my $letter2 = substr($hash{'AirIATA'},1,2); print $letter1,"\n",$letter2,"\n";

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009783]
[davido]: Using the -i switch causes Perl to rename the input file, read from it, and write to a file using the original file's name. If there's an extension provided, as in -i.bak, it's easy to see where the input file is. Where is the input file temporarily....
[davido]: placed if there is no extension provided to the -i switch?
[davido]: Nevermind, found the answer.

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2017-09-22 14:48 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (264 votes). Check out past polls.