--- Rob <[EMAIL PROTECTED]> wrote:
> Hi guys,
> 
> The following script works as I want except for one thing; if I call the
> script with no arguments I want it to list the whole phone book, which it
> does, but it also gives me two of the "Use of
> uninitialized value" warnings at the end. What would be a good way to stop
> this?
> 
> Thanks.

Change 

    my($nameIn) = $ARGV[0];

To

    my $nameIn = $ARGV[0] || '';

Cheers,
Curtis "Ovid" Poe
> #!/usr/bin/perl -wT
> use strict;
> my($nameIn) = $ARGV[0];
> open(IN, "$ENV{HOME}/.phonebook") || die "Can't open Phone Book: $!\n";
> while(<IN>) {
>     chomp;
>     my($fileName, $phoneNum) = split(/,/, $_);
>     my($foundIt) = index(lc($fileName), lc($nameIn));
>         if($foundIt >= 0) {
>             print "\t\t\t$fileName - $phoneNum\n";
>         }
> }
> 
> -- 
> Rob
> 
> Good judgement comes from experience, and experience -
> well, that comes from poor judgement.
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


=====
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__________________________________________________
Do You Yahoo!?
Check out Yahoo! Shopping and Yahoo! Auctions for all of
your unique holiday gifts! Buy at http://shopping.yahoo.com
or bid at http://auctions.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to