![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perl search in a string for.... | Philux | Shell Programming and Scripting | 5 | 02-17-2009 06:44 PM |
| Search array elements as file for a matching string | mkbaral | Shell Programming and Scripting | 1 | 09-18-2008 05:20 AM |
| search for a string -perl | meghana | Shell Programming and Scripting | 11 | 02-12-2008 09:44 PM |
| Perl: Search for string on line then search and replace text | Crypto | Shell Programming and Scripting | 4 | 01-04-2008 10:24 AM |
| Search string in array (perl) | man | Shell Programming and Scripting | 6 | 07-24-2007 12:14 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
search of string from an array in Perl
Hi All I want to search a string from an array in Perl. If a match occurs, assign that string to a variable else assign 'No match'. I tried writing the script as follows but it's in vain. Please help me.. Code:
#!/usr/bin/perl
use strict;
my $NER;
my @text=("ORG","PER");
my @NES=("I-PER","I-TIM","LOC","MISC","ORG","PER");
for(my $k=1; $k<=29; $k++)
{
if ($text[0] eq $NES[k])
{
$NER = $text[0];
}
else
{
$NER="No Match";
}
}
print $NER;
Expected Output:- ORG Thanks in advance. Last edited by Yogesh Sawant; 07-19-2009 at 07:03 AM.. Reason: added code tags |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|