Re: Uninitialized value in pattern match
- From: rob.dixon@xxxxxxx (Rob Dixon)
- Date: Mon, 31 Mar 2008 20:40:27 +0100
Johan wrote:
The last line of this code
foreach $PkgFile( @$PkgList )
{
if( $PkgFile =~m/^\s*$/)
gives this warning message
Use of uninitialized value in pattern match (m//) at packagefile.pm
line 838.
How can I solve this? (I have no idea what the code does...)
Some elements of @$PkgList are undefined. Beware that this may point to
errors in the preceding code that creates the array, but you can avoid
the warning by writing:
foreach $PkgFile (@$PkgList) {
next unless defined $PkgFile;
if ($PkgFile =~ /^\s*$/) {
:
:
}
}
If you expect to spend much time working on this program then it is also
well worth putting
use strict;
at the start, if it is not already there, and declaring all variables
with 'my'.
HTH,
Rob
.
- References:
- Uninitialized value in pattern match
- From: Johan
- Uninitialized value in pattern match
- Prev by Date: Re: parser using perl
- Next by Date: Re: commify_series script in cookbook page 94
- Previous by thread: Re: Uninitialized value in pattern match
- Next by thread: parser using perl
- Index(es):
Relevant Pages
|