Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Putting an array into a hash

by Theo (Priest)
on Dec 13, 2004 at 06:31 UTC ( #414321=note: print w/ replies, xml ) Need Help??


in reply to Re: Putting an array into a hash
in thread Putting an array into a hash

Thanks to the observations of Zaxo and you, I've gotten through some errors, misunderstandings and typos, but there is one error message I don't understand (even with use diagnostics). The whole program follows with the error listed first. The line giving the error is the one with the map command. It looks like the variables $1, $2 are somehow not being set. Perhaps the oddest aspect is that the program seems to work anyway. The error message is repeated 3 times.

Error:
Use of uninitialized value at e.pl line 13, <DATA> chunk 5.

Code:
#!/usr/bin/perl -w my $file; my @info; my $line; my %data = (one => 1, two => 2, three => 3); foreach $file (<BXML=Tr*>) { open (DATA, $file); @info = <DATA>; # @info contains the whole xml record foreach $line (@info) { chomp $line; $line =~ s|E-mail|Email|g; # make email tags match all other + tags %data = map { /<(\w+)>\s*(.*?)<\/\w+>/; ($1, $2) } @info; } print "\n",$data{"Position"},"\t",$data{"GradYear"},"\t",$data{"Em +ail"},"\n"; } close (DATA);
OutPut:
Stdnt 1987 SomeAddr@abc.com

So, can I safely ignore the error since the code does what I expect? Or is that asking for trouble?

-Theo-      (so many nodes and so little time ... )


Comment on Re^2: Putting an array into a hash
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2014-12-28 14:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (181 votes), past polls