Firsov has asked for the wisdom of the Perl Monks concerning the following question:
Hello!
When i try access to hash with $name i get error:
Use of uninitialized value within %p in concatenation (.) or string at ./7.plx line 15, <STDIN> line 1.
#!/usr/bin/perl use warnings; use strict; use 5.010; my %p = ( "Word1" => "WordWord1", "Word2" => "WordWord2", "Word3" => "WordWord3", ); while(<STDIN>) { my $name = $_; print "$p{$name}\n"; }
What is wrong with my code?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Wrong hash accessing?
by davido (Cardinal) on Mar 18, 2015 at 05:10 UTC | |
by Firsov (Novice) on Mar 18, 2015 at 05:34 UTC |