No such file or directory

No such file or directory

am 29.05.2008 12:45:50 von Mimi Cafe

------=_Part_10547_11202546.1212057950369
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

my script is in the same directory as my files, but it cannot find the file
ABC.txt in open() below.

foreach my $supplied (@ARGV){
# Output file name set of element currently processed.

# Open file to read from.
open (INPUTFILE, "<", "$supplied") or die "Could not open $supplied: $!\n";
# Error: No such file or directory.
}

Any help

Mimi

------=_Part_10547_11202546.1212057950369--

Re: No such file or directory

am 29.05.2008 12:48:46 von peng.kyo

On Thu, May 29, 2008 at 6:45 PM, Mimi Cafe wrote:
> my script is in the same directory as my files, but it cannot find the file
> ABC.txt in open() below.
>
> foreach my $supplied (@ARGV){
> # Output file name set of element currently processed.
>
> # Open file to read from.
> open (INPUTFILE, "<", "$supplied") or die "Could not open $supplied: $!\n";
> # Error: No such file or directory.
> }

How do you pass the files to the script?
Using opendir to do it is better I may suggest.


--
Jeff Peng - Peng.Kyo@Gmail.com
Professional Squid supports in China
http://www.ChinaSquid.com/

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: No such file or directory

am 29.05.2008 12:52:53 von Ken Foskey

--=-HB6JrN2NvmPZz6UroLEe
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Thu, 2008-05-29 at 11:45 +0100, Mimi Cafe wrote:

> my script is in the same directory as my files, but it cannot find the file
> ABC.txt in open() below.
>
> foreach my $supplied (@ARGV){
> # Output file name set of element currently processed.
>
> # Open file to read from.
> open (INPUTFILE, "<", "$supplied") or die "Could not open $supplied: $!\n";
> # Error: No such file or directory.
> }
>
> Any help
>
> Mimi



for starters you might want to look at the <> operator:

while( <> ) {
}

Will read each file on the command line in sequence, saves you thinking
about it.

If it is Unix it is case sensitive, is this your problem?

Are you actually in the directory? `bin/myscript.pl bin/ABC.txt`


--=-HB6JrN2NvmPZz6UroLEe--

Re: No such file or directory

am 29.05.2008 13:06:38 von Mimi Cafe

------=_Part_10674_23205739.1212059198346
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

I am on Windows so it should not be case-sensitive. The script and all
required files in one folder. I pass 2 arguments to the script and can I can
open open the file in the $ARGV[0].

my $ad_clients = shift @ARGV;

open (ADFILE, "<", $ad_clients) or die "Could not open $ad_clients for
reading: $! \n"; # This works fine!
my @ad_clients = ;
close ADFILE;

my %inputclient;

foreach my $supplied (@ARGV){
open (INPUTFILE, "<", $supplied) or die "Could not open $supplied for
reading: $!\n # This does not works! Error: No such file or directory
Mimi




On 29/05/2008, Ken Foskey wrote:
>
> On Thu, 2008-05-29 at 11:45 +0100, Mimi Cafe wrote:
>
> my script is in the same directory as my files, but it cannot find the file
> ABC.txt in open() below.
>
> foreach my $supplied (@ARGV){
> # Output file name set of element currently processed.
>
> # Open file to read from.
> open (INPUTFILE, "<", "$supplied") or die "Could not open $supplied: $!\n";
> # Error: No such file or directory.
> }
>
> Any help
>
> Mimi
>
>
>
> for starters you might want to look at the <> operator:
>
> while( <> ) {
> }
>
> Will read each file on the command line in sequence, saves you thinking
> about it.
>
> If it is Unix it is case sensitive, is this your problem?
>
> Are you actually in the directory? `bin/myscript.pl bin/ABC.txt`
>
>
>

------=_Part_10674_23205739.1212059198346--

Re: No such file or directory

am 29.05.2008 13:49:59 von Mimi Cafe

------=_Part_10801_16119447.1212061799263
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

> I am on Windows so it should not be case-sensitive. The script and all
> required files in one folder. I pass 3 arguments to the script (script.pl
> file1 file2 file3)and I can open the first file stored in $ARGV[0] as seen
> below:
>
> my $ad_clients = shift @ARGV;
>
> open (ADFILE, "<", $ad_clients) or die "Could not open $ad_clients for
> reading: $! \n"; # This works fine!
> my @ad_clients = ;
> close ADFILE;
>
> my %inputclient;
>
> foreach my $supplied (@ARGV){
> open (INPUTFILE, "<", $supplied) or die "Could not open $supplied for
> reading: $!\n # This does not works! Error: No such file or directory
>
Mimi

>
>
>
>
> On 29/05/2008, Ken Foskey wrote:
>>
>> On Thu, 2008-05-29 at 11:45 +0100, Mimi Cafe wrote:
>>
>> my script is in the same directory as my files, but it cannot find the file
>> ABC.txt in open() below.
>>
>> foreach my $supplied (@ARGV){
>> # Output file name set of element currently processed.
>>
>> # Open file to read from.
>> open (INPUTFILE, "<", "$supplied") or die "Could not open $supplied: $!\n";
>> # Error: No such file or directory.
>> }
>>
>> Any help
>>
>> Mimi
>>
>>
>>
>> for starters you might want to look at the <> operator:
>>
>> while( <> ) {
>> }
>>
>> Will read each file on the command line in sequence, saves you thinking
>> about it.
>>
>> If it is Unix it is case sensitive, is this your problem?
>>
>> Are you actually in the directory? `bin/myscript.pl bin/ABC.txt`
>>
>>
>>
>
>

------=_Part_10801_16119447.1212061799263--

Re: No such file or directory

am 30.05.2008 12:00:06 von Mimi Cafe

------=_Part_14685_4465261.1212141606843
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Still cannot see why Perl complains that Could not open file for reading.
File or directory does exist.
I have modified my script and now using Getopt::Long module instead of the
@ARGV variable. Can someone take a look?

The script is now run with command line options like this:
myscript --master --compare file_name --compare another_file

Here is a section of the script

use strict;
use warnings;
#use diagnostics;
use Getopt::Long;

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

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.
#################################

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 = ;
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
not open file for reading. File or directory does exist.
while (){
chomp;
$inputclient{"s_"} = $_;
}
close INPUTFH;

#$outputfile = "NOT_IN" . "$outputfile";
my $outputfile = $list;
my (@missing_clients, %outputclient);

open (OUTPUTFILE, ">", $outputfile) || die "Could not open $outputfile:
$!\n";
foreach my $aditem (@master_clients){
push (@missing_clients, $aditem) unless exists $inputclient{"$aditem"};
}



On 29/05/2008, Mimi Cafe wrote:
>
>
> I am on Windows so it should not be case-sensitive. The script and all
>> required files in one folder. I pass 3 arguments to the script (script.pl
>> file1 file2 file3)and I can open the first file stored in $ARGV[0] as seen
>> below:
>>
>> my $ad_clients = shift @ARGV;
>>
>> open (ADFILE, "<", $ad_clients) or die "Could not open $ad_clients for
>> reading: $! \n"; # This works fine!
>> my @ad_clients = ;
>> close ADFILE;
>>
>> my %inputclient;
>>
>> foreach my $supplied (@ARGV){
>> open (INPUTFILE, "<", $supplied) or die "Could not open $supplied for
>> reading: $!\n # This does not works! Error: No such file or directory
>>
> Mimi
>
>>
>>
>>
>>
>> On 29/05/2008, Ken Foskey wrote:
>>>
>>> On Thu, 2008-05-29 at 11:45 +0100, Mimi Cafe wrote:
>>>
>>> my script is in the same directory as my files, but it cannot find the file
>>> ABC.txt in open() below.
>>>
>>> foreach my $supplied (@ARGV){
>>> # Output file name set of element currently processed.
>>>
>>> # Open file to read from.
>>> open (INPUTFILE, "<", "$supplied") or die "Could not open $supplied: $!\n";
>>> # Error: No such file or directory.
>>> }
>>>
>>> Any help
>>>
>>> Mimi
>>>
>>>
>>>
>>> for starters you might want to look at the <> operator:
>>>
>>> while( <> ) {
>>> }
>>>
>>> Will read each file on the command line in sequence, saves you thinking
>>> about it.
>>>
>>> If it is Unix it is case sensitive, is this your problem?
>>>
>>> Are you actually in the directory? `bin/myscript.pl bin/ABC.txt`
>>>
>>>
>>>
>>
>>
>

------=_Part_14685_4465261.1212141606843--