CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Fun With Perl: Perl Golf: Re: [fashimpaur] String Replacement Golf: Edit Log



Paul
Enthusiast

Feb 15, 2002, 5:11 AM


Views: 43875
Re: [fashimpaur] String Replacement Golf

I think you have it wrong.....

$a = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; # EXPR
$b = 15; # OFFSET
$c = "Perl_Is_Fun"; # REPLACEMENT
$d = length $c; # LEN

sub mysubstr{$s=shift,$s=~s/^(.{$_[0]})(.{$_[1]})(.*)/\1$_[2]\3/,return$s};


If $s is shift then $_[0] is 15 .....thats fine!

However $_[1] is Perl_Is_Fun which cannot go inside curly braces.

Whichever way you do it either $_[0] or $_[1] will be letters which is invalid.


(This post was edited by RedRum on Feb 15, 2002, 5:13 AM)


Edit Log:
Post edited by Paul (Enthusiast) on Feb 15, 2002, 5:13 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives