in reply to use warnings => Use of uninitialized value...

Thanks for all the answers.
I get the impression that it is good practice to write code that doesn't generate any warnings. In my case I do stuff like
if ( $some_value =~ /some_thing_here/ ) { .... }
which I should change to
if ( defined $some_value && $some_value =~ /some_thing_here/ ) { .... }

Luca

Replies are listed 'Best First'.
Re^2: use warnings => Use of uninitialized value...
by davorg (Chancellor) on May 24, 2006 at 10:00 UTC

    That's one way to do it. Alternatively you can initialise $some_value when you define it.

    my $some_value = '';

    Or use many other techniques to ensure that it contains data before you try to use it.

    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Re^2: use warnings => Use of uninitialized value...
by gellyfish (Monsignor) on May 24, 2006 at 09:59 UTC

    Yeah that's the one, however the "Use of uninitialized value in regexp compilation" would indicate that you are also trying to interpolate an uninitialized variable into a regular expression either directly (e.g. something like : /$some_value/) or using the qr() mechanism, because all the warnings come from one line I would favour the former.

    /J\