Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax Error

Status
Not open for further replies.

DonP

IS-IT--Management
Jul 20, 2000
684
US
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:

[tt]
%use_this = (
'NO',0,
'YES',100
);
[/tt]

An early attempt:

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

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!

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

Thanks!

Don
don@ctagroup.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!)
 
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
 
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
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)
 
"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
 
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
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)
 
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
Experienced in HTML, Perl, VBScript, PWS, IIS and Apache. Run OS/2 Warp 4, BeOS v5 and Windows NT (only when I have to!)
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top