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
In reply to Re^4: Can't get the desired output..
by astronogun
in thread Can't get the desired output..
by astronogun
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |