inserting text, with a rename

DBSMITH_at_OhioHealth.com
Date: 05/27/04


To: "JupiterHost.Net" <mlists@jupiterhost.net>
Date: Thu, 27 May 2004 17:24:24 -0400

understood!

ok now if the *.bak file exists would I say something like: in order to
make a bakup or a bakup

use warnings;
use strict;
my @ejectapes = qw(/usr/local/bin/perld/exports);
($^I, @ARGV) = ('.bak', @ejectapes);
if ( -s '.bak' ) {
        rename (".bak", ".bak1") || die "cannot rename file: $! ";a
}
while (<>) {
s/(^E?\d{5})/eject\t0,0,0\t$1\n/;
print;
}

Isn't there a File:Copy module?

Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams

"JupiterHost.Net" <mlists@jupiterhost.net>
05/27/2004 01:19 PM

 
        To: DBSMITH@OhioHealth.com
        cc: beginners@perl.org
        Subject: Re: entering text within a file

DBSMITH@OhioHealth.com wrote:

>
> no.... thanks! but why are you setting ejectapes as an array and then
> calling it with @ instead of $?
>
>
> my @ejectapes = qw(/usr/local/bin/perld/exports);
> ($^I, @ARGV) = ('.bak', @ejectapes);
>
> instead of
>
> my @ejectapes = qw(/usr/local/bin/perld/exports);
> ($^I, @ARGV) = ('.bak', $ejectapes);

because :
  0) @ejectapes is not the same as $ejectapes :)
  1) =qw() is an array
  2) you're assigning it to @ARGV which is also an array, so array need
to be used instead of variables, if you did it the scalar way and aded
something to qw() like my @ejectapes = qw(/usr/local/bin/perld/exports
/foobar/tapes /baz/wal/tapes);

It would only loop throught the first one since that's the only one
you're using :)

HTH

Lee.M - JupiterHost.Net

-- 
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Relevant Pages