H
Hemant
Folks,
When I try to expand file name in a loop, perl fails to expand
everyother file.
Example:
#!/usr/bin/perl
#
@FileListArr = (
"Full-2008-06-16-23:29:40",
"Incr-2008-06-17-22:02:18",
"Incr-2008-06-18-22:02:23",
"Incr-2008-06-19-22:02:20",
"Incr-2008-06-20-22:02:38",
"Incr-2008-06-21-22:05:30",
"Incr-2008-06-22-22:05:26",
);
foreach $Volume (@FileListArr)
{
$File=glob("/backups/backupfiles/*/$Volume");
if (!defined $File)
{
print "File not found for $Volume\n";
}
else
{
print "$File\n";
}
}
The output of the script:
/backups/backupfiles/lidp11/Full-2008-06-16-23:29:40
File not found for Incr-2008-06-17-22:02:18
/backups/backupfiles/lidp11/Incr-2008-06-18-22:02:23
File not found for Incr-2008-06-19-22:02:20
/backups/backupfiles/lidp11/Incr-2008-06-20-22:02:38
File not found for Incr-2008-06-21-22:05:30
/backups/backupfiles/lidp11/Incr-2008-06-22-22:05:26
I also tried using "<>" keyword, but got same result. I tried similar
test to expand user's HOME directory (tilde expansion) and for same
result.
I tested it under perl 5.8.4 on AIX and perl 5.10.0 on linux.
When I try to expand file name in a loop, perl fails to expand
everyother file.
Example:
#!/usr/bin/perl
#
@FileListArr = (
"Full-2008-06-16-23:29:40",
"Incr-2008-06-17-22:02:18",
"Incr-2008-06-18-22:02:23",
"Incr-2008-06-19-22:02:20",
"Incr-2008-06-20-22:02:38",
"Incr-2008-06-21-22:05:30",
"Incr-2008-06-22-22:05:26",
);
foreach $Volume (@FileListArr)
{
$File=glob("/backups/backupfiles/*/$Volume");
if (!defined $File)
{
print "File not found for $Volume\n";
}
else
{
print "$File\n";
}
}
The output of the script:
/backups/backupfiles/lidp11/Full-2008-06-16-23:29:40
File not found for Incr-2008-06-17-22:02:18
/backups/backupfiles/lidp11/Incr-2008-06-18-22:02:23
File not found for Incr-2008-06-19-22:02:20
/backups/backupfiles/lidp11/Incr-2008-06-20-22:02:38
File not found for Incr-2008-06-21-22:05:30
/backups/backupfiles/lidp11/Incr-2008-06-22-22:05:26
I also tried using "<>" keyword, but got same result. I tried similar
test to expand user's HOME directory (tilde expansion) and for same
result.
I tested it under perl 5.8.4 on AIX and perl 5.10.0 on linux.