[ Top posting fixed ] [EMAIL PROTECTED] wrote: > > "John W. Krahn" <[EMAIL PROTECTED]> 05/25/2004 07:49 PM > > > > 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 <>; > > 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?
No, what it says is, match at the beginning of the line if it is followed by 'E' followed by five digits. \d{5} is just short for \d\d\d\d\d. (?=) is a positive zero-width look-ahead assertion which means that the expression 'E\d{5}' must match after the line beginning ^ but it does not effect the position of the match so that the replacement string "eject\t0,0,0\t\n" is inserted at the line beginning. 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>