Thomas H. George wrote:
> The difficulty is in the next to last line, the 'unless ...'
> statement which causes warning:
> Use of uninitialized value in string eq at chap4-take6.pl line 49.

Some debugging hints:

1.  Set the output autoflush ($|) Perl variable to a true value near the
top of your program to prevent interleaving of STDERR and STDOUT.

2.  Use Data::Dumper and print() to see what's going on with your
variables/ data structures.

3.  Use a debug variable to control both of the above.

4.  Use Getopt::Long to read a command line option to control the debug
variable.


2009-05-02 17:34:22 dpchr...@p43400e ~
$ cat foo
#! /usr/bin/perl -w
use strict;

use Data::Dumper;
use Getopt::Long;

my $debug = 0;

GetOptions("debug|d" => \$debug)
    or die "$0: error reading command line options";

$| = 1 if $debug;

my %hash = (FOO => 12345, BAR => "frunabulax", BAZ => [1,2,3]);
print Data::Dumper->Dump([\%hash], [qw(*hash)])
    if $debug;

print "hello, ";
print STDERR "Ouch!\n";
print "world!\n";

2009-05-02 17:34:27 dpchr...@p43400e ~
$ ./foo
Ouch!
hello, world!

2009-05-02 17:34:43 dpchr...@p43400e ~
$ ./foo -d
%hash = (
          'BAZ' => [
                     1,
                     2,
                     3
                   ],
          'BAR' => 'frunabulax',
          'FOO' => 12345
        );
hello, Ouch!
world!


Also, download and install perlindex to help you find information in the
Perl documentation:

    http://search.cpan.org/~ulpfr/perlindex-1.502/perlindex.PL


HTH,

David


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to