[19711] in Perl-Users-Digest
Perl-Users Digest, Issue: 1906 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 10 18:07:09 2001
Date: Wed, 10 Oct 2001 15:05:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1002751512-v10-i1906@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 10 Oct 2001 Volume: 10 Number: 1906
Today's topics:
Re: Checking Network Access <bart.lateur@skynet.be>
excel <jessica.bull@broadwing.com>
Re: executing batch file from script <tsee@gmx.net>
Re: executing batch file from script <Jon.Ericson@jpl.nasa.gov>
for loop <gclark@wavetel.com>
Re: for loop <tony_curtis32@yahoo.com>
Re: for loop <Laocoon@eudoramail.com>
Re: for loop <mjcarman@home.com>
Re: Hashes as class members nobull@mail.com
Re: how to execute a unix program with a cgi script <bart.lateur@skynet.be>
how to get an email message for bounced mail? <llshyu@yahoo.com>
Re: how to get an email message for bounced mail? <lmoran@wtsg.com>
Re: how to get an email message for bounced mail? <llshyu@yahoo.com>
How to print out uninitialized variables (a field in db (Alex)
Re: How to print out uninitialized variables (a field i <djberge@qwest.com>
Re: How to print out uninitialized variables (a field i <jeff@vpservices.com>
Re: How to print out uninitialized variables (a field i (John J. Trammell)
Linux vs DOS(Win98) behaviour <talexb@tabsoft.on.ca>
Re: Linux vs DOS(Win98) behaviour (Malcolm Dew-Jones)
Network Access as Windows 2000 Service? <IHATESPAM@IHATESPAM.COM>
Optimizing lookup in hash of regexps <mattc@visi.com>
pattern matching (shaz)
Re: pattern matching <ilya@martynov.org>
Re: pattern matching <Laocoon@eudoramail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 10 Oct 2001 21:23:04 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Checking Network Access
Message-Id: <01f9stgnrio5jahcgsvuafee8634c708lq@4ax.com>
MrsKensingtonUK wrote:
>Any other ideas why i would be getting Access is Denied??
In case you still haven't seen my other follow-up: it's the "\e".
--
Bart.
------------------------------
Date: Wed, 10 Oct 2001 21:29:59 GMT
From: "Jessica Bull" <jessica.bull@broadwing.com>
Subject: excel
Message-Id: <r53x7.686111$NK1.62673232@bin3.nnrp.aus1.giganews.com>
Sorry for all of the newbie questions...thanks for helping.
I am parsing through lines of data and pulling specific pieces to populate a
spreadsheet. I am on Win NT
What is the best way to populate an excel spreadsheet? it is really basic
and should look something like this:
DATE FILENAME PROCESS# COMPLETION CODE
I want it to append to the same file every time. So I have 4 columns and an
indefinate amount of rows. Any ideas?
I was looking through Win32::OLE and saw that I could accomplish my goal,
but I was looking for a more effient way. Any info would be greatly
appreciated.
------------------------------
Date: Wed, 10 Oct 2001 22:34:26 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: executing batch file from script
Message-Id: <9q2cve$2ul$04$1@news.t-online.com>
"Jessica Bull" <jessica.bull@broadwing.com> schrieb im Newsbeitrag
news:nz_w7.883395$ai2.67962521@bin2.nnrp.aus1.giganews.com...
> I am on windows NT. I am trying to call a batch file to run from the
> script. I am not able to get the script to call it correctly. I am
getting
> the error: Directory or Filename does not exist or is not an operable
batch
> program. Can someone help me out? This is what I have.
>
> my $batchdir = "c:\\cdsdk";
> my $rsobatch = "$batchdir\\rsogtecc.bat";
my $batchdir = 'c:/cdsdk';
my $rsobatch = $batchdir . '/rsogtecc.bat';
> elsif ($file =~ m/.*?\.RSO/i) {
> $errormessage = Cpy_snd_chk($rso, $rsobatch);
> push (@errors, $errormessage);
> next;
> }#end elsif
>
> The code above calls a subroutine (edited below)...this is where I am
trying
> to call the batch file. The correct value is being passed in, but the OS
> doesn't seem to like the command. Can someone help me out? Thanks so
> much!!!
Was the value really correct? Always use / for directories within Perl, even
under Windows. (Dunno about MacOS, though.)
> sub Cpy_snd_chk {
> my ($path, $batch) = @_;
> `$batch` or die "Batch file open failed: $batch : $! \n";
> }
Steffen
------------------------------
Date: 10 Oct 2001 13:29:33 +0000
From: Jon Ericson <Jon.Ericson@jpl.nasa.gov>
Subject: Re: executing batch file from script
Message-Id: <86y9mjoc76.fsf@jon_ericson.jpl.nasa.gov>
"Steffen Müller" <tsee@gmx.net> writes:
> "Jessica Bull" <jessica.bull@broadwing.com> schrieb im Newsbeitrag
> news:nz_w7.883395$ai2.67962521@bin2.nnrp.aus1.giganews.com...
> > my $batchdir = "c:\\cdsdk";
> > my $rsobatch = "$batchdir\\rsogtecc.bat";
>
> my $batchdir = 'c:/cdsdk';
> my $rsobatch = $batchdir . '/rsogtecc.bat';
> Was the value really correct? Always use / for directories within Perl, even
> under Windows. (Dunno about MacOS, though.)
Actually either works in Windows. The reason to use a slash rather
than a backslash is to avoid confusion and ugliness. I can't think of
a reason to use dot concatenation rather than string interpolation,
however.
(From email with the OP, the problem appears to be a batch file issue,
rather than a perl issue.)
Jon
--
"Consider carefully what you hear," he continued. "With the measure
you use, it will be measured to you--and even more. Whoever has
will be given more; whoever does not have, even what he has will be
taken from him." -- Mark 4:24-25 (NIV)
------------------------------
Date: Wed, 10 Oct 2001 18:19:43 GMT
From: "Geoff Clark" <gclark@wavetel.com>
Subject: for loop
Message-Id: <3j0x7.441960$Lw3.27573125@news2.aus1.giganews.com>
I am fairly new to perl and need help with a loop. What I am trying to do
is as follows:
use strict;
use vars qw(@hosts $p $host);
use Net::Ping;
@hosts = qw(10.1.66.0);
$p = Net::Ping->new("icmp");
foreach $host (@hosts)
{
print "$host is ";
print "NOT " unless $p->ping($host, 2);
print "reachable.\n";
sleep(1);
}
$p->close();
exit 0;
The problem is with the array @hosts = qw(10.1.66.0); What I am trying to
have is 10.1.66.0 - 10.1.66.255. I am not sure on how to do this in a loop.
Any assitance would be helpful.
Geoff Clark
------------------------------
Date: Wed, 10 Oct 2001 13:27:27 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: for loop
Message-Id: <87r8sbnyeo.fsf@limey.hpcc.uh.edu>
>> On Wed, 10 Oct 2001 18:19:43 GMT,
>> "Geoff Clark" <gclark@wavetel.com> said:
> The problem is with the array @hosts = qw(10.1.66.0);
> What I am trying to have is 10.1.66.0 - 10.1.66.255. I
> am not sure on how to do this in a loop. Any assitance
> would be helpful.
I think Net::IP will help you do what you want (useful if
you need to know more interesting things about the
addresses).
http://search.cpan.org/doc/MANU/Net-IP-1.0/IP.pm
Or you could iterate over the last octet and construct the
address from the network prefix:
foreach my $i ( 0 .. 255 ) {
my $addr = "10.1.66.$i";
...
}
hth
t
--
Whoops, I've said too much. Smithers, use the amnesia ray...
------------------------------
Date: Wed, 10 Oct 2001 20:31:42 +0200
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: for loop
Message-Id: <Xns9136D0D6F567FLaocooneudoramailcom@62.153.159.134>
> The problem is with the array @hosts = qw(10.1.66.0); What I am trying
> to have is 10.1.66.0 - 10.1.66.255. I am not sure on how to do this in
> a loop. Any assitance would be helpful.
my @hosts, $i = 0;
$hosts[$i++] = "10.1.66.$i" until $i == 256;
------------------------------
Date: Wed, 10 Oct 2001 13:47:30 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: for loop
Message-Id: <3BC497C2.C7306499@home.com>
Geoff Clark wrote:
>
> @hosts = qw(10.1.66.0);
>
> $p = Net::Ping->new("icmp");
>
> foreach $host (@hosts)
> {
> [...]
>
> The problem is with the array @hosts = qw(10.1.66.0); What I am
> trying to have is 10.1.66.0 - 10.1.66.255. I am not sure on how
> to do this in a loop.
@hosts = map {"10.1.66.$_"} (0 .. 255);
-mjc
------------------------------
Date: 10 Oct 2001 18:59:13 +0100
From: nobull@mail.com
Subject: Re: Hashes as class members
Message-Id: <u9wv23js0e.fsf@wcl-l.bham.ac.uk>
"Eric Cifreo" <ecifreo@austin.rr.com> writes:
> I'm a Perl beginner, so I hope this isn't a FAQ. I've searched long and
> hard for some examples of this, but I'm having trouble returning a hash from
> a class.
You don't mean from a class, you mean from a method. And actually the
fact that it's a method rather than a simple subroutine is not
relevant. This is probably why you are looking in the wrong place.
Subroutines in Perl return return either a list or a scalar (or void) depending
on if the call to the subroutine appears in a list context or a scalar
context (or a void contest). A subroutine cannot directly return an array or
hash. If you want a subroutine to to return a data structure it must
return a reference to a structure.
> My problem is this: when I try to get the hash out of the Office object,
> it's mangled somehow. If in the external script, I say:
>
> my %userHash = $office->users();
Did you read the explaination of the warning that was generated by
that line? What you didn't get a warning? You climb without ropes
and then when you fall you cry out for help from the very same people
who are forever advising novice climbers to use ropes! Excuse us if
we treat you with some exasparation/sarcasm etc.
> my %userHash = $office->users();
> foreach ($key (keys %userHash)) { # where the keys are the User's names
> print("Key is $key.\n");
> }
That code does not compile. Please post real code.
my $userHash = $office->users();
foreach my $key (keys %$userHash) {
print("Key is $key.\n");
}
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 10 Oct 2001 21:24:16 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: how to execute a unix program with a cgi script
Message-Id: <43f9stcq2436ib4976boiffjstrof19llh@4ax.com>
JHWB wrote:
> I'm just
>trying to make something usefull; an index of dvds that I have currently
>borrowed to friends.
You're moving files to represent data in a database? Boggle...
--
Bart.
------------------------------
Date: Wed, 10 Oct 2001 14:27:15 -0500
From: L shyu <llshyu@yahoo.com>
Subject: how to get an email message for bounced mail?
Message-Id: <3BC4A113.ED108ED4@yahoo.com>
Hi,
I am new to perl's mail::sendmail. The sendmail portion works fine.
What we would like to do is if one of the email address is not correct,
we would like to receive email back to let us know that mail delivery
failure. This works in some situation. However, if there are multiple
email addresses in CC and at least one of them is valid address, then
the sender will not recieve mail delivery failed message if some email
address in the CC are invalid.
Is there any way to get 'mail delivery failure' message if there is
an invalid email address is in to: CC: or BCC:?
Thanks.
Lin
------------------------------
Date: Wed, 10 Oct 2001 16:18:07 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: how to get an email message for bounced mail?
Message-Id: <mua9st4rq039igebd9rbcq2fkc637ku4p3@4ax.com>
On Wed, 10 Oct 2001 14:27:15 -0500, L shyu <llshyu@yahoo.com> wrote
wonderful things about sparkplugs:
I used this Mail:Sendmail for the first time today.
The first thing that happened was I got a bounced mail. I put in an
invalid address in To:.
Simply adjust Sendmail.pm (mine was in c:\perl\site\lib\mail) to
reflect the address you'd like to get reply's to and it will happen.
You should also input your server info there too, but I assume you've
done that already.
perldoc Mail::Sendmail was a big help.
>Hi,
>
> I am new to perl's mail::sendmail. The sendmail portion works fine.
>What we would like to do is if one of the email address is not correct,
>we would like to receive email back to let us know that mail delivery
>failure. This works in some situation. However, if there are multiple
>email addresses in CC and at least one of them is valid address, then
>the sender will not recieve mail delivery failed message if some email
>address in the CC are invalid.
>
> Is there any way to get 'mail delivery failure' message if there is
>an invalid email address is in to: CC: or BCC:?
>
>Thanks.
>
>Lin
--
TMTOWTDI: My way tends to be wrong...
lmoran@wtsg.com
------------------------------
Date: Wed, 10 Oct 2001 16:24:53 -0500
From: L shyu <llshyu@yahoo.com>
Subject: Re: how to get an email message for bounced mail?
Message-Id: <3BC4BCA5.E652AF25@yahoo.com>
Thanks.
Lou Moran wrote:
> On Wed, 10 Oct 2001 14:27:15 -0500, L shyu <llshyu@yahoo.com> wrote
> wonderful things about sparkplugs:
>
> I used this Mail:Sendmail for the first time today.
>
> The first thing that happened was I got a bounced mail. I put in an
> invalid address in To:.
>
> Simply adjust Sendmail.pm (mine was in c:\perl\site\lib\mail) to
> reflect the address you'd like to get reply's to and it will happen.
>
> You should also input your server info there too, but I assume you've
> done that already.
>
> perldoc Mail::Sendmail was a big help.
>
> >Hi,
> >
> > I am new to perl's mail::sendmail. The sendmail portion works fine.
> >What we would like to do is if one of the email address is not correct,
> >we would like to receive email back to let us know that mail delivery
> >failure. This works in some situation. However, if there are multiple
> >email addresses in CC and at least one of them is valid address, then
> >the sender will not recieve mail delivery failed message if some email
> >address in the CC are invalid.
> >
> > Is there any way to get 'mail delivery failure' message if there is
> >an invalid email address is in to: CC: or BCC:?
> >
> >Thanks.
> >
> >Lin
>
> --
> TMTOWTDI: My way tends to be wrong...
> lmoran@wtsg.com
------------------------------
Date: 10 Oct 2001 11:06:11 -0700
From: samara_biz@hotmail.com (Alex)
Subject: How to print out uninitialized variables (a field in db is empty)?
Message-Id: <c7d9d63c.0110101006.7e7d5fba@posting.google.com>
Hi,
I'm a little confused about how to make Perl stop complaining about
uninitialized variables when printing out fields from an Access
database.
For example, I have a table user with the following fields:
Username
Password
Firstname
Lastname
Phone
Fax
Email
Then, on in website I have a page where all this information is
displayed. I get record data using fetchrow_hashref() method from DBI
module. So when I try to print out $hashref->{Fax} and the field "Fax"
happens to be empty in the database I get this warning written in my
mycgi-log.txt file: "Use of uninitialized value in concatenation (.)
or string at..."
How do I avoid these warnings? It seems like it's too much of a pain
in the tail to do something like if( exists($hashref->{field}) ){
blah; blah; } each time I want to print out the content of a field.
Could someone possibly clarify this so I can get out of the state of
feeling lost and confused. :)
Thanks!
Alex
------------------------------
Date: Wed, 10 Oct 2001 13:21:33 -0500
From: "Mr. Sunblade" <djberge@qwest.com>
Subject: Re: How to print out uninitialized variables (a field in db is empty)?
Message-Id: <Eg0x7.205$MN5.155419@news.uswest.net>
"Alex" <samara_biz@hotmail.com> wrote in message
news:c7d9d63c.0110101006.7e7d5fba@posting.google.com...
<snip>
> How do I avoid these warnings? It seems like it's too much of a pain
> in the tail to do something like if( exists($hashref->{field}) ){
> blah; blah; } each time I want to print out the content of a field.
>
> Could someone possibly clarify this so I can get out of the state of
> feeling lost and confused. :)
If you're using Perl 5.6 or later, you can disable this warning like so:
no warnings 'uninitialized';
See the 'use warnings' pragma for more info on enabling/disabling warnings.
Regards,
Mr. Sunblade
------------------------------
Date: Wed, 10 Oct 2001 11:33:37 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: How to print out uninitialized variables (a field in db is empty)?
Message-Id: <3BC49481.1261EFA1@vpservices.com>
Alex wrote:
>
> I'm a little confused about how to make Perl stop complaining about
> uninitialized variables when printing out fields from an Access
> database. ...
>
> How do I avoid these warnings? It seems like it's too much of a pain
> in the tail to do something like if( exists($hashref->{field}) ){
> blah; blah; } each time I want to print out the content of a field.
Well, that is not a pain, it is a mistake :-). Exists tells whether
there has ever been a key of that name, not whether the current contents
of the hash with that key is initialized so it wouldn't do what you
think it would. What you want is "defined", not "exists".
Still seems like a pain? Perhaps, but it makes more sense than telling
perl to print something that isn't defined. You could also turn off
warnings locally but warnings are your friend. A real relational
databases has the possibility of containing things whose value is uknown
so Perl is actually helping you by preserving that aspect of the
database (The difference between an unknown value and one whose value is
0 or an empty string). Yes it seems cumbersome, but that's the price
you pay for accuracy.
--
Jeff
------------------------------
Date: Wed, 10 Oct 2001 14:00:41 -0500
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: How to print out uninitialized variables (a field in db is empty)?
Message-Id: <slrn9s96mp.4a7.trammell@haqq.hypersloth.net>
On 10 Oct 2001 11:06:11 -0700, Alex <samara_biz@hotmail.com> wrote:
> Hi,
>
> I'm a little confused about how to make Perl stop complaining about
> uninitialized variables when printing out fields from an Access
> database.
> For example, I have a table user with the following fields:
> Username
> Password
> Firstname
> Lastname
> Phone
> Fax
> Email
>
> Then, on in website I have a page where all this information is
> displayed. I get record data using fetchrow_hashref() method from DBI
> module. So when I try to print out $hashref->{Fax} and the field "Fax"
> happens to be empty in the database I get this warning written in my
> mycgi-log.txt file: "Use of uninitialized value in concatenation (.)
> or string at..."
>
> How do I avoid these warnings? It seems like it's too much of a pain
> in the tail to do something like if( exists($hashref->{field}) ){
> blah; blah; } each time I want to print out the content of a field.
One possible method:
for (qw[ Username Password ]) # et cetera...
{
$hashref->{$_} = "" unless defined $hashref->{$_};
}
Although I'm sure there's a more compact way to do it...
--
Only a very small fraction of our DNA does anything; the rest is all
comments and ifdefs.
------------------------------
Date: Wed, 10 Oct 2001 14:36:26 -0400
From: T. Alex Beamish <talexb@tabsoft.on.ca>
Subject: Linux vs DOS(Win98) behaviour
Message-Id: <o159stsvo5f2qm1p778dn7qtj3vqtnv4r6@4ax.com>
I discovered that the following script worked fine under Linux but
locked up my machine under DOS:
#!/usr/bin/perl -w
# Test program -- This is bugging me, it used to work but now does
# not.
open ( CMD, "dir |" ) or die "Error opening pipe: $!";
while ( <CMD> )
{
s/</</g;
s/>/>/g;
print;
}
close ( CMD ) or die "Error closing pipe: $!";
Thoughts?
Alex
T. Alex Beamish -- TAB Software
http://www.tabsoft.on.ca
talexb at tabsoft dot on dot ca
------------------------------
Date: 10 Oct 2001 12:33:04 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Linux vs DOS(Win98) behaviour
Message-Id: <3bc4a270@news.victoria.tc.ca>
T. Alex Beamish (talexb@tabsoft.on.ca) wrote:
: I discovered that the following script worked fine under Linux but
: locked up my machine under DOS:
: #!/usr/bin/perl -w
: # Test program -- This is bugging me, it used to work but now does
: # not.
: open ( CMD, "dir |" ) or die "Error opening pipe: $!";
: while ( <CMD> )
: {
: s/</</g;
: s/>/>/g;
: print;
: }
: close ( CMD ) or die "Error closing pipe: $!";
: Thoughts?
I guess you must have a "dir" command on linux.
It works fine under NT (just so you know).
I would hazard a guess that the "dir |" doesn't work properly under
windows 98, though I can't play with it to find out.
You might try something like
system("dir > %temp%\$$.tmp") ; # may want to check for errors
open CMD , "$ENV{'TEMP'}/$$.tmp" or die;
------------------------------
Date: Wed, 10 Oct 2001 20:41:25 GMT
From: "Lawrence Smith" <IHATESPAM@IHATESPAM.COM>
Subject: Network Access as Windows 2000 Service?
Message-Id: <Vn2x7.381$Fe5.6308@ord-read.news.verio.net>
Anybody got this working?
I'm using srvany.exe from the Windows Resource Kit and ActiveStates latest.
I can get the script running as a service, but the net function won't
work...
Here's an example...
Use Net::Ping;
eval { $p = Net::Ping->new("icmp"); };
open(FILE, ">C:/test.txt");
if ($@) { print FILE $@\n } else { print FILE "It worked!\n"; }
close(FILE);
The script runs when I start the service, and the file test.txt contains...
Can't get icmp protocol by name at c:\\test.pl line 4
If I run the script from the command line, however, the file contains...
It worked!
I understand that there is a limitation on services such that they can't be
interactive and access the net at the same time. I'm not running it as an
interactive app, I've tried running it under the local administrator's
account and as the Local System account. I get the error either way.
Can anyone point me in the right direction?
Thanks,
Lawrence Smith
IHATESPAM@fvldlaw.com
(replace IHATESPAM with lsmith)
------------------------------
Date: 10 Oct 2001 15:22:46 -0500
From: Matt Christian <mattc@visi.com>
Subject: Optimizing lookup in hash of regexps
Message-Id: <87d73v9re1.fsf@powerhouse.boogie.cx>
Hi,
I have a Perl program that looks up data by matching against a hash of
regexps (regular expressions) as follows:
============================ CUT & PASTE ============================
#!/usr/local/bin/perl -w
use strict;
# Example lookup table (truncated)
# regexp (should be unique) => value (not unique)
my %lookupTable = (
'1122' => 'a value',
'2308' => 'beta',
'[0-9]?99990' => 'read this',
'.*ERV' => 'a value',
'[a-z][0-9]+' => 'read this',
'ABCZ.+' => 'alphabet',
'.*random' => 'beta'
);
# Example data set (truncated)
my @data = ('1122', 1120, 'something', '199990', 'hi there', 'seeERV',
999, 'other random', 8285, 'a1');
my $datum;
foreach $datum (@data) {
print "datum = '$datum'\t";
my $result = lookup($datum, \%lookupTable);
if (defined($result)) {
print "result = '$result'";
} else {
print "NO MATCH!";
}
print "\n";
}
sub lookup {
my $datum = shift;
my $lookupTable = shift;
my ($key, $result);
# Loop through the keys (regexps) of the lookup table
foreach $key (keys %{ $lookupTable }) {
# Try to match the current regexp against the datum
if ($datum =~ /$key/) {
# If so, save the result and exit the loop
$result = ${$lookupTable}{$key};
last;
}
}
# Returns undef if there's no match for the datum
return $result;
}
============================ CUT & PASTE ============================
I get the following results:
datum = '1122' result = 'a value'
datum = '1120' NO MATCH!
datum = 'something' NO MATCH!
datum = '199990' result = 'read this'
datum = 'hi there' NO MATCH!
datum = 'seeERV' result = 'a value'
datum = '999' NO MATCH!
datum = 'other random' result = 'beta'
datum = '8285' NO MATCH!
datum = 'a1' result = 'read this'
Which are the expected results. However, this is just a subset of the
'real' data which includes thousands of datums to lookup and thousands
of lookup table entries. So as these arrays and hashes get bigger, this
program gets slower.
I have to believe that there are more efficient ways of doing
this... I've tried using the Memoize module to memoize the lookup() sub
but it actually made the program run slower. Which is to be expected
since I don't have a lot of duplicate data to lookup. I've also tried
looking in the Perl FAQs, various online Perl resurces (Perlfaq Prime,
Perl.com, MJD Perl Paraphernia, Randel L Schwartz' Perl articles, etc)
but haven't found anything like I'm doing. Maybe I just missed it...
Any ideas or tips to help speed this program up?
Pointers to other discussions and resources are most welcome, I am
willing to do the "homework" if you point me in the right direction.
Thanks,
Matt
--
Matt Christian - mattc@visi.com
http://www.visi.com/~mattc/
ftp://ftp.visi.com/users/mattc/
Learn to love and love to learn.
------------------------------
Date: 10 Oct 2001 11:15:06 -0700
From: ssa1701@yahoo.co.uk (shaz)
Subject: pattern matching
Message-Id: <23e71812.0110101015.419ecc9f@posting.google.com>
I am having some trouble adding and removing data from hashes.
I am using many if statements and can only add certain data at certain
points. This however, is making it difficult to remove all the data.
foreach .....
{
if ($val)
{
$value = 2;
%ans = ($name,$value);
}
else
{
$value = 1;
%ans = ($name,$value);
}
}
This is a simplified version of my problem. I want to add the data to
the hash %ans. (If $val is true add data to above, if $val is false
add data to below).
What I get is only one variable from the hash. I know that the data is
being added (by puting a print %ans command in the if statement and
the else statement). But if if place it after the foreach loop, I only
get one variable out out the hash.
In any case, I want to be able to print the data (from both) with a
decreasing $value.
Any ideas where I am going wrong???
------------------------------
Date: 10 Oct 2001 22:31:12 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: pattern matching
Message-Id: <87bsjfbb4f.fsf@abra.ru>
>>>>> On 10 Oct 2001 11:15:06 -0700, ssa1701@yahoo.co.uk (shaz) said:
s> I am having some trouble adding and removing data from hashes.
s> I am using many if statements and can only add certain data at certain
s> points. This however, is making it difficult to remove all the data.
s> foreach .....
s> {
s> if ($val)
s> {
s> $value = 2;
s> %ans = ($name,$value);
$ans{$name} = $value;
s> }
s> else
s> {
s> $value = 1;
s> %ans = ($name,$value);
$ans{$name} = $value;
s> }
s> }
s> [..skip..]
%ans = ($name,$value) creates hash with only one element and assigns
it to %ans
$ans{$name}= $value add new element to %ans hash
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Wed, 10 Oct 2001 20:26:54 +0200
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: pattern matching
Message-Id: <Xns9136D0066CC10Laocooneudoramailcom@62.153.159.134>
please use subject lines that describe your problem..
there is no pattern match anywhere in ur post
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 1906
***************************************