in reply to opening new file in different directory
You could define them with use constant or some other way. Which is just another TIMTOWTDI...#!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]; }
--
Graq
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: opening new file in different directory
by George_Sherston (Vicar) on Oct 23, 2001 at 19:32 UTC | |
by graq (Curate) on Oct 23, 2001 at 19:44 UTC | |
by George_Sherston (Vicar) on Oct 23, 2001 at 19:49 UTC | |
by IraTarball (Monk) on Oct 23, 2001 at 20:48 UTC | |
by buckaduck (Chaplain) on Oct 24, 2001 at 00:43 UTC | |
by IraTarball (Monk) on Oct 24, 2001 at 01:26 UTC | |
by IraTarball (Monk) on Oct 23, 2001 at 20:42 UTC | |
by graq (Curate) on Oct 24, 2001 at 18:47 UTC |