|Date: ||Tue, 23 Jan 2007 23:25:21 -0800|
|Reply-To: ||David L Cassell <davidlcassell@MSN.COM>|
|Sender: ||"SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>|
|From: ||David L Cassell <davidlcassell@MSN.COM>|
|Subject: ||Re: substr, scan|
|Content-Type: ||text/plain; format=flowed|
tobydunn@HOTMAIL.COM wrote back:
>On Wed, 24 Jan 2007 04:07:13 +0000, toby dunn <tobydunn@HOTMAIL.COM> wrote:
> >Art ,
> >Ian leaves me confused quite a bit and I often find careful, thoughful,
> >often long study of what he says yeilds some perl of wisdom. I would
> >think Ian is saying that this particular text parsing problem has been
> >solved using PRX. So why use something that is less robust to solve the
> >problem, well the level of skil in a shop is one valid reason I can see.
> >But pushing th limits every now and again ussually isnt a bad thing.
> >if we never ventured out we would get no where in our development.
> >So to that end I offer this PRX solution that may very well make Perl
> >data test;
> >input var $11. ;
> >Data Need ( Keep = Var Sec Min Hour ) ;
> >Set Test ;
> >Retain Pattern ;
> >If _N_ = 1 Then Pattern = PRXParse( "/\d+[smh]/" ) ;
> >Start = 1 ;
> >Stop = Length( Var ) ;
> >Call PrxNext( Pattern , Start , Stop , Var , Match , Length ) ;
> >Do I = 1 By 1 While( ( Match > 0 ) and ( I < Stop ) ) ;
> > Temp = Substr( Var , Match , Length ) ;
> > If Index( Temp , 's' ) Then Sec = Input( Compress( Temp , 's' ) ,
> >) ;
> > Else If Index( Temp , 'm' ) Then Min = Input( Compress( Temp , 'm' ) ,
> >) ;
> > Else If Index( Temp , 'h' ) Then Hour = Input( Compress( Temp , 'h' ) ,
> >) ;
> > Call PrxNext( Pattern , Start , Stop , Var , Match , Length ) ;
> >End ;
> >Run ;
> >Proc Print
> >data = Need ;
> >Run ;
> >Toby Dunn
>Both the INDEX and COMPRESS functions above could be replaced with regex.
>Geez man do I look like a Perl head....
I'll take the Fifth, your honor. :-)
> I just muddle my way through when it
>comes to Perl. I just wished it was easier to read.
Check out the /x modifier, so you can insert spacing for readability.
It's not as good as what the /x modifier does in Perl, but it's better
than a poke in the eye with a sharp stick.
David L. Cassell
3115 NW Norwood Pl.
Corvallis OR 97330
Valentine’s Day -- Shop for gifts that spell L-O-V-E at MSN Shopping