in reply to Re^3: Can't get the desired output..
in thread Can't get the desired output..
Ok sorry for that.. Actually the input file was came from a .txt file. So the contents of the file is the list of names that was separated only by comma. So here's what looks like:
Magnunm,Cobray,Ingram,Samsy,Rayver
The code starts by opening the file and putting it in a array then I make it in to a string, then on line 5 putting it in a string again. then the if statement wherein it will suppose to be only get the name "Cobray" on that list:
The requirement is to output only the chosen name like on this code it suppose to be output the name Cobray.. As you've said that it will output the whole thing.. How can I pull this off? hehe..
Here's the codeopen my $infile, "<", "name_list.txt" or die "cannot open input: $!"; my @infile1= <$infile>; close $infile; foreach my $name (@infile1) { chomp $name; if ($name =~ /Cobray/){ print "$name";} }
If I made my input like this:
Magnunm Cobray Ingram Samsy Rayver
it can display the name only... Hope that this info help you what I'm trying to achieve.. Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Can't get the desired output..
by GrandFather (Saint) on May 02, 2012 at 09:44 UTC | |
|
Re^5: Can't get the desired output..
by JavaFan (Canon) on May 02, 2012 at 09:48 UTC | |
by astronogun (Sexton) on May 02, 2012 at 10:19 UTC |