Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Golf: Embedded In Order

by chipmunk (Parson)
on Apr 27, 2001 at 17:54 UTC ( #76091=note: print w/replies, xml ) Need Help??

in reply to Golf: Embedded In Order

I'll get things started here. I don't have time for the extra credit, but this solves the first part:
sub t_in_s { ($t=pop)=~s/./$&.*/g;$_[0]=~$t } t_in_s('abcdefghijklmnopqrstuvwxyz', 'for');
Although, if $t may contain non-word characters, that becomes:
sub t_in_s { ($t=pop)=~s/./\Q$&\E.*/g;$_[0]=~$t }

Replies are listed 'Best First'.
Re (tilly) 2: Golf: Embedded In Order
by tilly (Archbishop) on Apr 27, 2001 at 18:41 UTC
    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.
      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://76091]
[choroba]: Lanzarote is great!
choroba went there year ago
[Discipulus]: here spring has sprung, so the warm is available without holidays..
[Discipulus]: Oh I got a (small but better than nothing) salary increase!! beer for all!
[cavac]: Not sure if it's only my connection, but seems rather slow to respond today.
[cavac]: Could some of you just log in for a second and check, for example, the tail daemon logfile?

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2017-02-22 08:53 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (325 votes). Check out past polls.