going crazy here!

Discussion in 'Perl Misc' started by Monkey Man, Jan 6, 2004.

  1. Monkey Man

    Monkey Man Guest

    Somebody tell me what's wrong with this code

    #!/usr/bin/perl -w

    %name = ( "ziya" => "aktas", "kimberly" => "aktas", "azer" => "apaydin" );

    print "Enter Something: ";
    my $key = <STDIN>;
    print $name{ $key };


    gives the error

    Use of uninitialized value in print at ./hash.pl line 8, <STDIN> line 1.
     
    Monkey Man, Jan 6, 2004
    #1
    1. Advertising

  2. Monkey Man

    Ben Morrow Guest

    "Monkey Man" <> wrote:

    use strict;

    > %name = ( "ziya" => "aktas", "kimberly" => "aktas", "azer" => "apaydin" );


    ^^ my

    >
    > print "Enter Something: ";
    > my $key = <STDIN>;
    > print $name{ $key };
    >
    > gives the error
    >
    > Use of uninitialized value in print at ./hash.pl line 8, <STDIN> line 1.


    $key was not any of the keys in the hash. This is probably because it
    still has a newline on the end: see perldoc -f chomp.

    Ben

    --
    perl -e'print map {/.(.)/s} sort unpack "a2"x26, pack "N"x13,
    qw/1632265075 1651865445 1685354798 1696626283 1752131169 1769237618
    1801808488 1830841936 1886550130 1914728293 1936225377 1969451372
    2047502190/' #
     
    Ben Morrow, Jan 6, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Navin
    Replies:
    3
    Views:
    654
    Navin
    Jul 28, 2003
  2. Jay Douglas
    Replies:
    0
    Views:
    407
    Jay Douglas
    Aug 28, 2003
  3. Larry Tate

    getting confused and going crazy

    Larry Tate, Dec 21, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    502
    Larry Tate
    Dec 21, 2003
  4. shapper

    Authentication ... going crazy here.

    shapper, Feb 23, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    336
    shapper
    Feb 23, 2007
  5. shapper
    Replies:
    1
    Views:
    391
    shapper
    May 29, 2007
Loading...

Share This Page