smileysam
Member level 4
Iam trying to copy content of one file into another .
The code is not working and hangs and the content is not copied into file 2
I have pasted the code. Any comment will be useful . thanks.
# copy one file into another.
$len = $#ARGV + 1;
print($len);
print("$ARGV[0]\n");
print("$ARGV[1]\n");
if( (open(fileptr1,$ARGV[0])) == 0)
{
die("Error in opening the file");
}
else
{
print("File 1 opened\n");
}
print("Iam here");
if( (open(fileptr2,">>".$ARGV[1])) == 0)
{
die("Error in opening the file");
}
else
{
print("File 2 opened\n");
}
while(fileptr1 ne "")
{
$input = <fileptr1>;
print ($input);
print fileptr2 ($input);
}
close(fileptr1);
close(fileptr2);
The code is not working and hangs and the content is not copied into file 2
I have pasted the code. Any comment will be useful . thanks.
# copy one file into another.
$len = $#ARGV + 1;
print($len);
print("$ARGV[0]\n");
print("$ARGV[1]\n");
if( (open(fileptr1,$ARGV[0])) == 0)
{
die("Error in opening the file");
}
else
{
print("File 1 opened\n");
}
print("Iam here");
if( (open(fileptr2,">>".$ARGV[1])) == 0)
{
die("Error in opening the file");
}
else
{
print("File 2 opened\n");
}
while(fileptr1 ne "")
{
$input = <fileptr1>;
print ($input);
print fileptr2 ($input);
}
close(fileptr1);
close(fileptr2);