Re: Could not open testfile.txt: No such file or directory

[email protected] ("Beginner")
Newsgroups perl.beginners.cgi
Message-ID <[email protected]>
Hi,

Did you mean to mail the cgi list?

On 30 May 2008 at 13:04, Mimi Cafe wrote:


> use constant DEFAULT_REPORTDIR => ".\\compare_report";

Is this a windows path? You can and probably should always use '/' 
for directory path separators or in this case 'compare_report' would 
do.

> my $master_list = "";
> my @compare_lists = "";
> my $help = "";
> 
> Getopt::Long::Configure ("ignorecase");
> 
> GetOptions(
>  "master=s" => \$master_list,
>  "compare:s" => \@compare_lists,
>  "help|?!" => \$help,
> );
> 
> usage() if $help;
> @compare_lists = split(' ',join(' ',@compare_lists));
> foreach (@compare_lists){
>  die "File $_ does not exist or it's empty. Please check the file try
> again.\n" unless -s $_;
> }
> 
> ################################
> #foreach (@compare_lists){print "$_\n";} # This prints the CLI arguments
> correctly.
> #################################

What is the output from the above for loop?
 
> my $outputdir = DEFAULT_REPORTDIR;
> unless (-d $outputdir){
>  mkdir ($outputdir) or die "could not create dir for $outputdir: $!\n";
> }
> 
> # Read the master list and populate our array.
> open (MASTERFILE, "<", $master_list) or die "Could not open $master_list for
> reading: $!\n";
> my @master_clients = <MASTERFILE>;
> close MASTERFILE;
> ##############################
> #print "master list starts below:\n";
> #foreach (@master_clients){print "$_\n";}exit;
> ######################################
> my (%inputclient,$list);
> 
> # Read the other files and compare the content to the master client list.
> foreach $list (@compare_lists){
>  # Output file name set of element curerently processed.
>  # Open file to read from.
>  open(INPUTFH, "<", $list) or die "Could not open $list for reading:
> $!\n"; # Could

No need for "<" here. $list will do or "<$list" if you want to hammer 
home the point that your reading in.

Consider using $inputfh for your file handle, there more portable.

What is the exact error message line, include the value of $list? 
It's this that the OS can't read/find. Post that and it might be 
clearer where the problem is.

Good luck,
Dp.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.