[ABE.pm] A little programming help

Faber J. Fedor faber at linuxnj.com
Wed Sep 5 08:01:39 PDT 2007


Here are two attemtps to do the same thing, but I'm stuck on both.

Objective: parse the string

    q( my @prereqs = ("forddaily", "processdailydata"); )

into an array

    @myarray = ( q(forddaily), q(processdailydata))

Difficulty: there are n items in the list, IOW the resulting array will
sometimes have one element, sometimes three elements, etc.


Method 1: I thought I could do it with a regex and back references,
but the variable number of entries won't allow that (I think).
I'm thinking map could help here, but I'm not sure.

Method 2: split the original string on '(', toss the first element, split
the result on ',' and you end up with

    @myarray = ( q("forddaily"), q("processdailydata");) );

I now want to edit this array "in place" to remove the non-alphabetic
characters but the only method I can think of is 

    my @newarray ;
    foreach(@myarray) {
        my $string =~ /"([a-z]+)"/;
        push(@newarray, $string)
    }

which seems clunky.

Anyone got anything sexier?

-- 
 
Regards,
 
Faber Fedor
President
Linux New Jersey, Inc.
908-320-0357
800-706-0701

http://www.linuxnj.com




-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



More information about the ABE-pm mailing list