473,382 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Error: Use of uninitialized value in print

5
Hi,

I just cant find wats wrong in this tiny piece of code.

All I want to fetch the number associated with a key in the hash. The key has to be entered my user during execution. Here is the code:
Expand|Select|Wrap|Line Numbers
  1. #!usr/bin/perl
  2. #chap3ex3.pl
  3. use warnings;
  4. use strict;
  5.  
  6. my %tele_directory = ("Mine" => "1911", "Moms" => "1911", "Dads" => "1913", "Siss" => "1914");
  7. print "Enter a name: ";
  8. my $name=<STDIN>;
  9. my $name1="Moms";
  10. #my $temp=$name;
  11.  
  12. print "\$name is $name and the respective number is", $tele_directory{$name}," \n";
  13.  
  14. print "\$name1 is $name1 and the resp entry is $tele_directory{$name1} \n";
  15.  
Here is the error I am getting:
Expand|Select|Wrap|Line Numbers
  1. Enter a name: Mine
  2. $name is Mine
  3. Use of uninitialized value in print at C:\Users\user\Documents\Perl_scripts\chap
  4. 3ex3.pl line 12, <STDIN> line 1.
  5.  and the respective number is
  6. $name1 is Moms and the resp entry is 1911
  7. Press any key to continue . . .
  8.  
Please help me out.

Thanks.
Apr 5 '12 #1
2 3787
sabie
5
Again... got it!!
Chomp() did the job.
Apr 5 '12 #2
numberwhun
3,509 Expert Mod 2GB
Yes. You have to remember to chomp any input from the user due to the carriage return. Also, unless you are executing this from the root directory, you may want to fix your path to perl in your shebang line as your missing the "/" before 'usr'.

Regards,

Jeff
Apr 6 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: | last post by:
hello, I have a problem with this piece of code. I want to open a random web page each time and remember which one has been opened before because I donīt want to repeat. It works fine the first...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
3
by: shin | last post by:
hi i am trying to output an image which i have in a database. but this gives me errors byte Picture; Picture = (dr); //cannot convert from object to byte Response.Buffer=true;
29
by: John Rivers | last post by:
Hello, What good reason there is for not allowing methods in ASPX pages I can't imagine, but here is how to get around that limitation: (START) <body MS_POSITIONING="FlowLayout"> <form...
6
by: Mark Walsh | last post by:
The following is an explanation of a bug that exists in the VB.NET compiler. I've tried to report it to Microsoft, but they've made it so difficult I've given up: MSDN help states that variables...
6
by: Mike | last post by:
When using a DataReader to return records from a SQL server, I'm having a problem with the following code (abbreviated) int ID = 0; ID = (int)dr; will work if the user_id column is an int...
6
by: kalyan.listsubs | last post by:
Hi, I have the below program which will simply write struct employee to a file (binary mode). The problem here is empid is writen to the file but the name (char name) is not written. I am using...
8
by: manmit.walia | last post by:
Hello Everyone, Long time ago, I posted a small problem I had about converting a VB6 program to C#. Well with the help with everyone I got it converted. But I overlooked something and don't...
2
by: YYweii | last post by:
Hi all my teacher say there is something wrong with this piece of code, but i can't figure it out, help ! void GetMemory(char *p, int num) { p = new char; }
3
by: SM | last post by:
I'm using simpleXML in PHP and i Can't get this small piece of code to work? Need help I have an XML that looks like this: <?xml version="1.0" encoding="utf-8"?> <VIDEO> <item>...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.