To start with, I would not use relative paths. I would define a base path and work from there.
#!perl -w
use strict;
my $file = "graq.txt";
my $source = &get_path("oldfiles/$file");
my $result = &get_path("newfiles/$file");
open( READ, "<$source" ) or die( "Could not open $source: $!\n" );
open( WRITE, ">$result" ) or die( "Could not write to $result: $!\n" )
+;
while(<READ>)
{
# Do stuff.
print WRITE $_;
}
close WRITE;
close READ;
# ---------------------------------
# Local Functions.
sub base_path { '/home/main/sub'; }
sub get_path { return &base_path."/".$_[0]; }
You could define them with
use constant or some other way. Which is just another TIMTOWTDI...
editTypo in die()/edit
--
Graq