Sorry, but I was just giving quick code and had NOT run. Using
of strict and warnings is the only way to go. I was writing and doing
other things. I apologize for not catching, but was supplying the open
for th input or output, etc. just a inkling on what he could do to get
started. 

          If you have any problems or questions, please let me know.

     Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449           FAX
http://fedex.com/us 

-----Original Message-----
From: D. Bolliger [mailto:[EMAIL PROTECTED] 
Sent: Friday, November 03, 2006 14:19
To: beginners@perl.org
Subject: Re: line position

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>



**********************************************************************
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**********************************************************************


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to