Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I need to get the name and the toyes , since they can be one word or more , I am putting it into array : I have done the following :-- Name: Menu -- TOYS: car monkey moon blblblb blblb
it get me all the other junk , here is the output:#set some local variables local ($name,$toys); open ( INPUT , "<input" ) or die " couldn't open\n"; while(<INPUT>) { @name=split(" ",$_) if /^-- NAME:\s(\w+)/; @toys=split(" ",$_) if /^-- TOYS:\s(\w+)/; } close(INPUT); foreach $name (@name) { print "the name $name\n"; } foreach $toys (@toys) { print "the toys $toys\n"; }
I don't need NAME: and TOYS: and --- to be in the array .. HELP ?the name -- the name NAME: the name Menu the neme the toys -- the toys TOYS: the toys CAR
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: array issue
by Zaxo (Archbishop) on Jan 23, 2004 at 19:37 UTC | |
|
Re: array issue
by Aragorn (Curate) on Jan 23, 2004 at 19:51 UTC | |
by jonadab (Parson) on Jan 24, 2004 at 01:56 UTC | |
|
Re: array issue
by Limbic~Region (Chancellor) on Jan 23, 2004 at 19:43 UTC | |
|
Re: array issue
by derby (Abbot) on Jan 23, 2004 at 19:40 UTC |