in reply to Re: Getting "un initialized value" error though variable is initialized. Please help.
in thread Getting "un initialized value" error though variable is initialized. Please help.
Overloading names in that way is a great way to introduce subtle bugs and make code hard to understand. If it's an array it likely contains more than one item so using a plural form of the name (@wwns) may make sense. Alternatively I'd use the slightly more generic variable name $name for the input variable.
Oh, and don't use our as a substitute for my, especially as a temporary variable - it doesn't do what you think it does and is not at all appropriate. I'd tend to rewrite the thing as:
#!/usr/bin/perl use warnings; use strict; while (1) { print "Enter the wwn: "; chomp (my $name = lc <STDIN>); last if $name eq "q"; print join (':', unpack ("(a2)*", $name)), "\n"; }
Update: s/own/our/
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Getting "un initialized value" error though variable is initialized. Please help.
by AnomalousMonk (Archbishop) on Dec 18, 2011 at 00:06 UTC |