|
||||||
| Perl Discussion for the PERL language - Practical Extraction and Reporting Language, is a programming language often used for creating CGI programs. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
I'm not good with perl but I've been told that I have to make this project in perl. Sorry for all of the questions.
Here is my question: Is there a way in PERL to determine if a string is in an array? Basically search an array for a string? Code:
@array1 = ("Bnn","Cnn","Dnn");
$string = "Cnn";
__________________
Code:
for (int i;;) {
cout << "Smith";
}
|
| Sponsored Links |
|
|
|
|||||
|
I don't know perl, but in most languages you can loop through the index range of the array and compare each string in the array.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Programming is a branch of mathematics. |
|
|||
|
one way:
Code:
@array1 = ("Bnn","Cnn","Dnn");
$string = "Cnn";
if (grep {$_ eq $string} @array1) {
print "Found $string\n";
}
else {
print "Nope, no $string\n";
}
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| fread into array position | kenna | C and C++ | 0 | 08-17-2007 09:03 AM |
| need help in counting a specify character in a string. | lichy | Perl | 2 | 06-27-2007 11:03 PM |
| [Help] String manipulation. | afiser | Visual Basic Programming | 1 | 05-31-2007 04:24 PM |
| Python 2D array question | annannienann | Python | 3 | 04-23-2007 05:36 PM |
| Accessing a string by array | Saint | C# Programming | 3 | 10-03-2006 08:33 PM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |
Goal: 100,000 Posts
Complete: 98%