CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Regular Expressions:
what's wrong?



Dec 12, 2004, 5:01 PM

Post #1 of 2 (6971 views)
     what's wrong?  

Can someone tell me what's wrong with this? I've tried using next and last, elseif, 1 line if's after the push stuff, etc... The @InvalidItms gets all the values 3 times and the @ValidItms gets only the value of the identical pair. Thank you.

@Array1 = ("item_one", "item_two", "item_three");
@Array2 = ("this_one", "item_two", "this_three");

foreach $itm (@Array1) {
foreach $sub_itm (@Array2) {
if ($itm eq $sub_itm) {
push (@ValidItms, $itm);
} else {
push (@InvalidItms, $itm);

print "Valid Items: @ValidItms";
print "<br>";
print "Invalid Items: @InvalidItms";


Thaumaturge / Moderator

Dec 13, 2004, 1:32 AM

Post #2 of 2 (6962 views)
     Re: [why_perl] what's wrong? [In reply to]  

Firstly, please don't post the same question in multiple areas of the forum. You'll waste people's time and you'll get fragmented answers to your questions.

Secondly, why post this question in the regex area? I can't see any use of regular expressions here.

I've locked this thread so no-one else can answer here.

Dave Cross, Perl Hacker, Trainer and Writer
Get more help at Perl Monks


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives