×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Syntax Error

Syntax Error

Syntax Error

(OP)
I'm doing something simple but can't seem to get the syntax right. Maybe someone can help.

I'm trying to take this basic working array and add an if/else to it:


%use_this = (
'NO',0,
'YES',100
);


An early attempt:


if {$Status eq 'Domestic'
%use_this =
('NO',0,
'YES',100);
}
elsif {$Status eq 'Foreign'
%use_this =
  ('Required for international',100);
}


I tried about everything else I could think of and ended up with this, which also gives a syntax error. Basically, I'm not sure how to use if/else with an array!


%use_this =
if {
$Status eq 'Domestic'
('NO',0,
'YES',100);
}
else {
   $Status eq 'Foreign'
  ('Required for international',100);
 }


Thanks!

Don
don@ctagroup.org
http://www.helpscc.org/
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)

RE: Syntax Error

Hi Don,

try this:

if ($Status eq 'Domestic'){
  %use_this = (
    'NO',0,
    'YES',100
  );
} elsif ($Status eq 'Foreign'){
  %use_this = (
    'Required for international',100
  );
}


Mike
michael.j.lacey@ntlworld.com

RE: Syntax Error

(OP)
Hi Mike!

That must have set a record for speed of reply to a posting! Thanks!

With your suggestion, it no longer gives a syntax error but it seems to be completely ignored. I think I need to work of the "if" variables now so I'll have to go through everything again to find out what I should be using now that it is not giving an error. The fact that it is being ignored implies that neither of the conditions are true.

Thanks again!

Don
don@ctagroup.org
http://www.helpscc.org/
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)

RE: Syntax Error

"The fact that it is being ignored implies that neither of the conditions are true."

Yup

Try:

} elsif ($Status eq 'Foreign'){
  %use_this = (
    'Required for international',100
  );
} else {
  die "whoops, not Foreign or Domestic ($Status)....\n";
}


Mike
michael.j.lacey@ntlworld.com

RE: Syntax Error

(OP)
Hi Mike,

Yes, that sounds like it would work. I'll try it tonight as it is a personal project. Thanks!

Don
don@ctagroup.org
http://www.helpscc.org/
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)

RE: Syntax Error

(OP)
Hi Mike,

After looking at it more carefully, I don't think the last bit of code is what I need because there should never be a time when one or the other are not true. I think your earlier code is the answer once I find a variable to use. The problem is that this script seems to load before the necessary variable is sent. I'll probably have to find an entirely different way to do it. Thanks for your help though!

Don
don@ctagroup.org
http://www.helpscc.org/
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)

RE: Syntax Error

Hi Don,

If I were you I'd keep the "emergency exit" code in there so that you can tell if $Status ever *does* get set to something silly.........

Be paranoid. Be *very* paranoid. And remember: In kernel space no one can hear you hit the keyboard with your head when you get it wrong...


Mike
michael.j.lacey@ntlworld.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close