Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Golf: Embedded In Order

by boo_radley (Parson)
on Apr 27, 2001 at 21:05 UTC ( #76170=note: print w/replies, xml ) Need Help??

in reply to Golf: Embedded In Order

42 chars in the sub.
use strict; my $s = "abcdefghijklmnopqrstuvwxyz"; my $t = "for"; print x($s,$t),"\n"; $t="perl"; print x($s,$t),"\n"; sub x{ my($s,$t)=@_; eval"\$s=~tr/$t//cd"; $s eq$t; }
one less:
sub x{ eval"\$_[0]=~tr/$_[1]//cd";$_[0]eq$_[1]; }

Replies are listed 'Best First'.
Re: Re: Golf: Embedded In Order
by MeowChow (Vicar) on Apr 27, 2001 at 22:07 UTC
    Interesting method, but it doesn't properly handle:
    my $s = "abcfoforrxyz"; my $t = "for";
    There are also serious escaping issues with the interpolated code inside the eval :)
                   s aamecha.s a..a\u$&owag.print

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://76170]
[Discipulus]: why github use 'pull request' instead of 'push request'? where is the subject?
[Discipulus]: I'm the subject or is the program? i think i always am the subject
[erix]: it an invite to pull, as I understand it
[Discipulus]: Concave or convex?
[Discipulus]: who make the invitation? the program?!?
[choroba]: it's historical
[erix]: pull requests
[choroba]: originally, you sent a pull request to someone by email, i.e. you asked them to pull from your repo
[Discipulus]: if is the author of a patch, is more like a 'request to push' into rather than a pull request..
[choroba]: as it's considered unpolite to push to someone else's repo

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2017-05-27 20:08 GMT
Find Nodes?
    Voting Booth?