H I'm writing a simple text comparing tool.
I read two command lines parameters passd to the scipts - 2 input files...however the script exits with the error messages that the second one does not exist...but it does!
Even when I swap the order of those 2 given input file names still the first one gets opened but always the second one does not no matter what file I pass as a second argument...
do you have any idea ??
Thanks
The function in which it fails:
sub Init {
my $file1;
my $file2;
my $tmp;
if(defined($opt_h)){
print Syntax();
exit;
}
$file1 = $ARGV[0];
$file2 = $ARGV[1];
print "\nFirst file - $file1\nSecond File - $file2\n";
if((!defined($file1)) || (!defined($file2))){
print "\nSpecify the correct number of output files!\n";
print Syntax();
exit;
}
if(!defined($opt_c)){
print "\nNo config file provided, defualt configuration will be us
+ed!\n";
init_default_config();
} else {
read_config_file();
}
if((!(-e $file1)) || (!(-e $file2))){
print "\nEither of specified files does not exist!\n";
exit;
}else{
#opening input files for reading
open FILE1, $file1 or die "\nCan't open $file1 for reading: $!\n";
open FILE2, $file2 or die "\nCan't open $file2 for reading: $!\n";
}
#opening output files for writing
open OUTFILE, "results" or die "\nCan't open $file2 for reading: $!\
+n";
#print the compare header to output file
print OUTFILE "CALL-ID\n";
$tmp = "_" x 78;
print OUTFILE "$tmp\n";
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.