![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 -write values in a file to @array in perl | meghana | Shell Programming and Scripting | 27 | 06-07-2009 05:05 PM |
| UNIX newbie NEWBIE question! | Hanamachi | UNIX for Dummies Questions & Answers | 4 | 03-28-2009 04:10 PM |
| [PERL] Running unix commands within Perl Scripts | userix | Shell Programming and Scripting | 1 | 05-28-2008 06:06 PM |
| perl newbie: how to extract an unknown word from a string | wolwy_pete | Shell Programming and Scripting | 3 | 03-23-2008 10:41 AM |
| Perl newbie question | ssmiths001 | Shell Programming and Scripting | 2 | 05-08-2006 12:20 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Perl Newbie - help!
Hi All,
newbie-ish question here. I have this script: Code:
foreach $test (@num)
{
foreach $record (@neet)
{
if ($record =~ /$test/){
print "$record \n";
print $test;
}
}
}
Edit/Delete Message |
|
||||
|
Works for me. What's in the @num array? Perhaps something which doesn't match what you think it ought to match? Or perhaps the missing newline after $test was throwing you off.
Code:
vnix$ cat neet
#!/usr/bin/perl
my (@num) = qw(foo bar baz);
my (@neet) = qw (food bar moobaz);
foreach $test (@num)
{
foreach $record (@neet)
{
if ($record =~ /$test/)
{
print "$record\n";
print $test;
print "\n"; # I assume you want, too
}
}
}
vnix$ perl neet
food
foo
bar
bar
moobaz
baz
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|