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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
[SOLVED] Conditional Syntax Error

 



unibot
Novice

Mar 6, 2011, 12:19 PM

Post #1 of 3 (921 views)
[SOLVED] Conditional Syntax Error Can't Post

EDIT: Nevermind, I just reversed the conditional to avoid whatever bug was preventing it from running..


Code
push(@aodlist,$_) if (($motto =~ m/In god we trust/)&&($flag =~ m/($idonesia)/));


Original Post:

I've been debugging this for a while, and now I'm stuck and was wondering if some fresh eyes might help, I feel like I've run into this syntax problem before. Tongue

Um.. there is likely two errors in the syntax of the conditional statement or something of that sort.

Here is the error report..


Quote
syntax error at C:\Users\User\Desktop\Perl\flagaod.pl line 20, near ")
{"
syntax error at C:\Users\User\Desktop\Perl\flagaod.pl line 24, near ";}"
Execution of C:\Users\User\Desktop\Perl\flagaod.pl aborted due to compilation er
rors.


And the code..


Code
#!/usr/bin/perl-w 

use XML::Simple;

my @aodlist =qw//;
my $idonesia = "http://www.nationstates.net/images/flags/indonesia.jpg";
my @nationstosearch =qw/Aitarcomed Unibot_II SdnalsIanaujiram The_Purple_woogies Sahms_Club Glen-Rhodes Ulodana /;

foreach (@nationstosearch)

{

my $nationurl = "http://www.nationstates.net/cgi-bin/api.cgi/nation="."$_";

my $xml = XMLin( get($nationurl));
my $flag = $xml->{'FLAG'};
my $motto = $xml->{'MOTTO'};

If (($motto =~ m/In god we trust/)&&($flag =~ m/($idonesia)/))
{
(@aodlist,$_);
}

sleep(5);}

print "@aodlist\n";


Thanks in advance for reading and any advice you may have for me!


(This post was edited by unibot on Mar 6, 2011, 12:39 PM)


FishMonger
Veteran / Moderator

Mar 6, 2011, 1:45 PM

Post #2 of 3 (892 views)
Re: [unibot] [SOLVED] Conditional Syntax Error [In reply to] Can't Post

Your first error was caused by using an uppercase I in the if statement. Perl is case sensitive, If is not the same as if.

Your second error was caused by the missing function push.

Code
(@aodlist,$_);

should have been

Code
push(@aodlist,$_);



unibot
Novice

Mar 6, 2011, 1:57 PM

Post #3 of 3 (887 views)
Re: [FishMonger] [SOLVED] Conditional Syntax Error [In reply to] Can't Post


In Reply To
Your first error was caused by using an uppercase I in the if statement. Perl is case sensitive, If is not the same as if.

Your second error was caused by the missing function push.

Code
(@aodlist,$_);

should have been

Code
push(@aodlist,$_);



I figured out the push, I would have never figured out the capitalization of if. Laugh

Thanks!

 
 


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

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