Re: Use of uninitialized value Error
On 12/30/05, David Gilden <dowda@xxxxxxxxxxxxxxxxxx> wrote:
> $_ =~ /(\d+)/;
> $num = int($1);
If there's no digit in $_, then $1 will be undef (or worse; see
below). I think that's probably your bug: Some filename isn't like the
others. Instead of this:
> my @files =<*>;
Consider something like this:
my @files = <Gambia*.tiff>;
Later, when you're trying to get the number from the string, you can
allow for the possibility that there isn't one by checking the value
of the pattern match. If it's false, the pattern didn't match, and you
shouldn't use $1.
if (/(\d+)/) {
$num = $1;
} else {
warn "No digits found in '$_', continuing...\n";
next;
}
Hope this helps!
--Tom Phoenix
Stonehenge Perl Training
.
Relevant Pages
- Re: code within libraries vs code within same project
... Is this a bug in System.Diagnostics.StackTrace? ... //the .dll do not appear to have all the info, particularly filename. ... (microsoft.public.dotnet.languages.csharp) - Re: Common dialog control returns wrong filename
... It is caused by the listview generating a CDN_SELCHANGE: message when the listview area is clicked. ... This is not a bug per: se, but rather the way a listview works. ... : Remember too that Word and Excel do not use the Windows common dialogs, so: their custom implementation to duplicate the functionality of the real: common dialogs may circumvent the problem. ... sometimes:: returns a different filename from the name that is displayed on the ... (microsoft.public.vb.bugs) - Re: Tilde expansion on (Windows)files?
... that a tilde in a filename makes problems: ... internal representation of the string makes a difference is a bug. ... perhaps tried to cover too many points at once in the bug report. ... tilde is another issue altogether. ... (comp.lang.tcl) - Re: Guarantee Critical Regions in Portable code. Portable Semaphores?
... Parsing the filename is the last resort if your MP3 file is missing ... inherent FS bug. ... Observe that an Explorer window does not show the 8.3 ... on a FAT volume also suppresses these 8.3 orphans. ... (comp.arch.embedded) - Re: Statistics for RCM
... Use of uninitialized value in pattern match at ./newsstats line 499. ... manually removed messages. ... something to get that to actually report for the whole ... a bug as a customization needed for certain groups. ... (rec.crafts.metalworking) |
|