Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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]
Discipulus dscivered BASH supports also double quotes..
choroba recommends ABSG to Discipulus

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2017-11-24 11:48 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (348 votes). Check out past polls.