ok does this s/^(?=E\d{5})/eject\t0,0,0\t\n/ while <>;
say...
from the beginning of the line match 0 or 1 E's with any digits then print
the eject string? I am not following the { 5 }.
my E string is 6 characters long, so why the 5?
isn't there a insert regular expression?
use strict;
my $ejectapes = "/usr/local/bin/perld/exports";
open (ACSLS, "$ejectapes") || die "cannot open file ejectapes \n: $!";
while (defined($ejectapes = <>)) {
s/^(?=E\d{5})/eject \t0,0,0\t\n/
}
close (ACSLS);
Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams
"John W. Krahn" <[EMAIL PROTECTED]>
05/25/2004 07:49 PM
To: [EMAIL PROTECTED]
cc:
Subject: Re: entering text within a file
[EMAIL PROTECTED] wrote:
>
> All,
Hello,
> I am having some trouble figuring this out. I want to enter some text
> within a pre-existing file. Here is what the file would look like
>
> E00140
> E00141
> E00143
> .
> .
> .
>
> here is my code thus far
>
> #!/usr/local/bin/perl -w
> use strict;
> my $ejectapes = "/usr/local/bin/perld/exports";
> open (ACSLS, "$ejectapes") || die "cannot open file ejectapes \n: $!";
> while (defined($ejectapes = <>)) {
> print "eject", "\t", "0,0,0", "\t", "\n", $_;
> close (ACSLS);
> }
>
> I want to print eject 0,0,0 before the tapeid
You can either use Perl's "in-place" edit feature or use a second file
to write the data to. Using in-place edit would look something like
this:
#!/usr/local/bin/perl -w
use strict;
( $^I, @ARGV ) = ( '', '/usr/local/bin/perld/exports' );
s/^(?=E\d{5})/eject\t0,0,0\t\n/ while <>;
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>