Front page | perl.beginners |
Postings from March 2002
RE: If statement
Thread Previous
|
Thread Next
From:
Zeus Odin
Date:
March 31, 2002 08:25
Subject:
RE: If statement
Message ID:
NCBBJGKHAPMBPELHFAHMMELODMAA.zeus.odin@verizon.net
Please note the error (WRONG) below. Apologies.
------------------
#!D:\perl\bin\perl -w
use strict;
my %data;
# fill in 11 other states
my @state = qw(MA CI DE IN OH);
# Make each element of @state a key of hash %data
# Set each value equal to 1 (true)
# Refer to Perl Cookbook
# Recipe 4.7: Finding Elements in One Array but Not Another
# WRONG !!!!!!!!!!!
# $data{ @state } = (1) x @state;
@data{ @state } = (1) x @state;
# Start loop here that reads each Access record
# Check if the present state is one of the 16
# $statefield is the state field of the ODBC
# record object: $rs->Fields('state')->value
# Refer to ActivePerl Help: Using OLE with Perl
If ( $data{$statefield} ) {
# OR If ( $data{uc($rs->Fields('state')->value)} ) {
# Process data
}
# End loop here that reads each Access record
-----Original Message-----
From: Ned Cunningham [mailto:Ned.Cunningham@MONRO.COM]
Sent: Friday, March 29, 2002 11:46 AM
To: beginners@perl.org
Subject: If statement
HI,
I am having a very newbie problem.
I am reading an Access database with ODBC and have my data read into
$Data{STATE}
My problem is now I need to match to 16 different states.
I have so far
If ( $Data{STATE} eq "MA" )
Process data
My question is should I use an array to test against and how to code it?
??-
@state="MA CI DE IN OH";
Thank you for anyhelp
Thread Previous
|
Thread Next