[11231] in Perl-Users-Digest
Perl-Users Digest, Issue: 4831 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 5 06:07:16 1999
Date: Fri, 5 Feb 99 03:00:18 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 5 Feb 1999 Volume: 8 Number: 4831
Today's topics:
Re: $reponse->content(); (Sam Holden)
5.00502 slow on Solaris 2.6 x86 frax@goliat.publ.ica.se
Re: Caputuring output and return code <sugalskd@netserve.ous.edu>
Change unix password from WINDOWS NT <xevi@itfintersoft.com>
Re: checking existance of subroutine <jrday@acm.org>
Error compiling module <p.lim2@ugrad.unimelb.edu.au>
Re: free PERL <jjarrett@ecpi.com>
get the path of a binary as hashed in memory <avitala@macs.biu.ac.il>
Re: How do I get local IP Address ? <uri@home.sysarch.com>
Re: How to replace text in a text file. (Sam Holden)
Re: matts search -- again (sorry!) <bencas@bigfoot.com>
Re: Perl in ASP code <matthew.sergeant@eml.ericsson.se>
perl path problem <elst.fels@nospam.ping.be>
Re: perl path problem (Bart Lateur)
Re: perl path problem (Larry Rosler)
problem with PerlTk (Stefano Ghirlanda)
Re: Programming with Style (Larry Rosler)
Re: Question: Arrays of associative arrays (Larry Rosler)
Re: regex Help (Larry Rosler)
Re: Sending Perl output to 2 diffent html frames <23_skidoo@geocities.com>
Re: testing for scalar/list/array <Patrick.Hayes.CAP_GEMINI@renault.fr>
Re: web load testing code <matthew.sergeant@eml.ericsson.se>
Win32::ODBC FetchRow() <olivier.henrot@alcatel.fr>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 5 Feb 1999 06:21:52 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: $reponse->content();
Message-Id: <slrn7bl3g0.m15.sholden@pgrad.cs.usyd.edu.au>
On Thu, 4 Feb 1999 16:34:11 -0000, Mike Watkins wrote:
>Hi there,
>
>No, that's not what I need. I need the script to still submit to the sites,
>which works fine, but I need to figure out how to get the content of the
>page which the remote script redirects the user to.
>
>Any help would be much appreciated,
>Mike Watkins
Then just follow the redirection. I have no idea how to do that since I don't
have much experience in the client side of web programming.
If a web browser does it then it can't be too hard...
--
Sam
Of course, in Perl culture, almost nothing is prohibited. My feeling is
that the rest of the world already has plenty of perfectly good
prohibitions, so why invent more? --Larry Wall
------------------------------
Date: Fri, 05 Feb 1999 09:17:07 GMT
From: frax@goliat.publ.ica.se
Subject: 5.00502 slow on Solaris 2.6 x86
Message-Id: <79ecuc$cci$1@nnrp1.dejanews.com>
I installed a testserver yesterday to replace my slow old Sparc 5/110.
The sparc is running Solaris 2.5.1 and perl 5.00404 and the new server
is a P2/266 with Solaris 2.6 and perl 5.00502.
I tossed together a small script to see if I would notice any difference
in speed and the test.pl took about 4secs on my rather busy sparc, the
same script took 24secs on the x86 machine.
After some thinking i installed perl 5.00404 on the x86 machine and now
the same script took 0.96secs to run.
I really wanna run the latest perl, have any one else noticed preformance
problems with 5.00502 on Solaris x86??
Heres some technical stuff and the script...
frax@apa> /usr/local/bin/perl5.00404 -V
Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration:
Platform:
osname=solaris, osvers=2.6, archname=i86pc-solaris
uname='sunos apa 5.6 generic i86pc i386 i86pc '
hint=recommended, useposix=true, d_sigaction=define
bincompat3=n useperlio=undef d_sfio=undef
Compiler:
cc='gcc', optimize='-O', gccversion=2.8.1
cppflags='-I/usr/local/include'
ccflags ='-I/usr/local/include'
stdchar='unsigned char', d_stdstdio=define, usevfork=false
voidflags=15, castflags=0, d_casti32=define, d_castneg=define
intsize=4, alignbytes=4, usemymalloc=y, prototype=define
Linker and Libraries:
ld='gcc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /shlib /lib /usr/lib /usr/ccs/lib
libs=-lsocket -lnsl -ldl -lm -lc -lcrypt
libc=/lib/libc.so, so=so
useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
cccdlflags='-fpic', lddlflags='-G -L/usr/local/lib'
Characteristics of this binary (from libperl):
Built under solaris
Compiled at Feb 4 1999 10:39:11
@INC:
/usr/local/lib/perl5/i86pc-solaris/5.00404
/usr/local/lib/perl5
/usr/local/lib/perl5/site_perl/i86pc-solaris
/usr/local/lib/perl5/site_perl
.
frax@apa> /usr/local/bin/perl5.00502 -V
Summary of my perl5 (5.0 patchlevel 5 subversion 2) configuration:
Platform:
osname=solaris, osvers=2.6, archname=i86pc-solaris
uname='sunos apa 5.6 generic i86pc i386 i86pc '
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef useperlio=undef d_sfio=undef
Compiler:
cc='gcc', optimize='-O', gccversion=2.8.1
cppflags='-I/usr/local/include'
ccflags ='-I/usr/local/include'
stdchar='unsigned char', d_stdstdio=define, usevfork=false
intsize=4, longsize=4, ptrsize=4, doublesize=8
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
alignbytes=4, usemymalloc=y, prototype=define
Linker and Libraries:
ld='gcc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /shlib /lib /usr/lib /usr/ccs/lib
libs=-lsocket -lnsl -ldl -lm -lc -lcrypt
libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'
Characteristics of this binary (from libperl):
Built under solaris
Compiled at Feb 5 1999 09:24:53
@INC:
/usr/local/lib/perl5/5.00502/i86pc-solaris
/usr/local/lib/perl5/5.00502
/usr/local/lib/perl5/site_perl/5.005/i86pc-solaris
/usr/local/lib/perl5/site_perl/5.005
.
frax@apa> cat test.pl
#!/usr/local/bin/perl5.00502
# or /usr/local/bin/perl5.00404
open FIL, "<words.txt" or die "Nops: $!\n";
# words.txt is a textfile with one word/line and aprox 46000 lines...
while (<FIL>) {
chomp;
push @ord, $_;
}
for $ord (reverse sort @ord) {
$i++;
print "$i: $ord\n" if $i==45400; # just to make sure something happens...
}
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 5 Feb 1999 07:00:02 GMT
From: Dan Sugalski <sugalskd@netserve.ous.edu>
Subject: Re: Caputuring output and return code
Message-Id: <79e4ti$4pg$1@news.NERO.NET>
James Goodall <jgoodall@vt.edu> wrote:
: I've used backticks to execute a command from the shell and capture
: the output and I've used system() to retrieve the command's return
: value, but how can I get both?
: e.g.
: $errno = system(("grep", $re, $file)); - returns the command's return
: value, but not it's output from stdout
: $output = `grep $re $file`; - returns the output from stdout of the
: command, but not it's return value
: I need both without running the command twice. Anyone know how this
: is done? TIA.
Well, $? holds the exit status of the most recently executed child
process. You could try that.
Dan
------------------------------
Date: Fri, 5 Feb 1999 10:28:13 +0100
From: "Xavier Batlle" <xevi@itfintersoft.com>
Subject: Change unix password from WINDOWS NT
Message-Id: <79ed3v$kd7$1@diana.bcn.ttd.net>
The question in simple. Can I changue the password of an user in a Perl CGI
( with active Perl), from a SOLARIS server?.
Any help would be appreciated.
Thanks in advanced.
xevi@itfintersoft.com
------------------------------
Date: Fri, 05 Feb 1999 00:28:49 -0800
From: Ryan Day <jrday@acm.org>
To: Arran Price <arranp@datamail.co.nz>
Subject: Re: checking existance of subroutine
Message-Id: <36BAABC1.9B18813F@acm.org>
You can use symbol tables to check for existence of symbols before eval'ing
them. However, this means not just subs in the symbol table, but al symbols
(including all scalars, arrays, and hashes in the main pacakage).
So, you may want to create a separate package for your subs (and subs only)
and check if they are defined in the symbol table of that package before eval'ing.
For example:
----------------
@STEP_SUB = ('foo','bar');
$bar = 0;
foreach $key (@STEP_SUB) {
if(defined $SUBS::{$key}) {
print "trying to run $key\n";
eval($key);
}
else {
print "sub $key not defined\n";
}
}
package SUBS;
sub foo {
print "foo\n";
return;
}
----------------
Since the subrouting 'foo' is defined in the package SUBS, I see it in
the symbol table %SUBS:: However, since 'bar' is in the symbol table
for %main:: it doesn't show up as defined in %SUBS::
There is most certainly a better way to do this, but I think this should
work for you.
Ryan
Arran Price wrote:
> Hi all,
>
> Im using an eval statement such as
>
> while ($CS<=$LS)
> {
> print"trying to run $STEP_SUB[$CS]\n";
> eval ("$STEP_SUB[$CS]");
> ++$CS;
> }
>
> so basically it loops through a whole lot of subroutines whose names are
> defined in @STEP_SUB. This works fine apart from when an entry in
> @STEP_SUB is not a valid subroutine. It dosent fail, just continues onto
> the next one.
>
> How do I check to make sure the subroutine is valid?
> Any help or pointers to help appreciated.
>
> cheers
>
> Arran
> arranp@datamail.co.nz
> My opinions are my own and do not reflect those of my employer.
------------------------------
Date: Fri, 05 Feb 1999 17:16:15 +1100
From: Paul Lim <p.lim2@ugrad.unimelb.edu.au>
Subject: Error compiling module
Message-Id: <36BA8CAE.3CF75F74@ugrad.unimelb.edu.au>
I seem to be getting this error a lot when installing modules:
/usr/lib/perl5/5.00502/i386-linux/CORE/perl.h:2434: redefinition of `union semun'
As a result I can't seem to install most modules... :(
I upgraded the perl that came with Redhat 5.2 to 5.00502 (from 5.004)
After I did the perl upgrade it couldn't access the perl modules. In particular I'm trying to install TkApache and it can't find Tk.pm, even though I knwo it's there. ????
Can anybody help?
Thanks,
Paul
p.s. P166 48Mb RAM, Installed "Everything" in RedHat 5.2. (so nothing should be missing, right?)
------------------------------
Date: Fri, 05 Feb 1999 00:08:56 -0500
From: "John T. Jarrett" <jjarrett@ecpi.com>
Subject: Re: free PERL
Message-Id: <36BA7CE8.338A85E0@ecpi.com>
I actually made it to the site, curious to what free ~tr/IDIOT/perl/ was
exactly, and there weren't a bit o' perl there!
John
Bart Lateur wrote:
> 3dsmax wrote:
>
> >free PERL examples and free downloads
> >
> >http://come.to/gamewire/
>
> Result:
> >THIS ACCOUNT HAS BEEN DELETED
> >
> >
> >You have reached this page after typing an URL
> >that was in conflict with our site policy.
> >The account has been disconnected.
> >
> >Please don't complain to us about this single account anymore.
> >The account has been disconnected and we have done
> >everything we could to stop the abuse.
>
> That was quick...
>
> Bart.
------------------------------
Date: Fri, 5 Feb 1999 12:02:24 -0000
From: "Avshi Avital" <avitala@macs.biu.ac.il>
Subject: get the path of a binary as hashed in memory
Message-Id: <79efn0$f6q$1@news.ibm.net.il>
hi all,
in the hope that it isn't too obvious.
when typing:
which [cmd]
on the unix prompt i get the path of [cmd] as hashed in internal mem. same
with 'where' (is that right?);
how do I do that from within perl?
this BTW, doesn't work (and seems like a work-around anyway):
$p=`which [cmd]`
appriciate any help,
avshi
------------------------------
Date: 05 Feb 1999 01:15:11 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: How do I get local IP Address ?
Message-Id: <x73e4lnzpr.fsf@home.sysarch.com>
>>>>> "MC" == Michael Ching <m_ching@hotmail.com> writes:
MC> if under winnt, ipconfig
not that i really give a damn, but can that be called from perl or is it
another winblows only useless program? you can't parse a window.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 5 Feb 1999 08:14:41 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: How to replace text in a text file.
Message-Id: <slrn7bla3h.m15.sholden@pgrad.cs.usyd.edu.au>
On Fri, 05 Feb 1999 05:20:10 GMT, chad@vcn.net <chad@vcn.net> wrote:
>In article <36BA273A.9C0A19C7@nnex.net>,
> Ted Bogeman <tbogeman@nnex.net> wrote:
>> Please Help
>>
>> I have a daemon that will call perl scripts when prompted. What I need
>> it to do: Is take the $username and edit the passwd file. I would like
>> to just send the user info to the script for unlocking and locking user
>> accounts. The script would find the username in /etc/passwd and then
>> change the x to ! , thus locking the account.
>>
>> username:x:1887:100:Real Name:/home/jbsw:/bin/bash (unlocked account)
>>
>> username:!:1887:100:Real Name:/home/jbsw:/bin/bash (locked account)
>>
>> Could someone please help with completing this script.
>>
>> #!/usr/bin/perl
>> open(INFILE,"@ARGV[0]");
>> $file = "@ARGV[0]";
>> $inline = <INFILE>;
>> ($username,$password,$realname,$shell,$uid,$gid) = split(/\:/,$inline);
>> close(INFILE);
>>
>> Thanks in advance. You can email me direct.
>
>
>
>Ok, so my .login solution does nothing for FTP accounts.
>
>Here's how I would edit the /etc/passwd file, perl guru's
>please speak up.
>
>-- untested code
Why? Is it really hard to run the code with a simple sample passwd file, the
two entries supplied in the original post would work...
>
>#!/usr/bin/perl
>
>if(!$ARGV[0] or !$ARGV[1]) {
> die "\nusage: script.pl [-l (lock) -u (unlock)] username\n\n";
>}
>
>chomp($now = `date +%s`);
No need to involve the shell just use localtime()...
>
># make a back-up of the passwd file incase I screw up
>print `cp /etc/passwd /somewhere/safe/passwd.$now`;
>
>$new_passwd = '';
>
># read in /etc/passwd
>open(PASSWD,"/etc/passwd") or die "You got problems.\n";
>while(<PASSWD>) {
> if($ARGV[0] eq "-l" and $_ =~ /^$ARGV[0]\:/) { s/^(.*?):x/$1:!/; }
> if($ARGV[0] eq "-u" and $_ =~ /^$ARGV[0]\:/) { s/^(.*?):!/$1:x/; }
> $new_passwd .= $_;
>}
>close(PASSWD);
>
># save changes (yikes);
>open(PASSWD,">/etc/passwd") or die "You got problems.\n";
>print PASSWD "$new_passwd";
>close(PASSWD);
Why not :
#!/usr/local/bin/perl -pi
s/^\Q$ENV{username}\E:x:/$ENV{username}:!:/
Note the \Q...\E without them really bad things would happen if you allow
meta-characters as in login names. Hope you don't use . in your user names
if you try the original solution.
That only locks, but making it work as a toggle is as simple as adding an
|| and making it an option is just as easy...
It would be invoked by a shell script which would take the username argument
put it in the $username environment variable, set $EDITOR to be the perl
script and run vipw (or whatever passwd file locking protocol you use),
something like :
#!/bin/sh
#error checking goes here... (check arguments, check uid, etc)
username="$1"
export username
EDITOR=/usr/local/sbin/lockuser.pl
export EDITOR
exec vipw
You could do it more efficiently by opening the file read/write and
finding the appropriate byte to change, but that would require more thinking
and probably more code.
--
Sam
Perl was designed to be a mess (though in the nicest of possible ways).
--Larry Wall
------------------------------
Date: Fri, 5 Feb 1999 10:53:42 -0000
From: "el_pollo_diablo" <bencas@bigfoot.com>
Subject: Re: matts search -- again (sorry!)
Message-Id: <79eilv$gcm$1@news5.svr.pol.co.uk>
doh stupid me I f**ked up.
I'll get my coat.
--
--
Peace, Empathy, Desire, Mischeif and Gladness.
Ben
el_pollo_diablo <bencas@bigfoot.com> wrote in message
news:79djsa$4pv$1@news8.svr.pol.co.uk...
>I'm attempting to get the form on matts simple search to be able to send
>more data to the search script. The form parsing routing is this:
>
>sub parse_form {
>
># Get the input
>
>read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
>
># Split the name-value pairs
>
>@pairs = split(/&/, $buffer);
>
>foreach $pair (@pairs) {
>
>($name, $value) = split(/=/, $pair);
>
>$value =~ tr/+/ /;
>
>$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>
>$FORM{$name} = $value;
>
>}
>
>}
>
>I've been playing with it allnight and I cant get it too work.
>
>How do I get it to recieve more than the current 3 form objects?
>
>Last time I posted about this I was told that Matts scripts were cack and I
>totally agree, however as you can see I'm totally new to this and I'm just
>trying to use this as a jumping block!
>
>Thanks for any help!
>
>--
>Peace, Empathy, Desire, Mischeif and Gladness.
>Ben
>
>
------------------------------
Date: Fri, 05 Feb 1999 09:15:49 +0000
From: Matt Sergeant <matthew.sergeant@eml.ericsson.se>
Subject: Re: Perl in ASP code
Message-Id: <36BAB6C5.79055DED@eml.ericsson.se>
Sean McKenna wrote:
>
> On Wed, 03 Feb 1999 11:35:55 +0000, Matt Sergeant
> <matthew.sergeant@eml.ericsson.se> wrote:
>
> >It doesn't specifically, but it does detail exactly what collections
> >are, and how to use them. A more direct (and more volatile) URL is:
> >
> >http://www.fastnetltd.ndirect.co.uk/Perl/PSIntro.html
>
> Matt, shouldn't that be
> http://www.fastnetltd.ndirect.co.uk/Perl/Articles/PSIntro.html
Don't you just love it when other people know your own web site better
than you do! ;-)
Thanks.
--
<Matt email="msergeant@ndirect.co.uk" />
| Fastnet Software Ltd | Perl in Active Server Pages |
| Perl Consultancy, Web Development | Database Design | XML |
| http://come.to/fastnet | Information Consolidation |
------------------------------
Date: Fri, 5 Feb 1999 07:19:27 +0100
From: "myname@mydomain.com" <elst.fels@nospam.ping.be>
Subject: perl path problem
Message-Id: <79e3lv$dqb$1@news3.Belgium.EU.net>
Is there a way to find out where the perl is on a server ?
I mean #!usr/bin/perl, #!usr/bin/local/perl, ...
Thank you,
Peter
------------------------------
Date: Fri, 05 Feb 1999 07:24:45 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: perl path problem
Message-Id: <36ba9c12.320871@news.skynet.be>
myname@mydomain.com wrote:
>Is there a way to find out where the perl is on a server ?
>I mean #!usr/bin/perl, #!usr/bin/local/perl, ...
One the command line (e.g. through telnet), do "which perl". While
you're at it, do a "perl -v" or "perl -V" too. That will tell you if
you're not accidently accessing perl4. If you are, best ask your ISP.
HTH,
Bart.
------------------------------
Date: Fri, 5 Feb 1999 00:55:11 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: perl path problem
Message-Id: <MPG.112451cc1a829ea7989a0b@nntp.hpl.hp.com>
In article <79e3lv$dqb$1@news3.Belgium.EU.net> on Fri, 5 Feb 1999
07:19:27 +0100, myname@mydomain.com <elst.fels@nospam.ping.be> says...
> Is there a way to find out where the perl is on a server ?
> I mean #!usr/bin/perl, #!usr/bin/local/perl, ...
Assuming you can run a command on the server system (preferably with the
same PATH as the account that runs the httpd daemon), and the server's
OS supports a Unix/POSIX toolkit, try the command:
which perl
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 5 Feb 1999 09:51:43 GMT
From: stefano@rerumnatura.zool.su.se (Stefano Ghirlanda)
Subject: problem with PerlTk
Message-Id: <slrn7blj7q.7rh.stefano@rerumnatura.zool.su.se>
Hi,
I'm learning perl since a few months, and I'm now trying to use the Tk
module. I started with the Hello world in TPJ 1, that I reproduce here:
use Tk;
$MW = MainWindow->new;
$hello = $MW->Button(
-text => 'Hello',
-command => sub {print STDOUT "hello\n"; exit;} );
$hello->pack;
MainLoop;
However, when I run it I get:
stefano: linux> ./hello
Goto undefined subroutine &main::-1 at
/usr/lib/perl5/site_perl/Tk/Widget.pm line 318.
Since I found it unlikely to be a bug in the Tk module, I ask what I'm
doing wrong. Perhaps the Tk module is not installed properly?
Tk application with tcl work. I'm on a linux system (redhat 5.2).
Thanks to everyone for your help,
Stefano
--
Stefano Ghirlanda, Zoologiska Institutionen, Stockholms Universitet
Office: D554, Arrheniusv. 14, S-106 91 Stockholm, Sweden
Phone: +46 8 164055, Fax: +46 8 167715, Email: stefano@zool.su.se
Support Free Science, look at: http://rerumnatura.zool.su.se
------------------------------
Date: Fri, 5 Feb 1999 00:46:47 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Programming with Style
Message-Id: <MPG.11244fcc5bed5ed9989a0a@nntp.hpl.hp.com>
In article <slinberg-0502990034460001@cc11620-a.lwmrn1.pa.home.com> on
Fri, 05 Feb 1999 05:34:45 GMT, Steve Linberg <slinberg@crocker.com>
says...
> In article <79dr91$ttv$1@nnrp1.dejanews.com>, chad@vcn.net wrote:
>
> > I'm sure I'll get
> > better with more and more experience and practice, just
> > wondering if anyone ran across a good book. I heard of one
> > called "The Pearls of Programming", but have never been able
> > to find it in a store.
>
> The Perl Cookbook, by Tom Christiansen and Nathan Torkington, is a great
> place to start. Lots of nice code samples in there.
Agreed.
The book chad is referring to is undoubtedly "Programming Pearls" by Jon
Bentley, ISBN: 0201103311. Some people have noticed an odd convergence
with the title of the Camel, "Programming Perl".
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 5 Feb 1999 00:38:04 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Question: Arrays of associative arrays
Message-Id: <MPG.11244dc64b5ae1e2989a09@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <slinberg-0502990050400001@cc11620-a.lwmrn1.pa.home.com> on
Fri, 05 Feb 1999 05:50:39 GMT, Steve Linberg <slinberg@crocker.com>
says...
> In article <MPG.11239bbd6aa7a4a9989a05@nntp.hpl.hp.com>, lr@hpl.hp.com
> (Larry Rosler) wrote:
>
> > You can't have an array of hashes. The elements of an array are
> > scalars, so they must be references to the hashes:
> >
> > @Array = (\%comp1, \%comp2, ..., \%compn);
>
> I know you know your stuff, Larry, so I'm sure you're correct, but I'm a
> little confused by this. The Camel, 2nd edition, p. 268-270 talks about
> arrays of hashes, and I use an array-of-hash structure right now in some
> code I'm working on. perldsc has samples. They don't seem to be using
> references, unless it's in some implicit way I don't understand. Can you
> shed any light?
<SNIP> long examples of so-called Lists of Hashes.
What you are missing is the significance of { } as the contructor of a
*reference* to an anonymous hash.
$hashref = { foo => 0, bar => 1 }; # Note the curly braces.
%hash = ( foo => 0, bar => 1 ); # Note the round parentheses.
You can use $hashref as a member of a list, because it is a scalar. If
you use %hash as a member of a list, you get the funny pseudo-fraction
that specifies the buckets in the hash, because the hash is evaluated in
scalar context.
No matter how loose the terminology 'List of Hashes' is, you cannot have
a list of hashes. You *can* have a list of hash references, though,
and you do in each of the examples I snipped.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 5 Feb 1999 00:22:11 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: regex Help
Message-Id: <MPG.11244a0558447087989a08@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <79dud7$ct$1@nnrp1.dejanews.com> on Fri, 05 Feb 1999 05:09:00
GMT, bob.pruett@cox.com <bob.pruett@cox.com> says...
...
> My environment is Perl 5.004 running on Sun Solaris 2.51
>
> Here are the questions:
>
> 1. I have read that I can use qr// to precompile the expression. I have tried
> this and have had no luck. How do I precompile this expression? Will it speed
> the processing?
Your regex is compiled once only, because there are no interpolations in
it. You cannot speed this up.
> 2. I have made the script use small strings instead of the whole file at once.
> This seemed to have sped it up greatly. What other regex tricks should I be
> using?
Not much that I can see. The '\s*' before '$END' should be eliminated,
because any spaces will be eaten up into the captured match, but that
shouldn't make a noticeable difference in speed.
> 3. Should I abandon regex altogether and start walking through the string
> manually?
That is possible. You could search for '$BEGIN' and '$END' with
index(), and use substr() to extract the intervening string. It might
be faster. Only benchmarking will tell you for sure.
> 4. This script does alot of concatenating of strings and I am concerned about
> garbage collection. Should I be? What can I do about it?
Push each of the modified lines onto an array, then return join("",
@array). This will avoid a lot of string concatenation.
> Here is some sample code:
>
> open(FILE, $fname)
Where is the test for failure and the terminating semicolon?
> while(<FILE>)
> {
> $_ =~ s/\$BEGIN\s*([\w\.\s]*)\s*\$END/proc_tag($1)/ge;
^^^^^^ ^^^
superfluous superfluous
> $template .= $_;
push @array, $_;
> }
> close(FILE);
>
> return $template;
Where is the sub you are returning from?
return join "", @array;
> sub proc_tag {
> my $this = shift;
> my $tagstring = shift;
This seems to be a function, not a method. There is only one argument.
Why are you reading two?
> # Parse template and replace template tags.
> $replacement = "Do something to process the tags in here";
>
> return($replacement);
> }
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 05 Feb 1999 10:33:36 +0000
From: 23_skidoo <23_skidoo@geocities.com>
Subject: Re: Sending Perl output to 2 diffent html frames
Message-Id: <36BAC8FF.240@geocities.com>
Eric The Read wrote:
>
> "Bob Van Der Ploeg" <bob@worldparts.com> writes:
> > How do I get perl to send output to 2 different html frames?
i do this by having 2 scripts, one i call a 'bridging script' which
takes whatever input was given and writes a frameset to the browser, the
url in each frame being along the lines of
<frame src="/cgi/script.pl?fu=bar&sna=fu">
so long as script.pl can read variables like this, and since ReadParse
in cgi-lib will do this for you, no problems.
well.... that's not strictly true, i believe there is a limit to how
much info you can stack like that but for small/med amounts of data
passed it works fine.
-23
------------------------------
Date: 05 Feb 1999 10:20:13 +0100
From: Patrick Hayes <Patrick.Hayes.CAP_GEMINI@renault.fr>
Subject: Re: testing for scalar/list/array
Message-Id: <vxj679h6wc2.fsf@goblin.pdj.renault.fr>
mgjv@comdyn.com.au (Martien Verbruggen) writes:
> surprising, but explainable :)
Um, would you mind explaining it?
Pat
------------------------------
Date: Fri, 05 Feb 1999 09:21:04 +0000
From: Matt Sergeant <matthew.sergeant@eml.ericsson.se>
Subject: Re: web load testing code
Message-Id: <36BAB800.764C927F@eml.ericsson.se>
Rob Butler wrote:
>
> Martin Vorlaender wrote in message
> <36b7e5c9.524144494f47414741@radiogaga.harz.de>...
> >Tom Bates (ctbates@tva.gov) wrote:
> >: Is anyone aware of any published perl code or modules out there for load
> >: testing a web server?
> >
> >Not Perl, but anyway: for Win32, there's a tool called Socrates.
> >Can't remember where I got it, though.
>
> Hello all
>
> Just checkin out the perl newsgroup and I thought I would lend a hand.
> You can get Socrates from
>
> http://davecentral.com/3978.html
Thank you. Just what I've been looking for. The perl stress testing
stuff is fine for simple jobs, but this is much better.
--
<Matt email="msergeant@ndirect.co.uk" />
| Fastnet Software Ltd | Perl in Active Server Pages |
| Perl Consultancy, Web Development | Database Design | XML |
| http://come.to/fastnet | Information Consolidation |
------------------------------
Date: Fri, 05 Feb 1999 11:33:28 +0100
From: Olivier <olivier.henrot@alcatel.fr>
Subject: Win32::ODBC FetchRow()
Message-Id: <36BAC8F8.3955E298@alcatel.fr>
Hi,
I've a strange problem with this bit of code:
print("<select name=C_INFO size=1>\n");
$db->Sql("select * from myTable
where VALID_I = 'O'
order by C_INFO;");
while($db->FetchRow()){
$ARCVINF_C_INFO=$db->Data(C_INFO);
print("<option>$ARCVINF_C_INFO\n");
}
print("</select>\n");
although it works just fine in DOS mode and in debugging mode, when it
is launched from netscape, the script never ends, returns no error and
just hangs, and i have to kill it manually...
The fetch should return about 100 values, is it too much for perl/cgi to
handle? If I add a "and C_INFO like 'A%' " in my sql query, it works
just fine...
Any Idea ?
Thanks for your help.
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 4831
**************************************