kitty has asked for the wisdom of the Perl Monks concerning the following question:
if ($var{file}) #the test-file name entered by user { my $fname=$var{file}; unless ($fname) { die ("No file specified.\n"); } unless (-e $fname) { die ("File does not exist.\n");} my $line; open (INFO,"$fname") or die ("Cannot open .. $!\n"); while (<INFO>) { $line=<INFO>; } close INFO; my @new2; if($var{param}) { list_param($var{param}); } if($var{the}) { list_the($var{the}); } sub list_param($) { if ($line =~ m:Absolute_Error_Tolerance=":) { @new2=split(/\"/,$line); $line=~s/$new2[1]/$G{param}/; } } sub list_the($) { if ($line =~ m:The_Rounding_Unit=":) { @new2=split(/\"/,$line); $line=~s/$new2[1]/$G{the}/; } } my $timestamp = strftime("%m/%d/%Y_", localtime((stat($var{file}))[9]) +); my $file2=$timestamp.$var{file}; rename ($var{file},$file2) or warn "***\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: using command line switches to edit file
by physi (Friar) on Feb 13, 2006 at 12:17 UTC | |
by kitty (Novice) on Feb 13, 2006 at 13:35 UTC | |
by holli (Abbot) on Feb 13, 2006 at 14:13 UTC | |
by kitty (Novice) on Feb 13, 2006 at 16:53 UTC |