To start off, I am new to perl....
Here's what I'm trying to do. I want to verify a file exist.
Here are the files:
1file_15895_123.csv
2file_13232_342.csv
3file_13242_314.csv
I have the user type in what file they want to verify. Now, currently, in order for it to work, they have to type in the entire file name. What i'm wanting to do is have them just type in the first part of the file name; ex. 1, 2 ,3. I'm trying to figure out how to add a wild card that will automatically find everything after what the user has inputted. I keep putting a * but that doesn't work for me...
Here's my code for that portion:
Code:
sub findfile
{
my $line = "";
my @fields;
$filetoscan = "C:/FilePath/" . $filename . ".csv";
if (-e $filetoscan)
{
open(FILETOSCAN, $filetoscan);
while ($line = readline(FILETOSCAN))
{
#print("$line\n");
@fields = split(',', $line);
if ($fields[0] =~ "Total")
{
if ($fields[1] =~ "0")
{
print ("\nThis is Okay!\n");
}
else
{
print ("\nThis is not Okay!\n");
}
}
}
close(FILETOSCAN);
}
else
{
print ("\nFile does not exist!\n");
}
}
Another problem if you have time....what happens if it files 2 of the files that start off with the same # or Letter?
Thanks for your help!