SPUG: reg exp's

ced at carios2.ca.boeing.com ced at carios2.ca.boeing.com
Wed Sep 4 21:17:07 CDT 2002


> while (<>) {
> 	/^(.*?):(.*)$/;
> 	my $heading = $1;
> 	my $data = $2;
> 	... do your stuff ...
> }

Be careful to test for regex success though. If there were no 
match [an embedded blank line somewhere within valid data for 
instance], $1, etc will be undefined.

  if (/^(.*?):(.*)/) { ... }
        

Rgds,
--
Charles DeRykus


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org




More information about the spug-list mailing list