Ramnarayan
Programmer
Hi,
I am trying to figure why PERL is giving a warning "Use of uninitialized value in -e at abc.pl line 16". I wantedly made sure that I tested that the script should work for gml files present under sss/ directory. But if they are not there, it should issue the errror "Can't find any GML files!:". I am not understanding where the warning is coming from. How to remove the warning?
Here is the script....
#!/usr/local/bin/perl -w
my $whoami = ($0 =~ m,([^/\\]*)$,) ? $1 : $0;
my $errors = 0;
use strict;
my $dir = "sss/";
my @gmlfiles = glob("${dir}*.gml");
my $gmlfiles = shift(@gmlfiles);
my $abs_found = 0;
my $bib_found = 0;
my $abs_notfound = 0;
my $gmlfile = 0;
if (-e $gmlfiles)
{
foreach(@gmlfiles)
{
my $gml = $_;
$gmlfile ++;
open (GML, "<$gml") or fatal ("Can't open $gml for read access: $!\n");
while(<GML>)
{
my $line = $_;
if ($line =~ m/\<abs\>/)
{
$abs_found++;
}
if ($line =~ m/\<bib\>/)
{
$bib_found++;
}
}
}
}
else
{
fatal("Can't find any GML files!:\n");
}
I am trying to figure why PERL is giving a warning "Use of uninitialized value in -e at abc.pl line 16". I wantedly made sure that I tested that the script should work for gml files present under sss/ directory. But if they are not there, it should issue the errror "Can't find any GML files!:". I am not understanding where the warning is coming from. How to remove the warning?
Here is the script....
#!/usr/local/bin/perl -w
my $whoami = ($0 =~ m,([^/\\]*)$,) ? $1 : $0;
my $errors = 0;
use strict;
my $dir = "sss/";
my @gmlfiles = glob("${dir}*.gml");
my $gmlfiles = shift(@gmlfiles);
my $abs_found = 0;
my $bib_found = 0;
my $abs_notfound = 0;
my $gmlfile = 0;
if (-e $gmlfiles)
{
foreach(@gmlfiles)
{
my $gml = $_;
$gmlfile ++;
open (GML, "<$gml") or fatal ("Can't open $gml for read access: $!\n");
while(<GML>)
{
my $line = $_;
if ($line =~ m/\<abs\>/)
{
$abs_found++;
}
if ($line =~ m/\<bib\>/)
{
$bib_found++;
}
}
}
}
else
{
fatal("Can't find any GML files!:\n");
}