[CrackMonkey] Perl

Jay Sulzberger jays at panix.com
Sun Jan 14 16:48:37 PST 2001


On Sun, 14 Jan 2001, Ben Brockert wrote:

> Could one of you geniuses give me a hand?
>
> I have a scalar, lets call it $foo. Sample text in foo could be
>
> BAR H
> QUUX
> BAZ BIM
>
> I want to take that, do some magic regexp stuff on it, and end up with
>
> Bar H
> Quux
> Baz Bim
>
> (this is a scalar, not an array, those are different samples, not
> different elements).
>
> So far, the closest I have gotten is something like this:
>
>    $foo=~tr/A-Z/a-z/;
>    $class=ucfirst($class);
> or
>    $foo=~tr/A-Z/a-z/;
>    $class=~tr/^[a-z]/[A-Z]/;
> which yield the same output:
>
> Bar h
> Quux
> Baz bim
>
> Any bright ideas?
>
> My perl is ugly.
>
> And why did TPGTB[1] put ucfirst() in when tr/^[a-z]/[A-Z]/ does the same?
>
> Ben

At the GOOPS prompt do

> (define capitalize-file
    (lambda (in-file-name out-file-name)
      (loltf
        (map capitalize
            (ftlol in-file-name)) out-file-name)))

> (capitalize-file "BIZARRO" "Bizarro")

oo--JS.






More information about the Crackmonkey mailing list