SPUG: Regex multi-line question

Richard Wood wildwood_players at yahoo.com
Wed Aug 4 09:26:50 CDT 2004


Thanks to all three that responded to this call.

Charles' solution is along the lines of what I was
thinking. 

Regards, 

Rich Wood

--- ced at carios2.ca.boeing.com wrote:

> > I can do it easily enough with a while<> loop (or
> a
> > parser) but I figure there is a more obfuscated
> > solution that one of you can propose using one
> line.
> 
> This uses a while loop... but, frankly, I think
> you'll 
> wind up in obfuscation hell without one:
> 
> --
> Charles DeRykus
> 
> use strict;
> use warnings;
> 
> # FORE...!! : golf course use only...   
> 
> { local $/;  $_ = <DATA>; }
> 
> while ( m{  \G .*? <media\stype="(.*?)" 
>                .*? <path>        (.*?) </path> 
>                .*? <tarname>     (.*?) </tarname> 
> }xsg )  {
> 
>         my( $type,$path,$tar ) = ( $1, $2, $3); 
>         print join( ", " => $type,$path,$tar), "\n";
> 
> }
> __END__
> <?xml version="1.0" encoding="UTF-8" ?>
> <transfer>
> <media type="Record">
>   <server>MUSIC</server>
>   <path>/home/woody/vinyl/Migration</path>
>   <tarname>JB_Migration.tar</tarname>
> </media>
> <media type="CD">
>   <server>MUSIC</server>
>   <path>/home/woody/cd/Migration</path>
>   <tarname>JB_Migration.tar</tarname>
> </media>
> <media type="TAPE">
>   <server>MUSIC</server>
>   <path>/home/woody/cass/Migration</path>
>   <tarname>JB_Migration.tar</tarname>
> </media>
> </transfer>
> 
> 


=====
Richard O. Wood
Wildwood IT Consultants, Inc.
wildwood_players at yahoo.com
425.281.1914 mobile
206.544.9885 desk


		
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail 


More information about the spug-list mailing list