Home: Perl Programming Help: Intermediate:
Couple of questions



enhost
Deleted

Jan 21, 2000, 6:52 AM


Views: 5938
Couple of questions

Ok, I'm writing a custom ordering script, basicly a from -> email script that does a bunch of calculations and reads and writes from some databases.

Now I'm trying to prevent invalid characters and this is the function that is supposed to be doing it.
--------------------------------------
sub decode_input { # Decodes input, Stores Input, Checks for input Validation, Bails on first bad

# Decode the Input from the order Gateway #
# Store in A. Array "%OrderInput" #
&ReadParse(*OrderInput);

# Check for all required fields, bail on first bad #
foreach $to_check (keys(%OrderInput)) {
if ($OrderInput{$to_check}=(/([;<>\*\|'&\$!#\(\)\[\]\{\}:`"])/) &#0124; &#0124; $OrderInput{$to_check} eq "") {
$error_required = "$to_check is missing or contains invalid characters";
&required_bail;
exit;
}
}
}
----------------------------------------

However It don't work.. it runs &required_bail if $OrderInput{$to_check} eq "" but if you put invalid characters in it (like : (that is my database delemiter..verybad) then it just loads and run a total different sub-routine that isn't even defined in there.. it loads up a sub-routine for password missmatch.

Any ideas as to what is wrong in that sub? any help would be appreciated. Thank you.


japhy
Enthusiast

Jan 21, 2000, 7:38 AM


Views: 5938
Re: Couple of questions

The problem is you're using the = operator, for assignment, instead of the =~ operator, for pattern matching.

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


if ($string = /[aieou]/i) {
# $string is set to 1 or 0
# depending on whether or not $_
# has any vowels in it.
# and if $string is set to 1,
# then this if block gets executed
}

if ($string =~ /[aeiou]/i) {
# if $string has any vowels in it,
# then this if block gets executed
}
</pre><HR></BLOCKQUOTE>


enhost
Deleted

Jan 21, 2000, 7:56 AM


Views: 5938
Re: Couple of questions

Thank you

it works now...lol