[15748] in Perl-Users-Digest
Perl-Users Digest, Issue: 3161 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 25 11:10:30 2000
Date: Thu, 25 May 2000 08:10:18 -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: <959267418-v9-i3161@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 25 May 2000 Volume: 9 Number: 3161
Today's topics:
NEWBIE: Variable = Command Line Results <president@webticker_dot_com.com>
NEWBIE: Variable = Command Line Results <president@webticker_dot_com.com>
Re: NEWBIE: Variable = Command Line Results <uackermann@orga.com>
Re: NEWBIE: Variable = Command Line Results <flavell@mail.cern.ch>
Re: NEWBIE: Variable = Command Line Results <red_orc@my-deja.com>
Re: Objects, SUPER:: and parameters... <aqumsieh@hyperchip.com>
Re: Perl Editor for Linux <dan@tuatha.sidhe.org>
Re: Perl Editor for Linux <jad9@po.cwru.edu>
Printing long scalars <jad9@po.cwru.edu>
Re: randomizing (anagramming words) <aqumsieh@hyperchip.com>
reading lines of file into several arrays <sw1nt@earthlink.net>
Re: reading lines of file into several arrays <tony_curtis32@yahoo.com>
Re: run perl script in background when html loads, with <red_orc@my-deja.com>
Re: run perl script in background when html loads, with <tony_curtis32@yahoo.com>
Re: Sending e-mail <sariq@texas.net>
Re: Sorting a Database jzoetewey@my-deja.com
Re: Sorting a Database <jeff@vpservices.com>
Re: Windows NT4.0 / IIS / ActivePerl 5.22 <vandemen@yahoo.com>
Re: Writing a concurrent server in perl <sweeheng@usa.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 25 May 2000 10:07:47 -0400
From: Julian Cook <president@webticker_dot_com.com>
To: comp.lang.perl@webticker_dot_com.com
Subject: NEWBIE: Variable = Command Line Results
Message-Id: <392D33B3.BDDFD552@webticker_dot_com.com>
Hello folks!
As usual, I bow to the collective genius of my peers.
I ask what may be quite possibly the simplest question that this forum
has seen
in a while probably
Here's my code. (Line numbers added only for clarity and wishful BASIC
thinking..hee hee)
1 #!/usr/local/bin/perl
2 $file = "testfile.txt";
3 $count = 'wc -l < $file';
4 die "wc failed: $?" if $?;
5 chomp($count);
6 print $count;
Ideally $count is assigned the output of wc -l <$file (counting number
of lines in $file)
but instead when this is executed $count has the literal value,
that is, it prints....
wc -l < $file
Many thanks in advance,
Julian
president@webticker_dot_com
(emailed changed as a guard against harvesters)
--
-----------------------------------------------------
My other car is a Garuda.....
-----------------------------------------------------
------------------------------
Date: Thu, 25 May 2000 10:08:23 -0400
From: Julian Cook <president@webticker_dot_com.com>
Subject: NEWBIE: Variable = Command Line Results
Message-Id: <392D33D6.5F2BF94F@webticker_dot_com.com>
Hello folks!
As usual, I bow to the collective genius of my peers.
I ask what may be quite possibly the simplest question that this forum
has seen
in a while probably
Here's my code. (Line numbers added only for clarity and wishful BASIC
thinking..hee hee)
1 #!/usr/local/bin/perl
2 $file = "testfile.txt";
3 $count = 'wc -l < $file';
4 die "wc failed: $?" if $?;
5 chomp($count);
6 print $count;
Ideally $count is assigned the output of wc -l <$file (counting number
of lines in $file)
but instead when this is executed $count has the literal value,
that is, it prints....
wc -l < $file
Many thanks in advance,
Julian
president@webticker_dot_com
(emailed changed as a guard against harvesters)
--
-----------------------------------------------------
My other car is a Garuda.....
-----------------------------------------------------
------------------------------
Date: Thu, 25 May 2000 16:12:52 +0200
From: Ulrich Ackermann <uackermann@orga.com>
Subject: Re: NEWBIE: Variable = Command Line Results
Message-Id: <392D34E4.E405FE7D@orga.com>
Julian Cook wrote:
> =
> Hello folks!
> As usual, I bow to the collective genius of my peers.
> I ask what may be quite possibly the simplest question that this forum
> has seen
> in a while probably
> =
> Here's my code. (Line numbers added only for clarity and wishful BASIC
> thinking..hee hee)
> =
> 1 #!/usr/local/bin/perl
> 2 $file =3D "testfile.txt";
> 3 $count =3D 'wc -l < $file';
> 4 die "wc failed: $?" if $?;
> 5 chomp($count);
> 6 print $count;
> =
> Ideally $count is assigned the output of wc -l <$file (counting number
> of lines in $file)
> but instead when this is executed $count has the literal value,
> that is, it prints....
> wc -l < $file
> =
> Many thanks in advance,
> Julian
> president@webticker_dot_com
> (emailed changed as a guard against harvesters)
> =
> --
> -----------------------------------------------------
> My other car is a Garuda.....
> -----------------------------------------------------
Just take a look at your backticks in line 3. Should be `wc -l < $file`,
don=B4t they?
HTH =
Ulrich
-- =
Ulrich Ackermann
ORGA Kartensysteme GmbH (SY-PEAT-STA)
Tel.:+49.5254.991-925 =
mailto:uackermann@orga.com
------------------------------
Date: Thu, 25 May 2000 16:43:36 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: NEWBIE: Variable = Command Line Results
Message-Id: <Pine.GHP.4.21.0005251642470.10338-100000@hpplus01.cern.ch>
On Thu, 25 May 2000, Ulrich Ackermann wrote:
> > My other car is a Garuda.....
> > -----------------------------------------------------
>
> Just take a look at your backticks in line 3.
Is this supposed to be some obscure joke?
------------------------------
Date: Thu, 25 May 2000 14:45:54 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: NEWBIE: Variable = Command Line Results
Message-Id: <8gjeas$ae6$1@nnrp1.deja.com>
In article <392D33D6.5F2BF94F@webticker_dot_com.com>,
Julian Cook <president@webticker_dot_com.com> wrote:
> Hello folks!
<SNIP>
> Here's my code. (Line numbers added only for clarity and wishful BASIC
> thinking..hee hee)
>
notwithstanding the usual suggestions (-w, use strict, . . .)
> 1 #!/usr/local/bin/perl
> 2 $file = "testfile.txt";
> 3 $count = 'wc -l < $file';
this should be $count = `wc -l < $file`; # note use of backticks
> 4 die "wc failed: $?" if $?;
> 5 chomp($count);
> 6 print $count;
>
> Ideally $count is assigned the output of wc -l <$file (counting number
> of lines in $file)
> but instead when this is executed $count has the literal value,
> that is, it prints....
> wc -l < $file
that's 'cause you used single-quote to assign that string to $count,
instead of using backticks to execute the command you wanted.
>
> Many thanks in advance,
> Julian
> president@webticker_dot_com
> (emailed changed as a guard against harvesters)
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 25 May 2000 14:27:25 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Objects, SUPER:: and parameters...
Message-Id: <7abt1u66y9.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me>
Zak McGregor <zapcs@icon.co.za> writes:
> $self->{_conn}=$self->SUPER::connectdb("dbname=xxxxxxxxx user=xxxxxx");
>
> I always get:
> Usage: Pg::connectdb(conninfo) at
> /usr/lib/perl5/5.00503/DBEngine/DBConnect.pm line 14.
The problem is not whether or not the call to connectdb() worked or not
(obviously, your script did call it), but rather with the parameters you
pass to it. Check out the docs (if any) for the Pg module. If you wrote
it, then make sure what it expects as input, and the way it calls the
appropriate method in DBConnect.pm.
--Ala
------------------------------
Date: Thu, 25 May 2000 14:29:34 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Perl Editor for Linux
Message-Id: <iNaX4.93428$hT2.386622@news1.rdc1.ct.home.com>
Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote:
> I was shocked! How could Elaine Ashton <elaine@chaos.wustl.edu>
> say such a terrible thing:
>>in article 8ghahj$qbt$1@nnrp1.deja.com, houseofpain@my-deja.com at
>>houseofpain@my-deja.com quoth:
>>
>>> Can anyone recomend a good Perl Editor for Linux. Someting i can use
>>> to trace through my code.
>>
>>Try ed.
> No No! cat is the one true text editor!!!
Luxury! Why, when I was learning all we had was a 9-volt battery, a aper
clip, and bare drive leads. Cat. Humph.
Dan
------------------------------
Date: Thu, 25 May 2000 10:52:57 -0500
From: "John A. Dutton" <jad9@po.cwru.edu>
Subject: Re: Perl Editor for Linux
Message-Id: <392D4C59.C355133B@po.cwru.edu>
Dan Sugalski wrote:
> Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote:
> > I was shocked! How could Elaine Ashton <elaine@chaos.wustl.edu>
> > say such a terrible thing:
> >>in article 8ghahj$qbt$1@nnrp1.deja.com, houseofpain@my-deja.com at
> >>houseofpain@my-deja.com quoth:
> >>
> >>> Can anyone recomend a good Perl Editor for Linux. Someting i can use
> >>> to trace through my code.
> >>
> >>Try ed.
>
> > No No! cat is the one true text editor!!!
>
> Luxury! Why, when I was learning all we had was a 9-volt battery, a aper
> clip, and bare drive leads. Cat. Humph.
>
> Dan
If you're looking for syntax highlighting, go with vim (in X, runs as gvim,
too) ... if you don't mind vi syntax.
John
------------------------------
Date: Thu, 25 May 2000 10:42:31 -0500
From: "John A. Dutton" <jad9@po.cwru.edu>
Subject: Printing long scalars
Message-Id: <392D49E6.93498C96@po.cwru.edu>
I'm running ePerl 2.2.14 over perl 5.005 and Apache on OpenBSD 2.6. I'm
running a personal diary system on my box that has to print out long
entries (greater than 750 characters). When I first coded this and
tested it with long entries simply saying:
<P><?=$entry!></P>
[ equivalent to:
print "<P>$entry</P>"; ]
perl would write NOTHING to STDOUT (or so says all browsers used) and
all heck ensued. So I wrote a hack to split up the scalar into 700
character blocks and print out each block in order. Amazingly, this
works for my diary. Yet, now I call this function from a different web
suite on the same box, doing similar diary-like functions, and it writes
nothing to STDOUT again. I'm using almost exactly the same syntax, but
what I'm most interested in is what causes this to happen. Is this an
ePerl issue or a known perl bug or ... ?
John
------------------------------
Date: Thu, 25 May 2000 14:04:29 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: randomizing (anagramming words)
Message-Id: <7aem6q680k.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me>
Kevin Miles <kdmiles@lucent.com> writes:
> If I want to randomize a word
>
> i.e.
>
> England
>
> to be (as an example)
>
> glnEand
You can do as others said: split word into array, shuffle array, join
letters back. But here's a faster method (didn't benchmark though):
my $string = 'England';
my $new;
$new .= $_ while $_ = substr $string =>
rand length $string, 1, '';
--Ala
------------------------------
Date: Thu, 25 May 2000 14:51:34 GMT
From: sw1nt <sw1nt@earthlink.net>
Subject: reading lines of file into several arrays
Message-Id: <Pine.LNX.4.21.0005251051450.7396-100000@icenine>
I know that subject line probably inspires "smack the non-RTFM'ing
newbie" feelings in all of you, but please read on.
I have a perl program that writes data to a file in the format:
blue red green purple
00255 25500 02550 15548255
monday tuesday wednesday thursday
I want to read the data into another perl program into an rray. One
array for each line of the file. One word in each element of each array.
Three arrays with four elements each. The files have a set number of lines,
but each line may be *very* long.
To test the array setup, I tried looping through one line at a time, like so:
<---BEGIN WHILE LOOP CODE--->
#!/usr/bin/perl -w
use strict;
my @array;
open(CACHE, '<infile') or die "cannot open file";
while (<CACHE>) {
@array = $_;
print "$array[0]";
}
close(CACHE);
<---END WHILE LOOP CODE--->
But this includes the entire first line in the first element of @array.
I got it all working with this code:
<---BEGIN CODE--->
#!/usr/bin/perl -w
open(CACHE, '<infile') || die "can't open file";
@info = qw(color number day);
$a = 0;
while (<CACHE>) {
chomp($_);
@array = $_;
foreach $var (<@array>) {
$arrname = $info[$a];
push(@$arrname, $var);
}
$a++;
}
print "$color[1]\n";
close(CACHE);
<---END CODE--->
This is ugly, but works. It bombs with 'use strict' and the -w warns that
'color' in the last print line is only used once.
I know there is probably a lot easier and cleaner way to do this, if
someone could point me to the right perldoc, or any suggestions,
it would be greatly appreciated.
thanks,
chris
------------------------------
Date: 25 May 2000 10:00:25 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: reading lines of file into several arrays
Message-Id: <87u2fmhdyu.fsf@limey.hpcc.uh.edu>
>> On Thu, 25 May 2000 14:51:34 GMT,
>> sw1nt <sw1nt@earthlink.net> said:
> I know that subject line probably inspires "smack the
> non-RTFM'ing newbie" feelings in all of you, but please
> read on.
Hey, you gave it a good go!
> I want to read the data into another perl program into
> an rray. One array for each line of the file. One word
> in each element of each array. Three arrays with four
> elements each. The files have a set number of lines, but
> each line may be *very* long.
Here's an example of how I might go about it. I've used
the DATA handle so I can avoid the open() malarky and get
to the nub of the problem:
my @lines;
while (<DATA>) {
chomp;
my @words = split /\s+/; # or / / if you KNOW it is one space
push @lines, \@words;
}
use Data::Dumper;
print Dumper(\@lines);
__DATA__
blue red green purple
00255 25500 02550 15548255
monday tuesday wednesday thursday
hth
t
------------------------------
Date: Thu, 25 May 2000 13:07:25 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: run perl script in background when html loads, without user intervention
Message-Id: <8gj8i0$62s$1@nnrp1.deja.com>
In article <siq3lubno154@corp.supernews.com>,
mick <michaelr69@eircom.net> wrote:
> can anybody help me
> when the html document loads
> i want a perl script to be executed
> the perl script will not return any info to the browser,
> instead it will fire off an email
>
assuming you have a link like
<A HREF="http://www.gork.net/gork.html">click here</A>
where gork.html is the document to which your refer above,
you probably want that link to be
<A HREF="http://www.gork.net/gork.cgi">click here</A>
where gork.cgi calls sendmail with appropriate content, and then
presents the appropriate html stuff.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 25 May 2000 09:27:59 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: run perl script in background when html loads, without user intervention
Message-Id: <87wvkihfgw.fsf@limey.hpcc.uh.edu>
>> On Thu, 25 May 2000 11:30:06 GMT,
>> mick <michaelr69@eircom.net> said:
> can anybody help me when the html document loads i want
> a perl script to be executed the perl script will not
> return any info to the browser, instead it will fire off
> an email
1. make the HTML be produced by a CGI program, but that is
off-topic for clpm, see comp.infosystems.www.authoring.cgi
2. use SSI to #exec the program within the HTML document,
but that is off-topic for clpm, see
comp.infosystems.www.servers*
3. associate a handler with the document by tweaking
whichever web server you are using, but that is
off-topic for clpm, see comp.infosystems.www.servers*
NB: your question doesn't actually have anything to do
with perl, it would apply to programs written in any
CGI-capable language, hence my redirects above.
hth
t
------------------------------
Date: Thu, 25 May 2000 09:13:18 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Sending e-mail
Message-Id: <392D34FE.B886E24B@texas.net>
Michael wrote:
>
> I have the script working except for a small problem that the e-mail portion
> won't send the e-mail to the recipient. Any ideas?
There's a bug in the part of the program that sends the mail.
HAND!
- Tom
------------------------------
Date: Thu, 25 May 2000 13:20:36 GMT
From: jzoetewey@my-deja.com
Subject: Re: Sorting a Database
Message-Id: <8gj9aj$6ke$1@nnrp1.deja.com>
> If the latter, take a look at Jeff
> Zucker's DBD::RAM (in fact, it could be adapted if you had to do the
former).
Looks like I replied to this message a bit too soon. I decided I'd go
check for DBD::RAM and couldn't find it in Active State's listing of
modules--which is bad because I'm limited to Windows at work. At home
things would be a bit easier.
What I need to do is to be able to sort. I also need to identify
duplicates--but I'm not too worried about how to do that either. What
mystifies me is how to sort a hash or array and then be able to keep
track of which record the sorted item originally came from.
Jim Zoetewey
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 25 May 2000 07:26:24 -0700
From: Jeff Zucker <jeff@vpservices.com>
To: jzoetewey@my-deja.com
Subject: Re: Sorting a Database
Message-Id: <392D3810.BF347D75@vpservices.com>
[posted and emailed]
jzoetewey@my-deja.com wrote:
>
> > If the latter, take a look at Jeff
> > Zucker's DBD::RAM (in fact, it could be adapted if you had to do the
> former).
>
> Looks like I replied to this message a bit too soon. I decided I'd go
> check for DBD::RAM and couldn't find it in Active State's listing of
> modules--which is bad because I'm limited to Windows at work. At home
> things would be a bit easier.
You're needlessly limiting yourself. Many modules (including DBD::RAM)
can be installed just fine on windows from the CPAN distribution. Just
download and unzip it. If you have nmake, you can install it on windows
with that, or if you don't have nmake and don't feel like getting a free
copy of it, just copy the RAM.pm file into your perl/site/lib/DBD
directory or into your own DBD directory. For DBD::RAM you'll need to
install the prerequisites mentioned in the readme file first (DBI,etc.)
but those *are* all available on activestate. Instructions and the
latest version are also available at
http://www.vpservices.com/jeff/programs/dbd-ram.html
> What I need to do is to be able to sort. I also need to identify
> duplicates--but I'm not too worried about how to do that either. What
> mystifies me is how to sort a hash or array and then be able to keep
> track of which record the sorted item originally came from.
You can accomplish that with hashes. If you choose to use DBD::RAM
instead, an eight line script will sort the records by any field or
group of fields you want and also allow you to apply flexible selection
criteria.
--
Jeff
------------------------------
Date: Thu, 25 May 2000 23:10:22 +0800
From: "Aaron" <vandemen@yahoo.com>
Subject: Re: Windows NT4.0 / IIS / ActivePerl 5.22
Message-Id: <b6bX4.4342$c5.6423@newsfeeds.bigpond.com>
Are all your scripts in the same directory with the same permissions ??
If the particular file ( your script ) does not have script permissions it
will not be interpreted by the ISAPI filter.
Cheers,
Aaron
Peter Krauzer <peter.krauzer@aon.at> wrote in message
news:959245061.861891@newsmaster-04.atnet.at...
> Maybe anyone can help.
>
> I am runnning ActiveState Perl 5.22 under Windows NT with IIS4. My problem
> is, that all my scripts are working fine most of the time. But sometimes I
> recieve instead of the script output the source code of my scripts.
>
> Any idea whats wrong with my configuration?
>
> Thanks
> :-) Peter
>
>
------------------------------
Date: Thu, 25 May 2000 21:45:27 +0800
From: "Swee Heng" <sweeheng@usa.net>
Subject: Re: Writing a concurrent server in perl
Message-Id: <8gjaff$oto$1@mawar.singnet.com.sg>
<hritzman@my-deja.com> wrote in message news:8gh5ua$mnd$1@nnrp1.deja.com...
> Interestingly in re-reading perlipc, they mentioned that
> SIG{CHLD} = 'IGNORE' will prevent zombies on some Unix systems. This
> doesn't work on our Dec Alpha (perl version 5.004_04 built for
> alpha-dec_osf), but _does_ work on our Solaris system (5.005_03 built
> for sun4-solaris).
>
> Any further thoughts, besides getting rid of our Alphas ;-) , would be
> welcome.
See perldoc -f sleep. It says that sleep "May be interrupted if the process
receives a signal such as `SIGALRM'". My (wild) guess is that SIGCHLD
interrupts sleep too.
Thinking along this line, I tried: "sleep 1 for 1..30" and "$i++ while ($i <
$BIG_NUMBER)" in place of "sleep 30". And it DID work on RH 6.2 Linux!
It is a crude hack but it may solve your problem. (What if the process has
30+ childs all exiting in sequence? :o)
Swee Heng
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 3161
**************************************