peppiv has asked for the wisdom of the Perl Monks concerning the following question:
Happy Holidays!
Just seeing who else spent all their time off during the year and are stuck working the holidays. For those of you left, let's see if we can give this descent young fella a hand.
My program fills an array with a text file that looks like this:
1001,choochoo
1002,candycane
1003,sockpuppet
etc.
The actual amount of elements in this array may vary, so I can't say $array[2] to be sure of getting a sockpuppet. I need to search the array. Fortunately, I know that the data I'm looking for begins with 1006. What I'd like to do is put the value I'm looking for into a string for further use. (info that needs to be sent back through a URL - junk like that).
So, exposing my weak knowledge of grep and search, I tried the following:
Please help!
peppiv
Just seeing who else spent all their time off during the year and are stuck working the holidays. For those of you left, let's see if we can give this descent young fella a hand.
My program fills an array with a text file that looks like this:
1001,choochoo
1002,candycane
1003,sockpuppet
etc.
The actual amount of elements in this array may vary, so I can't say $array[2] to be sure of getting a sockpuppet. I need to search the array. Fortunately, I know that the data I'm looking for begins with 1006. What I'd like to do is put the value I'm looking for into a string for further use. (info that needs to be sent back through a URL - junk like that).
So, exposing my weak knowledge of grep and search, I tried the following:
I know, I know. Pathetic ain't it?my $answer= grep /^1006,/, @array; my $thing = substr($answer, 6,6);
Please help!
peppiv
|
---|
Back to
Seekers of Perl Wisdom