Wagner, David --- Senior Programmer Analyst --- WGO am Freitag, 3. November 2006 22:16: > If it is only one line and it is record separator is carriage > return as defined by your system, then a simple loop like:
Hello David and Tim, The below code is a good example why one should happily place: use strict; use warnings; at the beginning. > while: ( <MYFILEIN> ) { You meant: while ( <MYFILEIN> ) { > chomp; Just omit the chomp and the code behaves the same. > if ( substr($_,70,2) =~ /(xx|xy|xz)/I ) { The modifier should be /i, not /I. With /I, the code doesn't even compile. If you want to use a regex, then it might be better to: - anchor the pattern (not completely shure though if that makes a difference *here*) - stop the matching process immediately after the first char does not match - use non-capturing parenthesis (?:) to decrease the work of the regex engine, since the matched string is not used - Then, since the same substring is used below, it might (not shure) be appropriate to store the extracted string into a variable That would leed to [untested]: if ( (my $s=substr($_,70,2)) =~ /^x(?:x|y|z)/i ) { > print MYFILEOUT substr($),70,2) . You meant '$_', not '$'. print MYFILEOUT $s . # see above alternative > Substr($_,91,1) . "\n"; You meant: substr ($_,91,1) . "\n"; > } > } > > simple format and should be straight forward. Dani [snipped top-posting history] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>