[19663] in Perl-Users-Digest
Perl-Users Digest, Issue: 1858 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 2 18:07:17 2001
Date: Tue, 2 Oct 2001 15:06:51 -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: <1002060410-v10-i1858@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 2 Oct 2001 Volume: 10 Number: 1858
Today's topics:
$count = (@emails); <todd@mrnoitall.com>
Re: $count = (@emails); (Steve Lamb)
Re: 2 newlines after Headerlines in HTTP? <comdog@panix.com>
Re: bad math or code <bart.lateur@skynet.be>
Re: Can't create NDBM database (Garry Williams)
Re: Can't unlink file under Perl for NT <lglessner@hotmail.com>
Re: Conditional regex substitution - thank you! <marc.beyer@berlin.de>
Re: Conditional regex substitution (Malcolm Dew-Jones)
CPAN module and local directory (Miko O'Sullivan)
DBI and getting data - long one (vivekvp)
Re: Efficient code? <tsee@gmx.net>
Re: Efficient code? <darkon@one.net>
Re: Efficient code? <bart.lateur@skynet.be>
Re: Efficient code? <joe+usenet@sunstarsys.com>
How to add date stamp to a log file (Venkatesh Babu Sira)
Re: How to add date stamp to a log file <mbudash@sonic.net>
how to give commands to a perl script from another? <naren@india.ti.com>
Re: how to give commands to a perl script from another? (Malcolm Dew-Jones)
Re: HTTP::Daemon::ClientConn <buggs-clpm@splashground.de>
Re: IE vs. Netscape problems in perl (Abigail)
looking for "cgrep like" script that can grep w/"/foo/ (Tom Rodman)
Re: Lotus Notes <vcuya@mindspring.com>
many file search and replace (Windows) <magrav@wnt.sas.com>
Re: many file search and replace (Windows) (Malcolm Dew-Jones)
Pixel Color at particular coordinate <jay@utils.net.nospam>
Re: Pixel Color at particular coordinate <bart.lateur@skynet.be>
Regexp question slidge@slidge.com
Re: use Module vs. use module <mjcarman@home.com>
Using sendmail with PGP <simonp@NOSPAM.dircon.co.uk>
Re: Using sendmail with PGP <mbudash@sonic.net>
Which Class::* lets me do this? <prlawrence@lehigh.edu>
Re: Which Class::* lets me do this? <bart.lateur@skynet.be>
Re: Yet another fork question <djberge@qwest.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 02 Oct 2001 15:35:58 +0000
From: Todd Anderson <todd@mrnoitall.com>
Subject: $count = (@emails);
Message-Id: <3BB9DC2D.C3B3840B@mrnoitall.com>
I need the code below to count the number of addresses associated with
$username. This code works in other areas of the script. Why doesn't it
work here? All your help is appreciated.
open (FILE, "$ejdy") || &file_open_error
("$ejdy", "Group Email", __FILE__, __LINE__);
while (<FILE>)
{
$line = $_;
chop $line;
@fields = split (/\|/, $line);
if($fields[1] eq "$username") {
@emails = ("$fields[0]");
$count = (@emails);##<<<< code in question here<<<<<<<
@emails = sort {lc($a) cmp lc($b)} @emails;
foreach $email (@emails){
$email_group .= qq~<option value="$email">$email~;
}
}
}#while
close (FILE);
------------------------------
Date: Tue, 02 Oct 2001 21:23:26 -0000
From: grey@despair.dmiyu.org (Steve Lamb)
Subject: Re: $count = (@emails);
Message-Id: <slrn9rkc2e.3cm.grey@teleute.dmiyu.org>
On Tue, 02 Oct 2001 15:35:58 +0000, Todd Anderson <todd@mrnoitall.com> wrote:
> while (<FILE>)
> {
> $line = $_;
> chop $line;
> @fields = split (/\|/, $line);
>if($fields[1] eq "$username") {
>@emails = ("$fields[0]");
>$count = (@emails);##<<<< code in question here<<<<<<<
>@emails = sort {lc($a) cmp lc($b)} @emails;
> foreach $email (@emails){
>$email_group .= qq~<option value="$email">$email~;
>}
>}
>}#while
>close (FILE);
Improper indention, clearly.
--
Steve C. Lamb | I'm your priest, I'm your shrink, I'm your
ICQ: 5107343 | main connection to the switchboard of souls.
To email: Don't despair! | -- Lenny Nero, Strange Days
-------------------------------+---------------------------------------------
------------------------------
Date: Tue, 02 Oct 2001 15:50:35 -0400
From: brian d foy <comdog@panix.com>
Subject: Re: 2 newlines after Headerlines in HTTP?
Message-Id: <comdog-56893C.15503502102001@news.panix.com>
In article <3BB9D0DD.200BCD70@erl.sbs.de>, Rainer Klier
<Rainer.Klier@erl.sbs.de> wrote:
> RFC 2616 says,
> there should be one newline. Did I miss something?
evidently you've misread the RFC ;)
--
brian d foy <comdog@panix.com> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html
------------------------------
Date: Tue, 02 Oct 2001 21:07:55 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: bad math or code
Message-Id: <tmakrt42c244912bcpgfv0tvg7f3ufhveo@4ax.com>
Jamie R. Bohr wrote:
>It is really wierd that 3.50 - 3.48 does not equal 0.02 in perl, for example
>please look at the code below:
>
>$A="3.50";
>$B="3.48";
>$C="2";
It's not weird. It's the normal result of how floating point numbers are
stored internally: the exponent parts are powers oftwo, not of 10. Thus,
there is no exact representation in the computer of 0.01, or 1*10**-2.
Why do you even expect that? You don't expect to be able to write down
an exact representation of 1/3, are you? Why not? After all, it's only
1*3**-1, thus through an internal representation in base 3, this would
be dead easy to represent exactly.
BTW this is a FAQ:
Found in D:\programs\indigoperl\lib\pod\perlfaq4.pod
Why am I getting long decimals (eg, 19.9499999999999) instead of the
numbers I should be getting (eg, 19.95)?
And it's the same in ANY computer language that makes use of floating
point. It comes with the territory, er, floating point, that is. I saw a
warning against the use of floating point for finnancial calculations,
in a book on Java, this afternoon.
If you want an exact representation of cents, then do you calculations
in whole cents.
--
Bart.
------------------------------
Date: Tue, 02 Oct 2001 18:06:40 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Can't create NDBM database
Message-Id: <slrn9rk0hg.cis.garry@zfw.zvolve.net>
On Tue, 02 Oct 2001 11:41:54 GMT, Mike <gbeanery@hotmail.com> wrote:
> I am a beginner, and am trying to learn how to create a database
> using NDBM. Here is the code
>
> #!/usr/bin/perl
> use Fcntl;
> use NDBM_File;
>
> tie %dbhash, "NDBM_File", "dbdata", O_RDWR|O_CREAT, 0644;
>
> $key='key1';
> $value='value1';
> $dbhash{$key}=$value;
> untie %dbhash;
>
> ---------
> This code creates a dbdata.db file, but apparently the book says I
> have to create a dbdata.pag and dbdata.dir files. Please help
Works for me. What OS are you using?
$ ls -l
total 0
$ perl -we '
#!/usr/bin/perl -w
use strict;
use Fcntl;
use NDBM_File;
tie my %dbhash, "NDBM_File", "dbdata", O_RDWR|O_CREAT, 0644;
$dbhash{key1}="value1";
untie %dbhash;
'
$ ls -l
total 2
-rw-r--r-- 1 garry dev 0 Oct 2 14:04 dbdata.dir
-rw-r--r-- 1 garry dev 1024 Oct 2 14:04 dbdata.pag
$
--
Garry Williams
------------------------------
Date: Tue, 2 Oct 2001 12:09:09 -0700
From: "Lynn" <lglessner@hotmail.com>
Subject: Re: Can't unlink file under Perl for NT
Message-Id: <9pd3ac$htt1b$1@ID-105031.news.dfncis.de>
Is your perl script running under a different id (e.g. cgi under the iis
service)?
Try giving the group "everyone" full control permissions to the directory
which will contain the temp file.
"Glenn" <glenn@surveystar.com> wrote in message
news:3BB91332.152A5049@surveystar.com...
> I can't seem to be able to delete a file via a Perl script under Win
> NT. Have tried many things -- most recently this simple test...
>
> open (OUTFILE,"> e:/somedir/testfile.zzz"); #open it
> printf OUTFILE "some test data\n"; # write something
> close (OUTFILE); # be sure
> to close it
> unlink("e:/somedir/testfile.zzz") || print "could not delete $!";
> # then delete it
>
> The file gets created (it is there), but not deleted. I get a
> "Permission denied" error. Don't ask why I am creating a file just to
> delete it -- my real use involves use of temporary files which I want to
> clean up when done. Any thoughts appreciated. Thanks!
>
>
------------------------------
Date: Tue, 02 Oct 2001 22:31:13 +0100
From: Marc Beyer <marc.beyer@berlin.de>
Subject: Re: Conditional regex substitution - thank you!
Message-Id: <9pdblk$iftji$1@ID-80494.news.dfncis.de>
Just wanted to say thank you to all of you who took the time to answer
my question. Not only have you helped me but I've found several ways to do
what I wanted. And "There's more than one way to do it" is what it's all
about, right ? :-)
Thanks,
Marc
------------------------------
Date: 2 Oct 2001 11:47:27 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Conditional regex substitution
Message-Id: <3bba0bbf@news.victoria.tc.ca>
Marc Beyer (marc.beyer@berlin.de) wrote:
: Hi,
: I'm trying to remove some specific characters from a string like
: s/=>|,|=|;| |"|'//g
: but to exempt any characters enclosed by quotation marks. So that (for
: example):
Some techniques have been shown by others,
Another technique is to split the string around (possibly unescaped)
quotation marks, and then run s/// on every _other_ substring.
To handle the case of escaped quotes, you'll have to extend the RE used in
the split. I think simple one character negative look-behind should work,
but you'll have to check that yourself.
The following is untested code, but similar to working quote that I can't
be bothered to find for cut and paste.
my @parts = split('"' , $the_original_string );
for ($i=1;$i<@parts;$i+=2)
{ # the odd numbered parts were not originally quoted
$parts[$i] =~ s/something/its replacement/;
}
$the_original_string_munged = join '"' , @parts;
------------------------------
Date: 2 Oct 2001 13:34:59 -0700
From: miko@idocs.com (Miko O'Sullivan)
Subject: CPAN module and local directory
Message-Id: <db27ea77.0110021234.33df45cf@posting.google.com>
I know how to install something to a local directory.
I know how to use the CPAN module (at least minimally).
I DON'T know how to use the CPAN module to install a module to a local
directory.
Could somebody point me in the right direction on using the CPAN
module to install a module in my own custom directory instead of to
the machine's global Perl library (which I don't and shouldn't have
rights to).
-Miko
------------------------------
Date: 2 Oct 2001 14:40:57 -0700
From: vivekvp@spliced.com (vivekvp)
Subject: DBI and getting data - long one
Message-Id: <9bf633be.0110021340.21370747@posting.google.com>
Hello,
It seems data I am pulling from a database is not being printed to a
file - the only time it does is when wf_id seems to be empty.
For brevity sake - I have removed the variable declares. The program
runs - it is not printing the data.
Basically this script goes through 3 main loops - They are nested -
the first one points to a second - which points to the third - which
is suppose to pick out the data.
I would think since it is going through 3 loops it would print the
inner most loop (loop 3) the product of the 2nd loop and the first
loop - but this is not happening .
I know this is complicated - and not explained very well.
I have listed my comments in CAPS - for the main loops.
Thanks,
V
#!/usr/bin/perl -w
open (FILE,">Uroute.txt");
use DBI; # Load the DBI module
use CGI; # HTML
use strict; # keep it usable
### Varibles
<all defined>
### Attributes to pass to DBI->connect() to disable automatic
### error checking
my %attr = (
PrintError => 0,
RaiseError => 0,
);
### Perform the connection using the Informix driver
my $dbh = DBI->connect( "dbi:XXXX:XXX\@XXX", "XXX", "XXX"
, \%attr )
or die "Can't connect to database: ", $DBI::errstr, "\n";
### Prepare a SQL statement for execution
my $sth = $dbh->prepare( "SELECT req_id,rts_nbr FROM rtshead where
status='5' and region_code='U' and time_stamp>'2001-01-01 00:00:00'")
or die "Can't prepare SQL statement: ", $dbh->errstr(), "\n";
### Execute the statement in the database
$sth->execute
or die "Can't execute SQL statement: ", $sth->errstr(), "\n";
### give columns values and names
$sth->bind_columns(undef,\$req_id, \$reqnum)
or die "Problem: ", $sth->errstr(), "\n";
# put data in array
$cnt=0;
print "Getting req \n";
$reqdata = $sth->fetchall_arrayref();
foreach $reqdata (@$reqdata) {
($r_id,$reqnum)=@$reqdata;
push @r_id, $r_id;
$cnt++;
# push into array.
push @reqnum, $reqnum;
eErr_trap ("Damn.") if $DBI::err;
}
$sth->finish;
# get wf_id
print "Getting wf_id \n";
foreach $r_id (@r_id) {
$sth = $dbh->prepare("SELECT wf_id FROM aprvl_wf WHERE
req_id=$r_id")or die "Can't prepare SQL statement: ", $dbh->errstr(),
"\n";
$sth->execute();
$wfid = $sth->fetchrow_array();
push @wfid,$wfid;
#print "wf_id: $wfid \n";
### get total req value
# will loop through each req_id - get lot_id - sum up req detail
value
# store in variable and array per req id
###
foreach($r_id) {
$rtotal=0;
$sth = $dbh->prepare("SELECT orig_qty,unit_cost FROM rtsdet WHERE
req_id=$r_id") or die "No req totals for you \n";
#$sth->bind_columns(undef,\$oqty, \$ucost) or die "Problem: ",
$sth->errstr(), "\n";
$sth->execute();
$qtycost = $sth->fetchall_arrayref();
foreach $qtycost (@$qtycost) {
$tqtycost=0;
($oqty,$ucost)=@$qtycost;
$tqtycost=$oqty*$ucost;
$rtotal=$tqtycost+$rtotal;
}
push @rtotal,$rtotal;
}
}
$sth->finish;
# get state_id
print "Getting state_id \n";
$cnt=0;
foreach $wfid (@wfid) { <--WF_ID LOOP MAIN LOOP 1
$sth = $dbh->prepare("SELECT state_id FROM aprvl_states WHERE
wf_id=$wfid") or die "Cannot prepare statement. Crap:",
$dbh->errstr(), "\n";
$sth->execute();
$state_id = $sth->fetchrow_array();
while ($state_id = $sth->fetchrow_arrayref) { MAIN LOOP 2
print "Getting signoffs \n";
print "state_id: @$state_id \n";
$sth = $dbh->prepare("SELECT
sign_off_id,sign_off_global_id,sign_off_status,sign_off_stat_date,sign_off_type
FROM aprvl_sign_offs where state_id=@$state_id");
$sth->bind_columns(undef, \$soid,\$sogid, \$sos, \$sosd, \$sot);
$sth->execute();
$signarray = $sth->fetchrow_array();
I WANT IT TO PRINT FOR EVERY RECORD OF $SIGNARRAY - IT ONLY SEEMS TO
PRINT WHEN WF_ID IS UNINITIALED.
while ($signarray=$sth->fetchrow_arrayref) { MAIN LOOP 3
($soid,$sogid,$sos,$sosd,$sot) = @$signarray;
print "$soid,$sogid,$sos,$sosd,$sot \n"; <-I ONLY SEE THIS WHEN WF_ID
IS NULL
$sth=$dbh->prepare("SELECT first_name,last_name from aaa_emp where
global_id=$sogid");
$sth->bind_columns(undef,\$first,\$last) or die "naming
problem.","\n";
$sth->execute();
$firstlast=$sth->fetchall_arrayref();
$first=~s/ //g;
$last=~s/ //g;
$rq++;
print "Sign off:$soid GID:$sogid $first $last total:$rtotal[$rq]|
count: $cnt \n";
print FILE "$soid|$sogid|$first|$last|$wf_id|$rtotal[$rq]| $cnt \n";
} LOOP 3
} ### while state_id loop LOOP 2
} ### loop for every wf_id LOOP 1
close (FILE);
$sth->finish;
------------------------------
Date: Tue, 2 Oct 2001 21:22:46 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: Efficient code?
Message-Id: <9pd45r$275$02$1@news.t-online.com>
"S Warhurst" <s.warhurst@rl.ac.uk> schrieb im Newsbeitrag
news:9pcsu3$k10@newton.cc.rl.ac.uk...
> 2) If one has an array of email addresses like:
>
> @emails = ('john@here.com', 'tim@there.com', 'bill@anisp.com',
> 'tim@there.com', 'john@here.com')
>
> and wanted to make them unique I would use the line:
>
> @emails = do {my %h; grep {!$h {$_} ++} @emails}
>
undef %saw;
@out = grep(!$saw{$_}++, @in);
is from perlfaq 4 and about 15 percent faster, I'd say. (and the benchmark
would after 100k iterations over a 200 entry array, too.)
> Is there an easy way to modify this line so that it gives a count of email
> addresses aswell, resulting in an array like this:
>
> @emails = (['bill@anisp.com', '1'],
> ['john@here.com', '2'],
> ['tim@there.com', '2']);
The code already does that. The has %saw contains the unique email addresses
as keys and the number of occurrances as values.
[snip]
I'd gladly try to help you with the rest, too, but I gtg now.
Hope I could help.
Steffen
------------------------------
Date: Tue, 02 Oct 2001 19:57:56 -0000
From: David Wall <darkon@one.net>
Subject: Re: Efficient code?
Message-Id: <Xns912EA25175D93darkononenet@207.126.101.97>
"S Warhurst" <s.warhurst@rl.ac.uk> wrote on 02 Oct 2001:
> 1) If one wants to go through each line of a 100,000 line text file,
> looking for one of 50 different strings, is the quickest way to do it
> (in terms of processor time) to use 50 IF... ELSIF... commands? (some
> of these do require regexp matching.. eg: "I like cornflakes for
> breakfast" where cornflakes could be any breakfast cereal).
I'd put the strings in a list and then loop over the list.
# initialize @list, with all the strings you're checking for
my @list = ('string1', 'string2', '"[^"]+"', '(this|that) stuff');
while (<DATA>) {
foreach my $str (@list) {
print "'$str' found at $.\n" if /$str/;
}
}
You'll have to alter this, I'm sure, since I don't know all the details of
what you're doing.
> 2) If one has an array of email addresses like:
>
> @emails = ('john@here.com', 'tim@there.com', 'bill@anisp.com',
> 'tim@there.com', 'john@here.com')
>
> and wanted to make them unique I would use the line:
>
> @emails = do {my %h; grep {!$h {$_} ++} @emails}
>
> Is there an easy way to modify this line so that it gives a count of
> email addresses aswell, resulting in an array like this:
>
> @emails = (['bill@anisp.com', '1'],
> ['john@here.com', '2'],
> ['tim@there.com', '2']);
Steffen Müller already answered this. I just want to add: Whenever you
want something unique, think hash. It will make your life much easier
than trying to do it with with arrays.
> 3) If I have an array like the following (there would actually be
> several hundred of rows):
>
> @array = (['bath.ac.uk', '46'],
> ['blackpool.ac.uk', '22'],
> ['hull.ac.uk', '13'],
> ['sussex.ac.uk', '36'],
> ['hull.ac.uk', '31'],
> ['blackpool.ac.uk', '2']);
>
> and I want to find the unique domains in column 1 and total the values
> in column 2 so it looks like this:
>
> @array = (['bath.ac.uk', '46'],
> ['blackpool.ac.uk', '24'],
> ['hull.ac.uk', '44'],
> ['sussex.ac.uk', '36']);
>
This is similar to your question 2, but you're summing instead of
counting.
my @array = (['bath.ac.uk', '46'],
['blackpool.ac.uk', '22'],
['hull.ac.uk', '13'],
['sussex.ac.uk', '36'],
['hull.ac.uk', '31'],
['blackpool.ac.uk', '2']);
my %domains;
foreach my $ref (@array) {
$domains{$ref->[0]} += $ref->[1];
}
# now %domains has all the info you need
# if you want it back in @array:
undef @array; # get rid of the old data in @array
foreach my $key (sort keys %domains) {
push @array, [ $key, $domains{$key} ];
}
I suspect you'll eventually want to do a more complicated sort on these...
:-)
Do you have a copy of the _Perl_Cookbook_? It has all sorts of examples
of how to do things with Perl. Using the FAQ and the cookbook, you can
learn how to do do all sorts of useful and interesting things.
--
David Wall
darkon@one.net
------------------------------
Date: Tue, 02 Oct 2001 20:47:38 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Efficient code?
Message-Id: <tb9krtc20kr9uqii0jaes1uc60kabnvbuo@4ax.com>
S Warhurst wrote:
>1) If one wants to go through each line of a 100,000 line text file, looking
>for one of 50 different strings, is the quickest way to do it (in terms of
>processor time) to use 50 IF... ELSIF... commands? (some of these do require
>regexp matching.. eg: "I like cornflakes for breakfast" where cornflakes
>could be any breakfast cereal).
Eh... Are you trying to find if there is at least one that matches? I
think I'd try to combine all the tests in one regex, using "|":
/I like (?:cornflakes|honeypops|muesli) for breakfast/
That's three of them.
If it's something else you want... I don't know. Be more specific.
>2) If one has an array of email addresses like:
>
>@emails = ('john@here.com', 'tim@there.com', 'bill@anisp.com',
>'tim@there.com', 'john@here.com')
>
>and wanted to make them unique I would use the line:
>
>@emails = do {my %h; grep {!$h {$_} ++} @emails}
>
>Is there an easy way to modify this line so that it gives a count of email
>addresses aswell, resulting in an array like this:
>
>@emails = (['bill@anisp.com', '1'],
> ['john@here.com', '2'],
> ['tim@there.com', '2']);
Do you care what order they come in? Of not, just return the (key,
value) pair of the hash you just populated:
my %h; $h {$_} ++ foreach @emails;
@emails = map { [ $_ => $h{$_} ] } sort keys %h;
If you want to retain the order as above, i.e. first occurrence:
my %h;
my @unique = grep { !$h {$_}++ } @emails;
@emails = map { [ $_ => $h{$_} ] } @unique;
>3) If I have an array like the following (there would actually be several
>hundred of rows):
>
>@array = (['bath.ac.uk', '46'],
> ['blackpool.ac.uk', '22'],
> ['hull.ac.uk', '13'],
> ['sussex.ac.uk', '36'],
> ['hull.ac.uk', '31'],
> ['blackpool.ac.uk', '2']);
>
>and I want to find the unique domains in column 1 and total the values in
>column 2 so it looks like this:
>
>@array = (['bath.ac.uk', '46'],
> ['blackpool.ac.uk', '24'],
> ['hull.ac.uk', '44'],
> ['sussex.ac.uk', '36']);
Just sum them in a hash.
my %total;
$total{$_->[0]} += $_->[1] foreach @array;
@table = map { [ $_ => $table{$_} ] } sort keys %total;
The similarity of the code with that in one of the answers above is no
coincidence.
--
Bart.
------------------------------
Date: 02 Oct 2001 16:52:35 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Efficient code?
Message-Id: <m33d51n4rw.fsf@mumonkan.sunstarsys.com>
"S Warhurst" <s.warhurst@rl.ac.uk> writes:
> 1) If one wants to go through each line of a 100,000 line text file,
> looking for one of 50 different strings, is the quickest way to do it
> (in terms of processor time) to use 50 IF... ELSIF... commands? (some
> of these do require regexp matching.. eg: "I like cornflakes for
> breakfast" where cornflakes could be any breakfast cereal).
If you have enough RAM (which you probably do), you might try slurping
the whole file in and study()ing the scalar before doing any pattern
matches:
# untested code
read TEXTFILE, $_, -s TEXTFILE;
study; # be careful, this might actually slow things down
my @line_break = -1;
push @line_break, pos while /\n/g;
# just in case the last char in $_ isn't a newline:
push @line_break, length $_ unless $linebreak[-1] == length $_;
my @re = map qr/$_/, qw/list of 50 regexps/;
foreach my $r (@re) {
my $n = 1; # line number of matching text
while (/$r/g) {
# first get $line: assumes $r won't match across lines-
# i.e. be careful with "\s"
# XXX: might be faster to invert @line_break
++$n until $line_break[$n] >= pos;
my $line = substr $_, $line_break[$n-1] + 1,
$line_break[$n] - $line_break[$n-1];
# avoids mutiple matches on the same line by advancing pos
pos = $line_break[$n];
# now do something
}
}
The line marked XXX might be accelerated by first inverting @line_break
outside the loops:
my %line_num = map {$line_break[$_] => $_} 0..$#line_break;
# just in case last char isn't "\n":
$line_num{ -1 } = $line_num{ $line_break[-1] };
and replacing the line below the XXX with
$n = $line_num{ index($_, "\n", pos) };
but I haven't tested this either, so YMMV.
> 2) If one has an array of email addresses like:
>
> @emails = ('john@here.com', 'tim@there.com', 'bill@anisp.com',
> 'tim@there.com', 'john@here.com')
>
> and wanted to make them unique I would use the line:
>
> @emails = do {my %h; grep {!$h {$_} ++} @emails}
>
> Is there an easy way to modify this line so that it gives a count of email
> addresses aswell, resulting in an array like this:
>
> @emails = (['bill@anisp.com', '1'],
> ['john@here.com', '2'],
> ['tim@there.com', '2']);
>
Since you already have %h, I don't know why you'd want to do this.
Here's one way:
my %h;
$h{$_}++ for @emails;
@emails = map [$_ => $h{$_}], keys %h; # redundant given %h
> ----------------------------
>
> 3) If I have an array like the following (there would actually be several
> hundred of rows):
>
> @array = (['bath.ac.uk', '46'],
> ['blackpool.ac.uk', '22'],
> ['hull.ac.uk', '13'],
> ['sussex.ac.uk', '36'],
> ['hull.ac.uk', '31'],
> ['blackpool.ac.uk', '2']);
>
> and I want to find the unique domains in column 1 and total the values in
> column 2 so it looks like this:
>
> @array = (['bath.ac.uk', '46'],
> ['blackpool.ac.uk', '24'],
> ['hull.ac.uk', '44'],
> ['sussex.ac.uk', '36']);
Again- use a hash:
my %h;
$h{ $_->[0] } += $_->[1] for @array;
@array = map [ $_ => $h{$_} ], sort keys %h; # redundant given %h
--
Joe Schaefer "There is something fascinating about science. One gets such
wholesale returns of conjecture out of such a trifling
investment of fact."
--Mark Twain
------------------------------
Date: 2 Oct 2001 12:36:36 -0700
From: vsira@hotmail.com (Venkatesh Babu Sira)
Subject: How to add date stamp to a log file
Message-Id: <d5b8dfd2.0110021136.3c5c31e7@posting.google.com>
I have code like,
$LOGFILENAME = "logfile.txt";
I want to add time stamp like
$LOGFILENAME = "logfile.txt.$time";
ex: that it may look like logfile.txt.2oct2001 .
Tx
-B
------------------------------
Date: Tue, 02 Oct 2001 20:10:50 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: How to add date stamp to a log file
Message-Id: <mbudash-CAB4B9.13105302102001@news.sonic.net>
In article <d5b8dfd2.0110021136.3c5c31e7@posting.google.com>,
vsira@hotmail.com (Venkatesh Babu Sira) wrote:
> I have code like,
> $LOGFILENAME = "logfile.txt";
> I want to add time stamp like
> $LOGFILENAME = "logfile.txt.$time";
> ex: that it may look like logfile.txt.2oct2001 .
> Tx
> -B
this does it with a format you probly _oughta_ use, if you ever wanna
sort (or view a dir listing of) these files:
NOTE: beware of word wrap below!
use POSIX;
$LOGFILENAME = 'logfile.txt.' . POSIX::strftime("%Y%m%d", 0, 0, 0,
(localtime)[3..5]);
the above (currently) yields;
logfile.txt.20011002
this version does it exactly as you requested:
use POSIX;
my @t = localtime;
$LOGFILENAME = 'logfile.txt.' . $t[3], lc(POSIX::strftime("%b%Y\n", 0,
0, 0, @t[3..5]));
the above (currently) yields;
logfile.txt.2oct2001
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Wed, 03 Oct 2001 00:38:51 +0530
From: Narendran Kumaraguru Nathan <naren@india.ti.com>
Subject: how to give commands to a perl script from another?
Message-Id: <3BBA10C3.67495D8B@india.ti.com>
Hi,
There is one perl script available that works fine. Now I wish to give inputs
from another script to the first script. Is there any way?
I tried invoking the first script as
open( FIRST_SCR, " | my_first_script.pl " ) || die "Cannot open ";
print FIRST_SCR "first_command";
I couldn't see any output messages for the first_command. I tried changing the
'|' to '>' with no use. Also I tried with printf.
Can anyone guide me how to do this?
Regards,
Naren.
------------------------------
Date: 2 Oct 2001 13:52:45 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: how to give commands to a perl script from another?
Message-Id: <3bba291d@news.victoria.tc.ca>
Narendran Kumaraguru Nathan (naren@india.ti.com) wrote:
: Hi,
: There is one perl script available that works fine. Now I wish to give inputs
: from another script to the first script. Is there any way?
: I tried invoking the first script as
: open( FIRST_SCR, " | my_first_script.pl " ) || die "Cannot open ";
: print FIRST_SCR "first_command";
...very confused...
(Look in perlfunc.pod for the correct way to test errors at the places
marked below...)
try something like
#!perl
# script number 2 a
system("the_other_script.pl the arguments go here");
-- system may return error codes, so check for the errors here
(you may need to use `system("perl script.pl args")' )
to mimic the command line without using a shell, try the following (though
note that the scripts will potentially stomp on each other's variables and
etc. )
#!perl
# script number 2 b
@ARGV=qw(the arguments you want);
do "the_other_script.pl";
-- "do" may return error codes, so do some error checking here
(require will also work if you are running the other script
*just once*)
------------------------------
Date: Tue, 02 Oct 2001 22:21:17 +0200
From: Buggs <buggs-clpm@splashground.de>
Subject: Re: HTTP::Daemon::ClientConn
Message-Id: <9pd7pp$51o$06$1@news.t-online.com>
Rainer Klier wrote:
> Hi,
>
> implemented a simple HTTP Daemon via HTTP::Daemon
> and wanted to document it. The man page says,
> that accept returns an object of type
> HTTP::Daemon::ClientConn, but I cannot find this
> Module and no docu on it. Is the documentation
> of HTTP::Daemon wrong?
No but the package is in the HTTP/Daemon.pm file.
See its dox and src.
Buggs
------------------------------
Date: 2 Oct 2001 21:38:37 GMT
From: abigail@foad.org (Abigail)
Subject: Re: IE vs. Netscape problems in perl
Message-Id: <slrn9rkcs4.7cg.abigail@alexandra.xs4all.nl>
David Linker (dtlinker@u.washington.edu) wrote on MMCMLIII September
MCMXCIII in <URL:news:9panoe$1470$1@nntp6.u.washington.edu>:
@@ I need some help. I wrote a download logging perl script. It keeps track
@@ of how many times a file has been downloaded, and who did it, in two
@@ separate files. It works perfectly now when accessed from within
@@ Netscape, but when I use Internet explorer, it downloads a link with the
@@ name of the script, and logs two downloads!
That sounds like a browser problem to me, not a Perl problem.
Not that you don't have a gazillion problems with your program.
@@
@@ Any ideas appreciated!
@@
@@ Thanks,
@@
@@ David Linker
@@
@@ From Netscape, it downloads the file "Test.RTF", as intended.
@@
@@ From IE, it downloads a file called count.cgi (the name of the perl
@@ script), containing:
@@
@@ [InternetShortcut]
@@ URL=http://faculty.washington.edu/dtlinker/Test.RTF
@@
@@ The script is as follows:
@@
@@ #!/usr/local/bin/perl
You ought to be using -w and 'use strict'.
@@ #-----------------------
@@ # count.cgi
@@ # Ver. 1.0
@@ # 2001-09-30
@@ # ----------------------
@@ # David T. Linker
@@ # dtlinker@u.washington.edu
@@ #-----------------------
@@
@@ $cntfile = "./count.dat";
@@ $logfile = "./count.log";
@@ $downldfile = "http://faculty.washington.edu/dtlinker/Test.RTF";
@@
@@ print "Location: $downldfile\n\n";
@@
@@ open (DATA,"$cntfile");
What if the open fails? You should not assume it will succeed. And what's
with the quotes?
@@ $count = <DATA>;
@@ close (DATA);
@@ $newcount = $count + 1;
@@
@@ #open and clobber the file to overwrite
@@ open (DATA,"+>$cntfile");
Why open for write/read when you don't read? What if the open fails?
@@ print DATA "$newcount\n";
@@ close (DATA);
You aren't doing any file locking. So, three instances of your CGI
program might open the file, increment the counter and write the result,
resulting in just adding one to the number (they all write the same value
back to the file). Of course, that's if you are lucky. If you are unlucky,
the simultaneous reads and writes will in practise quickly lead to totally
garbled data. You might as well roll a die to find out how many "hits"
you got. It will give you a more accurate answer.
@@ #log the access
@@ open (DATA, ">>$logfile");
@@ print DATA "$ENV{'REMOTE_HOST'}\n";
@@ close (DATA);
The biggest flaw of course is the very idea you need such a program. Any
webserver I've encountered in the past 7+ years will log the information
you are attempting to log (and then some), with far less overhead for both
the server, client and network (no silly redirect necessary), giving you
more information for less of a buck. And, more importantly, give you more
accurate information.
Don't fight your webserver, work with it.
Abigail
--
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
print } sub __PACKAGE__ { &
print ( __PACKAGE__)} &
__PACKAGE__
( )
------------------------------
Date: Tue, 02 Oct 2001 19:10:42 GMT
From: trodman@nyx.nyx.net (Tom Rodman)
Subject: looking for "cgrep like" script that can grep w/"/foo/ && ! /thud/"
Message-Id: <1002049489.696824@irys.nyx.net>
Would like to print a configurable number of lines before
and after a regular expression pair like "/foo/ && ! /thud/"
matches.
perl -lne 'print if (/foo/ && ! /thud/ );'
# does what I want but also want several lines
# before and after the match printed
The "cgrep" perl sript that I found can not handle
"/foo/ && ! /thud/".
thanks/regards,
Tom
------------------------------
Date: Tue, 02 Oct 2001 14:16:37 -0400
From: Victor A. Cuya <vcuya@mindspring.com>
Subject: Re: Lotus Notes
Message-Id: <bs0krtcb3bnbsb13pkm8ah1or9bgpuomq1@4ax.com>
Hansgeorg,
Here is come code I started playing with sometime ago. I never got too
far with it because other things popped out. I get an error message in
one of the calls because I think someone changed the template on me a
couple of times.
Anyway, if you have a good OLE browser you could figure it out. Good
luck
---
#!perl -w
use strict;
use Win32::OLE;
my $Notes = Win32::OLE->new('Notes.NotesSession') or die "Cannot start
Lotus Notes Session object.\n";
my ($Version) = ($Notes->{NotesVersion} =~ /\s*(.*\S)\s*$/);
my $User = $Notes->{UserName};
my $Platform = $Notes->{Platform};
my $Database = $Notes->GetDatabase('', 'favorite.nsf') or die "Cannot
access database";
my $Title = $Database->{Title};
my $AllDocuments = $Database->{AllDocuments};
my $Count = $AllDocuments->{Count};
print "There are $Count documents in the database.\n";
for (my $Index = 1; $Index <= $Count; ++$Index) {
my $Document = $AllDocuments->GetNthDocument->{$Index};
printf "$Index. %s\n", $Document->GetFirstItem('Subject')->{Text};
my $Values = $Document->GetItemValue('Index_Entries');
foreach my $Value (@$Values) {
print " Index: $Value\n";
}
last unless $Index < 5;
}
---
On Fri, 14 Sep 2001 14:58:19 +0200, "Hansgeorg Zauner"
<hg_zauner@gmx.de> wrote:
>Is there a way to access a Lotus Notes Database from perl?
>I could not find any module for this purpose.
>
>Thanx
>
------------------------------
Date: Tue, 02 Oct 2001 15:07:10 -0400
From: Max Gravitt <magrav@wnt.sas.com>
Subject: many file search and replace (Windows)
Message-Id: <6v3krt4c4sad1lfkkr192uja7h83dh6bca@4ax.com>
I'm trying to find a perl command that will do a multiple file search
and replace on Windows. This one works on Unix:
perl -pi.bak -e 's/oldstring/newstring/g' FILES
But it does not work on Windows NT with perl 5. I'm not sure why.
Does anyone know of a solution to this problem?
thanks in advance
Max
------------------------------
Date: 2 Oct 2001 13:43:42 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: many file search and replace (Windows)
Message-Id: <3bba26fe@news.victoria.tc.ca>
Max Gravitt (magrav@wnt.sas.com) wrote:
: I'm trying to find a perl command that will do a multiple file search
: and replace on Windows. This one works on Unix:
: perl -pi.bak -e 's/oldstring/newstring/g' FILES
: But it does not work on Windows NT with perl 5. I'm not sure why.
: Does anyone know of a solution to this problem?
Perhaps the quotes are wrong?
perl -pi.bak -e "s/oldstring/newstring/g" m.1 m.2 m.3
the just above worked for me
------------------------------
Date: Tue, 02 Oct 2001 13:24:31 -0700
From: Jay <jay@utils.net.nospam>
Subject: Pixel Color at particular coordinate
Message-Id: <3BBA227E.582E7E07@utils.net.nospam>
Dear All,
I was wondering if there is some bare bone program, which could
ease the job of reading color value for a particular coordinate.
For example, an image ( gif/jpeg/ps ) looks like the following:
GGGGGGG
BBRRRGG
BBRRRGG
BBBBBBB
What I know is: it's a 7x4 image ( this is using the images
size program I wrote, for now it understand gif and jpeg )
I would like to know what's the color of pixel 'p'
which is in row 'x' and column 'y'
Any help will be appreciated.
Thanks.
~Jay
------------------------------
Date: Tue, 02 Oct 2001 21:49:13 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Pixel Color at particular coordinate
Message-Id: <0rckrts4rlogshq0sjpqo3n9prr2qdaf41@4ax.com>
Jay wrote:
>I was wondering if there is some bare bone program, which could
>ease the job of reading color value for a particular coordinate.
>
>For example, an image ( gif/jpeg/ps ) looks like the following:
>
>GGGGGGG
>BBRRRGG
>BBRRRGG
>BBBBBBB
>
>What I know is: it's a 7x4 image ( this is using the images
>size program I wrote, for now it understand gif and jpeg )
>
>I would like to know what's the color of pixel 'p'
>which is in row 'x' and column 'y'
>
>Any help will be appreciated.
You need at least read the file format, which need not be trivial. Look
into the GD module, which is an interface to GD which is written in C.
<http://stein.cshl.org/WWW/software/GD/>. Search for the "getpixel"
method.
Old versions of GD used to support GIF, but it has been replaced with
PNG out of protest against Unisys licensing demands (are you prepared to
pay a few thousand dollars just to be allowed to use GIF?) If you
insist, use an old version of GD.
I doubt if there's an easy interface for Postscript files. Well... the
other module for image manipulation in perl, Image::Magick, again just
an interface to a (free) powerful graphics package, ImageMagick, see
<http://www.imagemagick.org>, seems to be able to convert between
various file formats, including GIF and EPS. The Unisys licensing
troubles make support for GIF a bit iffy.
For such a small image, why do you even need GIF? 28 pixels, h*ll, even
BMP will do.
HTH,
Bart.
------------------------------
Date: Tue, 02 Oct 2001 21:07:48 GMT
From: slidge@slidge.com
Subject: Regexp question
Message-Id: <E0qu7.19429$ck.127345@sjc-read.news.verio.net>
I am writing a Perl script to parse DNS zone files, and I'm coming up
against my limitations concerning my knowledge of regexp. Bear with me,
I'm not a Perl wiz.
What I am trying to do is "Append the contents of the variable $origin
to the variable $line if $line does not end with the character "." and
if line does not end with an IP address (like 10.0.0.1), and if the
value of the variable $type is not "HINFO", "TXT", or "UNKNOWN".
The snippet I have is:
$line = $line.".".$origin
if (( $line =~ /^.*[^\.]$/
&& $line =~ /[^\d+\.\d+\.\d+\.\d+]$/ )
&& ( $type ne "HINFO"
&& $type ne "TXT"
&& $type ne "UNKNOWN"));
This will append the value of $origin to lines such as:
@ IN NS foo
foo IN MX 10 foo
And will not append the value of $origin to lines like:
@ IN A 10.0.0.1
@ IN TXT "This is a test"
ns1 IN A 10.0.0.2
My problem is that it will not attach the value of $origin to:
www IN CNAME ns1
And for the life of me I can't figure this out.
Thanks for any help ;)
------------------------------
Date: Tue, 02 Oct 2001 15:37:24 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: use Module vs. use module
Message-Id: <3BBA2584.BB49CF5C@home.com>
Bart Lateur wrote:
>
> Michael Carman wrote:
>
> >use foo; # Typo -- should be 'Foo'
> >
> >BEGIN {
> > die "Import failed" unless exists &baz;
> >}
> >
> >Note that there's no point in checking for Foo::baz. Perl found
> >Foo.pm (thanks to your case-insensitive OS) which means that
> >Foo::baz does exist; it just didn't get imported.
>
> Not true. It's easy to loose sight of this, but the correlation of the
> name of the module file and the package is a convention. Nothing more.
> It's an important convention, because the proper workings of use()
> depend on it, but it's still just convention.
Fair enough, but it was "the proper workings of use()" that I was
concerned with. Failure to abide by this will cause more severe
problems. ;)
> So if your file is foo.pm and your package is Foo, then Foo::baz
> may exist but foo::baz will not.
Of course. Perhaps I didn't make myself clear. If Perl finds the file,
then the package will get loaded and its subroutines will exist. But
unless the name given to 'use' in the script matches the name specified
by 'package' in the module file, any imports will fail. As such, you
don't want to test for the existance of something in the module. (Unless
you plan on making the same typo repeatedly.) Instead, check whether or
not something which should have been imported was.
> But, as I wrote before: it may be relevant to know if the package
> exists, but not if the sub "import" actually exists.
Agreed.
-mjc
------------------------------
Date: Tue, 2 Oct 2001 20:02:03 +0100
From: "Simon Pearce" <simonp@NOSPAM.dircon.co.uk>
Subject: Using sendmail with PGP
Message-Id: <9pd31b$qe2$1@news6.svr.pol.co.uk>
I need to encrypt mail sent from one of my CGI scripts (credit card info)
using PGP - anybody know any good resources/docs/sites that might help me?
I've seen a few 'formmail' type scripts that use PGP but they seem way to
complicated to implement in my own script.
Thanks everyone
Simon
------------------------------
Date: Tue, 02 Oct 2001 19:46:34 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Using sendmail with PGP
Message-Id: <mbudash-049B28.12463702102001@news.sonic.net>
In article <9pd31b$qe2$1@news6.svr.pol.co.uk>, "Simon Pearce"
<simonp@NOSPAM.dircon.co.uk> wrote:
> I need to encrypt mail sent from one of my CGI scripts (credit card info)
> using PGP - anybody know any good resources/docs/sites that might help me?
>
> I've seen a few 'formmail' type scripts that use PGP but they seem way to
> complicated to implement in my own script.
>
> Thanks everyone
>
> Simon
>
>
here's an untested snippet (intended for use with PGP 5.x for Irix) that
may help you get started:
# We need a library function
use IPC::Open2;
# Set up the pgp command
$pgpcmd = '/full/path/to/pgpe -at -r public_key_name';
# Open the PGP program for bidirectional I/O
$pid = open2(\*READPGP, \*WRITEPGP, $pgpcmd) or die("Open2 failed! OS
error: $!");
# Send text to be encrypted to PGP
print WRITEPGP $text_to_encrypt;
# Encrypt the data
close(WRITEPGP) or die("Write close failed! OS error: $! Child error:
$?");
# Get the encrypted data from PGP
@encrypted_text = <READPGP>;
$encrypted_text= join ('', @ encrypted_text);
# Finish up
close(READPGP) or die("Read close failed! OS error: $! Child error: $?");
as i said, this is untested as delivered.
hope this helps,
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Tue, 2 Oct 2001 16:00:03 -0400
From: "Phil R Lawrence" <prlawrence@lehigh.edu>
Subject: Which Class::* lets me do this?
Message-Id: <9pd6cf$co0@fidoii.CC.Lehigh.EDU>
I have a question about OOP and the Class::* modules. Basically I
want to create an object (A) that contains, among other things, a hash
of objects (B). The end customer (a perl script) recieves an A
object, and through it needs access to the B.constructor method, for
the purpose of adding new B objects to A's hash slot.
Of course, the B.accessor methods and such also need to be accessible
from the end script.
Here is Class::MethodMaker pseudo code with comments asking for
specific help. I appreciate any leads. Also, let me know if another
of the Class::* modules would lend itself better to this.
Thanks!
Phil R Lawrence
./SQL/Snippet.pm
-------------------BEGIN FILE--------------
#################################
package SQL::Snippet::Parm;
use diagnostics;
use strict;
# We'll only use a couple of these slots
# in this example
use Class::MethodMaker
new_hash_init => 'new_parm',
boolean => [qw/ allow_null
confirm_values
get_set => [qw/ name
label
description /],
list => [qw/ msg_lines
prompt_lines
re_prompt_lines
default_values
values
sql_checks
regex_checks /];
#################################
package SQL::Snippet;
use diagnostics;
use strict;
use base qw/ SQL::Snippet::Parm /;
use Class::MethodMaker
new_hash_init => 'new',
boolean => 'interact_mode',
get_set => 'select_clause',
list => 'baseline_limits',
# Please help with this part...
# I want a hash of SQL::Snippet::Parm objects
hash => 'parm';
# So I'll end up with a hash with slot 'parm',
# but how can I populate it with SQL::Snippet::Parm
# objects from the calling module (below)?
# ...
1;
-------------------END FILE----------------
./SQL/Snippet/Admissions.pm
-------------------BEGIN FILE--------------
package SQL::Snippet::Admissions;
use diagnostics;
use strict;
use base qw/ SQL::Snippet /;
my $snippet;
BEGIN
{
$snippet = SQL::Snippet->new(
interact_mode => 1,
);
# Set up some default Admissions snippage...
$snippet->parm->new(
# how can I pass the name of the slot
# I want this object saved under?
name => 'test_parm',
msg_lines => [
'Blah blah blah',
'Yep, pep, yep',
'and so on.',
],
default_values => [
'foo',
'bar',
'baz',
],
regex_checks => [ qr/^(\s*\d\.\d\d\s*)+$/ ],
prompt_lines => [ 'Bar bar' ].
);
}
sub get_snippet { $snippet }
1;
-------------------END FILE----------------
./scripts/use_snippage.pl
-------------------BEGIN FILE--------------
#!perl -w
use diagnostics;
use strict;
use SQL::Snippet::Admissions;
my $snippet = SQL::Snippet::Admissions->get_snippet;
# set up additional info in the existing snippet,
# the one we created in ./SQL/Snippet/Admissions.pm
$snippet->parm->test_parm->set_interact_mode;
$snippet->parm->test_parm->label( 'A Label' );
# Set up a new parm object...
$snippet->parm->new(
name => 'test_parm',
prompt_lines => [ 'Bar bar' ].
);
# ...
-------------------END FILE----------------
------------------------------
Date: Tue, 02 Oct 2001 20:58:06 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Which Class::* lets me do this?
Message-Id: <h0akrtsogmn0p13eki03lmmdl0j76ho0dt@4ax.com>
Phil R Lawrence wrote:
>I have a question about OOP and the Class::* modules. Basically I
>want to create an object (A) that contains, among other things, a hash
>of objects (B). The end customer (a perl script) recieves an A
>object, and through it needs access to the B.constructor method, for
>the purpose of adding new B objects to A's hash slot.
Are you sure you need one of the Class::* (which I don't know) modules?
This looks like something relatively easy to do in Perl. Any hash value
can be an object, any object. For example, HTML::TreeBuilder parses a
HTML document (using HTML::Parser) and makes a tree of HTML::Element
objects.
--
Bart.
------------------------------
Date: Tue, 2 Oct 2001 15:56:00 -0500
From: "Mr. Sunblade" <djberge@qwest.com>
Subject: Re: Yet another fork question
Message-Id: <mNpu7.2590$825.362000@news.uswest.net>
Uh, nevermind. It *does* work. Sorry 'bout that.
Mr. Sunblade
------------------------------
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 1858
***************************************