Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re (tilly) 2: Golf: Embedded In Order

by tilly (Archbishop)
on Apr 27, 2001 at 18:41 UTC ( #76119=note: print w/replies, xml ) Need Help??

in reply to Re: Golf: Embedded In Order
in thread Golf: Embedded In Order

If $s or $t can contain \n, you need a /s on both matches. But your $_[0] can be replaced with pop.

That makes your solution turn into the 36 character:

sub t_in_s { ($t=pop)=~s/./\Q$&\E.*/gs;pop=~/$t/s }
or 38 if you wish to add my to make it strict compliant.

Replies are listed 'Best First'.
Re: Re (tilly) 2: Golf: Embedded In Order
by chipmunk (Parson) on Apr 30, 2001 at 09:01 UTC
    I realized later that I had the replacement in the wrong order, and I could save two characters:
    sub t_in_s { ($t=pop)=~s/./.*\Q$&/gs;pop=~/$t/s }
    So that's 34 characters.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://76119]
[LanX]: Once upon a time there was light in my life But now there's only Trump in the dark Nothing I can say A total eclipse of the heart

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2017-08-21 23:43 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (325 votes). Check out past polls.