+1 to Bob;

Jos�.

-----Original Message-----
From: Bob Showalter [mailto:[EMAIL PROTECTED] 
Sent: Monday, September 08, 2003 5:29 PM
To: 'Akens, Anthony'; [EMAIL PROTECTED]
Subject: RE: Matching a section of test


Akens, Anthony wrote:
> Sorry for the first post, didn't mean this as
> a reply.
> 
> 
> Hello all...
> 
> I'm wanting to write a script that scans a file,
> ignoring all lines until it reaches a certain
> section, then processes all lines in that
> section that are not comments, until it reaches
> the end of that section.
> 
> The section would be designated like this:
> 
> ## Beging Processing ##
> 
> ## End Processing ##
> 
> So I open my file, and skip all lines until I
> see that first bit...  Then do stuff until I
> see the last bit.  Can someone help me out with
> this?
> 
> Tony
> 
> 
> #!/usr/bin/perl -w
> 
> use strict;
> 
> open (FILE, "<myfile")
>         or die "Could not open Template. ($!)";
> 
> while ($line = <FILE>) {
>       #skip until beginning....
> 
>       #End when "End Processing" is reached
>       last if $line =~ "End Processing";
> 
>       #Process the lines in between
>       next if $line =~ /^#/;
>       #do stuff....
> }

The range operator in scalar context can handle this kind of thing. See perldoc perlop 
and search for "Range Operators".

   while (<FILE>) {
      if (/^## Begin/ .. /^## End/) {
         ...do stuff here with $_
      }
   }

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



**** DISCLAIMER ****

"This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to