Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If else statement w/ glob

Status
Not open for further replies.

komark

Technical User
Sep 12, 2005
134
US
Hi,
I am not able to get the correct values when I am running this script below. Basically I am putting writing everything in an array into a file 'file.txt'. Then foreach line in the file I am trying to find the file in the directory /home/omar

open (DAT, "file.txt");
@newFiles = <DAT>;

foreach $newfile (@newFiles)

{
chomp $newfile;

my $smsdir = "/home/omar";

print "$newfile\n";

if ( glob ("$smsdir/*/*_$newfile*"))
{
$type = "YES";
}
else
{
$type = "NO";
}

print "$type\n";

I am getting some of the results correct and some false. Does anyone know what the problem is?

Omar.
 
Find my answer.

I had to use this at the top inorder for the glob function to work correctly.

use File::Glob ':glob';
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top