Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Warning is right or not ?

by Anonymous Monk
on Dec 20, 2012 at 19:50 UTC ( [id://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);

Output;

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

pl files

test1.pl

#!/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++; } }

test2.pl

#!/usr/bin/perl use warnings; use strict; use XML::Simple; require 'test1.pl'; 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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-20 01:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found