[7491] in Perl-Users-Digest
Perl-Users Digest, Issue: 1117 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 2 20:07:19 1997
Date: Thu, 2 Oct 97 17:00:35 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 2 Oct 1997 Volume: 8 Number: 1117
Today's topics:
"Unreading" an input line <danilo@acme.nsc.com>
Re: [req] a procmail replacement in perl (Chip Salzenberg)
Bad arg length for Socket::unpack_sockaddr_in, length i glucz@compuline.com
Banner rotation / click thru system needed <neil@njmcov.demon.co.uk>
Re: Bigtime Newbie needs a teeny bit of help . . . (Doug)
Re: Can anonymous subroutines also be anonymous methods (Chip Salzenberg)
Emmulating MORE in Perl? (Jim Turner )
Re: How do I change group (GID) in perl (Chip Salzenberg)
Inheritance inside a Safe compartment <jmayer@texas.net>
Install perl on NT <vesuvio@worldaccess.nl>
Re: New Perl syntax idea (Chip Salzenberg)
Newbie CGI question <dbarr@simplex.com>
Re: Newbie ques: How to concatenate two strings? (Chip Salzenberg)
Re: Number of Emails? (R Chandrasekar (Mickey))
Re: Parsing compressed text (Doug Roberts)
pattern matching question <tkeitt@santafe.edu>
Re: pattern matching question (Mike Stok)
Re: pattern matching question <jgostin@shell2.ba.best.com>
Performing Subroutines from a string of text ads@websp.com
PERL 5.003 and the _STDC_ variable <sarahck@planet.eon.net>
re: perl modem access david@barnworth.com
problem with redirection <camerond@mail.uca.edu>
shell script (Jeff Fayne)
Re: shell script <jgostin@shell2.ba.best.com>
Re: String Concat Acting Weird (Greg Zevin)
Re: symbolic dereferencing of my() variables -- can it (Chip Salzenberg)
Re: sysread() question (Chip Salzenberg)
Re: usemymalloc (Ilya Zakharevich)
Re: XS: sv_2mortal (when is it necessary?) (Chip Salzenberg)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 2 Oct 1997 22:32:25 GMT
From: Danilo Unite <danilo@acme.nsc.com>
Subject: "Unreading" an input line
Message-Id: <343420F9.7CC225C0@acme.nsc.com>
Hi,
I am trying to parse input from a socket connection to a daemon process.
I have a function that reads this input a line at a time. I am using
this function in a recursive manner such that in some instances I want
to put the line that I just read back into the input stream so that the
same line is available to a subsequent call to this function. The
following snippet of code illustrates what I am trying to do:
local($STATE) = 0;
while(!eof($fh)){
$attr = &_readAttr($fh);
if(ref($attr) ne "Error"){
$attrlist->add($attr);
}
else{
$return $attr;
}
}
.
.
sub _readAttr{
$line = <@_>;
if($STATE == 0){
.......
$STATE = 1;
&_readAttr(@_);
}
else{
.....
# push $line back onto input stream
}
}
I'm suspecting that I may have to bypass the standard I/O stuff work
with sysread() and seek(), but I'm not sure how to do this. Any help
would be appreciated.
Thanks in advance,
Danilo Unite
------------------------------
Date: 2 Oct 1997 18:51:42 GMT
From: chip@rio.atlantic.net (Chip Salzenberg)
Subject: Re: [req] a procmail replacement in perl
Message-Id: <610qfu$rs8$1@news1.atlantic.net>
According to Nicolas MONNET <nico@idnet.fr>:
> Honestly, I looked everypossiblewhere, and could not find that: a
>procmail/deliver eqv writen in Perl.
Well, as Deliver's author, I must point out that Deliver was made to
work with Perl. My personal delivery file is written in Perl. And
Larry uses it. :-)
--
Chip Salzenberg - a.k.a. - <chip@pobox.com>
"He's Mr. Big of 'Big And Tall' fame." // MST3K
------------------------------
Date: Thu, 02 Oct 1997 17:12:17 -0600
From: glucz@compuline.com
Subject: Bad arg length for Socket::unpack_sockaddr_in, length is 0
Message-Id: <875779514.11146@dejanews.com>
I have a perl server script that works fine
most of the time, but when a friend of mine
tried to connect to it, it died with the
following error:
Bad arg length for Socket::unpack_sockaddr_in, length is 0
should be 16 at /usr/lib/perl5/Socket.pm line 236.
What might be the problem.
When posting a replay, please be sure to cc-it
to my e-mail address.
Thanks in advance: Geza Lucz
glucz@compuline.com
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Wed, 01 Oct 1997 09:41:13
From: Neil <neil@njmcov.demon.co.uk>
Subject: Banner rotation / click thru system needed
Message-Id: <78227216wnr@njmcov.demon.co.uk>
Hi,
Can anyone please let me know if I can get hold of a system which will
allow me to place advertisers banners on my websites.
I would like to be able to track display and cick thru stats online and
rotate banners as and when needed.
If there is such a system in the public domain it would be appreciated.
If I have to pay someone to write me one then so be it, just let me
know.
Thanks
--
Neil McAliece
------------------------------
Date: Thu, 02 Oct 1997 16:21:38 GMT
From: doug@3dlabs.com (Doug)
Subject: Re: Bigtime Newbie needs a teeny bit of help . . .
Message-Id: <60vm51$5k0$1@acdc.3dlabs.com>
Use the AT.exe command, or WINAT.exe give a GUI for the same
scheduler.
Doug
mgjv@mali.comdyn.com.au (Martien Verbruggen) wrote:
>In article <3432815a.3413784@news.internex.net>,
> rama@rely.com (Rama Polefka) writes:
>> i have a simple problem -
>> i need to run a series of commands at specified intervals to trigger a
>> mail flush. the series of commands is as follows:
>[snip]
>> this needs to run on a NT box that is receiving mail from another mail
>Doesn't NT come with some sort of crontab like scheduling thingie? I
>wouldn't really want to write anything myself in perl, but would just
>use that.
>--
>Martien Verbruggen |
>Webmaster www.tradingpost.com.au | That's not a lie, it's a terminological
>Commercial Dynamics Pty. Ltd. | inexactitude.
>NSW, Australia |
------------------------------
Date: 2 Oct 1997 19:22:58 GMT
From: chip@rio.atlantic.net (Chip Salzenberg)
Subject: Re: Can anonymous subroutines also be anonymous methods?
Message-Id: <610sai$t28$1@news1.atlantic.net>
According to men2@auto.med.ohio-state.edu (Mark Nielsen):
>I would like ot be able to do the following
>$Object -> {$ReferenceToMethod} ("$Variable");
In Perl 5.004_04, the forthcoming maintenance release, you can say:
$Object->$ReferenceToMethod($params)
BTW, putting $Variable in double quotes is usually pointless.
--
Chip Salzenberg - a.k.a. - <chip@pobox.com>
"He's Mr. Big of 'Big And Tall' fame." // MST3K
------------------------------
Date: 2 Oct 1997 21:36:32 GMT
From: turnerj@cliffy.lmtas.lmco.com (Jim Turner )
Subject: Emmulating MORE in Perl?
Message-Id: <611450$flg1@quest.lmtas.lmco.com>
Help! I am needing to emmulate the behavior of "more" using Perl. My
problem is that I am piping in a file, command results, etc. into STDIN, but
need to be able to pause and input a character directly from the terminal
in the same program. Anyone have any ideas how to do this? I looked first
in the Camel book and then in the Modules list in CPAN, but didn't find
anything that looked like it would work.
Thanks very much in advance.
Jim Turner
turnerj@mmc1001.lmtas.lmco.com
------------------------------
Date: 2 Oct 1997 19:01:46 GMT
From: chip@rio.atlantic.net (Chip Salzenberg)
Subject: Re: How do I change group (GID) in perl
Message-Id: <610r2q$s8q$1@news1.atlantic.net>
According to Chuck Stein <mirror@scruznet.com>:
>How can I change the group ID (GID) inside a perl
>script such that I can delete files of the new group
>that are writeable? Assume I am changing to a group
>that the calling user is part of (but not their
>default group).
You can't do that directly. You'll have to use system() or `` to
spawn a newgrp command that does what you really want.
--
Chip Salzenberg - a.k.a. - <chip@pobox.com>
"He's Mr. Big of 'Big And Tall' fame." // MST3K
------------------------------
Date: Thu, 2 Oct 1997 21:13:12 +0000
From: JonathanMayer <jmayer@texas.net>
Subject: Inheritance inside a Safe compartment
Message-Id: <Pine.LNX.3.95.971002205150.22355A-100000@perfidia>
Hi folks!
Here's what I want to do:
use Safe;
$cpt = new Safe;
# define the class test1 inside the cpt, which works fine:
$cpt->reval("package test1; sub hello { print \"hi\\n\"; }");
# but when I try:
$cpt->reval("package test2; \@ISA = ( 'test1' );");
$cpt->reval("test1::hello();"); # works fine
$cpt->reval("test2::hello();"); # doesn't work.
How can I have one class within a Safe compartment inherit from
another class, either within or without that Safe compartment?
Perhaps I need @ISA = ('Safe::Root0::test1') ?
And while we're at it, what exactly is Safe.pm doing? Apparently:
my $evalsub = eval sprintf(<<'EOT', $root);
package %s;
sub {
eval $expr;
}
EOT
return safe_call_sv($root, $mask, $evalsub);
so the first eval just defines a sub that evaluates my text, and is
eval'ed just to put everything in the correct package. Is my text
still text at this point or has it been converted to opcodes already?
I assume that safe_call_sv attempts to execute the eval'ed sv with an
opcode mask. What if I were to modify this to put my packages in
main::test, instead of main::Safe::root0::test? Would I be compromising
security?
Thank you kindly sirs,
Jonathan.
jmayer AT earthling.net
(free Randal Schwartz!)
________________________________________________________________________
space monkey jmayer AT earthling.net
TUNE IN TURN ON DWEEB OUT
------------------------------
Date: Thu, 02 Oct 1997 23:27:25 +0100
From: "Drs.H.M.L. van der Gun" <vesuvio@worldaccess.nl>
Subject: Install perl on NT
Message-Id: <34341FCD.5D7A4147@worldaccess.nl>
Dear reader,
I tried to install perl 5.003_07 on a NT-server 4.0, with IIS 2
installed.
After running pw32i310(2).exe and automatically installing in the same
directory, an error occurs.
The last command in the batchfile is (for updating the path):
"Retrieving Path information from session manager"
the result is:
"Win 32::RegSetValueEx: Type not specified, cannot set Path
The result is that we are not able to run script, because the path is
not found.
Typing on the command line:
"assoc .pl=PerlScript"
"FTYPE PerlScript=[our path to perl]/perl.exe %1 !*"
or introducing the *.pl file type to the the NT-explorer brings no
solution
I would be grateful if somebody could help me?
Thanks,
Eric van der Gun
------------------------------
Date: 2 Oct 1997 19:05:29 GMT
From: chip@rio.atlantic.net (Chip Salzenberg)
Subject: Re: New Perl syntax idea
Message-Id: <610r9p$s9i$1@news1.atlantic.net>
According to chris@ixlabs.com:
>Greg Bacon wrote:
>> In article <342FE73B.41C2@ixlabs.com>,
>> Chris Schoenfeld <chris@ixlabs.com> writes:
>> : How about aliasing 'method' to 'sub' and passing the object reference
>> : through a magic variable when 'method' is used?
>>
>> What potential benefits do you see for such an addition?
>
>To eliminate the repetitive use of:
>my $self = shift;
Larry has planned forever to allow parameter names in prototypes:
sub methodname ($this, $param) { $this->othermeth($param) }
That'll help with $this and also other verbosities.
--
Chip Salzenberg - a.k.a. - <chip@pobox.com>
"Men of lofty genius are most active
when they are doing the least work."
-- Leonardo da Vinci
------------------------------
Date: Thu, 02 Oct 1997 16:41:12 -0700
From: David Barr <dbarr@simplex.com>
Subject: Newbie CGI question
Message-Id: <34343118.8C5FE1C4@simplex.com>
Good Morning!
(Considering my ISP is UUNet, I hope this gets somewhere where it can be
read...)
Would someone please send me a code fragment that shows me the basic basic
read and write capabilities of perl when receiving from and sending to a
web client. Also, I'm not certain of the interaction between the web
client, the web server, and the actual script, so hints there would also be
helpful.
What I'm looking for is something at the level of:
for (<STDIN>) {
chop;
@array = split (/&/,$_);
...
}
to read the text sent to the script and something at a similar level to
return a script generated html document to the client. I can look up the
pre-written libraries on the Web, but that doesn't teach me anything.
Anyone have any hints?
Oh, and please reply by email, as I rarely get time to surf USENET looking
for responses.
Thanks in advance,
David
--
David Barr | Systems Administration:
dbarr@simplex.com | Problems solved while you wait.
Simplex Solutions, Inc. |
Sunnyvale, CA, USA | ( Where's my sledgehammer?... )
------------------------------
Date: 2 Oct 1997 19:09:42 GMT
From: chip@rio.atlantic.net (Chip Salzenberg)
Subject: Re: Newbie ques: How to concatenate two strings?
Message-Id: <610rhm$sii$1@news1.atlantic.net>
According to ben@reser.org (Ben Reser):
>You're right this is bad style.
>
>Whenever you can avoid interpolation do so. That means if you don't
>need to quote something with double quotes don't.
Perhaps you don't realize that the compiler turns "$a$b" into $a.$b
so there is no performance difference whatever.
As for style, you should mark your opinions as such.
--
Chip Salzenberg - a.k.a. - <chip@pobox.com>
"Men of lofty genius are most active
when they are doing the least work."
-- Leonardo da Vinci
------------------------------
Date: 2 Oct 1997 21:58:46 GMT
From: mickeyc@linc.cis.upenn.edu (R Chandrasekar (Mickey))
Subject: Re: Number of Emails?
Message-Id: <6115em$t6l$1@netnews.upenn.edu>
brian d foy (comdog@computerdog.com) wrote:
: In article <610s8b$p0a$1@shell3.ba.best.com>, mcravit@best.com (Matthew Cravit) wrote:
: >In article <01bccf64$be680aa0$16b84dcc@flax.ncfcomm.com>,
: >Spencer Alewel <salewel@ncfcomm.com> wrote:
: >>I'm just starting to learn Perl and I was wondering if someone could pass
: >>some hints on as to how to count the number of emails that a particular
: >>individual or account has.
: > while (<$fh>) {
: > $count++ if ($_ =~ m/^From /);
: > }
: so what happens with "From"'s embedded in the email text and happen to
: be right after an $INPUT_RECORD_SEPARATOR? $count will only be the
: greatest lower bound - not necessarily the number of email messages.
Mailers are supposed to detect From's at the start of records
in text and change them, usually to >From.
-- rc
--
Raman Chandrasekar, CASI/Instt for Research in Cognitive Science,
Univ of Pennsylvania,3401 Walnut St, Suite 400A, Philadelphia PA 19104
Phone: +1-215-898-0332, Fax: +1-215-573-9247, Home: +1-610-352-5512
mickeyc@linc.cis.upenn.edu http://www.cis.upenn.edu/~mickeyc
------------------------------
Date: Thu, 02 Oct 1997 13:51:58 -0800
From: zz---dougr--zz@headspace.com (Doug Roberts)
Subject: Re: Parsing compressed text
Message-Id: <zz---dougr--zz-ya02408000R0210971351580001@news1.alterdial.uu.net>
In article <34336465.7A4DA416@absyss.fr>, Doug Seay <seay@absyss.fr> wrote:
> Ain't no magic in zcat. Try gzip with the -d option do decompress and
> the -c option to dump to standard output. This lets you do something
> like
>
> gzip -dc MY_FILE | MY_PERL_SCRIPT
Actually, I was doing exactly that with zcat, but like I said, I need a
perl specific tool since this may not be a Linux solution, but either Mac
or NT
> If you want to roll things into a single process, I think that there is
> some sort of compression module in CPAN that works with gzip, go root
> around a bit.
I rooted and came up with some stuff, thanks. Not as intuitive as I had
hoped (perl semi newbie), still trying.
--
Doug Roberts
to reduce spam, reply to me at dougr at headspace.com
============
The views I express do not reflect those of my employer or the other voices
I hear in my head.
(Do too!) (Do not!)
(Do too!) (Do not!)
(Too!) (Not!)
------------------------------
Date: Thu, 02 Oct 1997 13:32:22 -0600
From: "Timothy H. Keitt" <tkeitt@santafe.edu>
Subject: pattern matching question
Message-Id: <3433F6C6.771F@santafe.edu>
Hi,
I'm trying to count the number of matches between a template string and
some other string. For example,
$count = $string =~ tr/$template//;
or
while ( $string =~ m/$template/g ) { $count++ }
The problem is that this doesn't do exactly what I want. I want to count
matches in a sliding-window fashion, e.g., the template "aa" should
match the string "aaa" *twice*, not once. Is there someway to backtrack
the position of the match to exactly one character past the beginning of
the last match?
Thanks,
Tim
------------------------------
Date: 2 Oct 1997 20:57:21 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: pattern matching question
Message-Id: <6111rh$6fb@news-central.tiac.net>
In article <3433F6C6.771F@santafe.edu>,
Timothy H. Keitt <tkeitt@santafe.edu> wrote:
>I'm trying to count the number of matches between a template string and
>some other string. For example,
>
> $count = $string =~ tr/$template//;
>
>or
>
> while ( $string =~ m/$template/g ) { $count++ }
>
>The problem is that this doesn't do exactly what I want. I want to count
>matches in a sliding-window fashion, e.g., the template "aa" should
>match the string "aaa" *twice*, not once. Is there someway to backtrack
>the position of the match to exactly one character past the beginning of
>the last match?
Does
$string = 'a frick aa b aaa banana aaaa fripp';
$count = 0;
$count++ while $string =~ /(?=aa)/gc;
do what you want? with 5.004_04 O get $count as 6
a frick aa b aaa banana aaaa fripp
11 22 44
33 55
66
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: 2 Oct 1997 20:57:36 GMT
From: Jeff Gostin <jgostin@shell2.ba.best.com>
Subject: Re: pattern matching question
Message-Id: <6111s0$d8v$2@nntp1.ba.best.com>
Timothy H. Keitt <tkeitt@santafe.edu> wrote:
: while ( $string =~ m/$template/g ) { $count++ }
>From "perldoc perlre":
By default, a quantified subpattern is "greedy", that is,
it will match as many times as possible (given a
particular starting location) while still allowing the
rest of the pattern to match. If you want it to match the
minimum number of times possible, follow the quantifier
with a "?". Note that the meanings don't change, just the
"greediness":
*? Match 0 or more times
+? Match 1 or more times
?? Match 0 or 1 time
{n}? Match exactly n times
{n,}? Match at least n times
{n,m}? Match at least n but not more than m times
Maybe try:
while ($string =~ m/$template?/g) {$count++} #untested!
I hope this helps! For more info, see "perldoc perlre". It may prove useful.
I haven't checked the FAQ on this, but it may also be there.
--Jeff
------------------------------
Date: Thu, 02 Oct 1997 18:01:16 -0600
From: ads@websp.com
Subject: Performing Subroutines from a string of text
Message-Id: <875832678.25592@dejanews.com>
Does anyone know how to perform subroutines from a string of text? This
is what I am trying to do:
I have a string that is : delimited. For example:
text a b c:next text:some more text:RQCVF
The only thing I care about is the last field. What I want to do is have
some sort of if statement that (after doing a split -
($parta,$partb,$partc,$partd) = split /:/, $string;) checks to see what
letters are in $partd and then if there is a "R" it runs a certain
subroutine, if there is a Q it runs a different subroutine. I could have
26 different subroutines and any combination would run only the ones
specified. If I listed 1, it would only run the one subroutine it
corresponded to. If I had 26, it would do all 26. I hope this is clear.
Thanks for any help.
Please cc any responses, too.
Thanks,
Sidney Traynham
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Thu, 02 Oct 1997 15:38:21 -0600
From: Sarah Chase-Kruszewski <sarahck@planet.eon.net>
Subject: PERL 5.003 and the _STDC_ variable
Message-Id: <3434144D.5F129630@planet.eon.net>
Hi,
I have installed Perl 5.003 on my AIX machine. It runs just fine. Now
I'm adding the
CGI_pm, DBI-0.90 and DBD-Informix libraries. The DBD is the last thing
I'm installing and it claims that I need to compile Perl 5.003 such that
_STDC_ is defined. I can't see in
the Perl distribution where I'm supposed to define _STDC_.
Any help appreciated. (I've tried www.perl.com, all the README files
and so on).
Thanks,
Sarah
------------------------------
Date: Thu, 02 Oct 1997 18:02:10 -0600
From: david@barnworth.com
To: dbruyne@uia.ua.ac.be (Karel.DeBruyne)
Subject: re: perl modem access
Message-Id: <875832615.25516@dejanews.com>
Hi.
dbruyne@uia.ua.ac.be (Karel.DeBruyne) wrote:
>I've got a unix box (linux or solaris) with a modem.
>I want to have my perl-program send some string to the modem, to
>setup a dialout session. Than, I want to read from this modem to
>get the replies.
>
>How can I do this in perl ?
I am having the same trouble on my linux machine. Can't believe there's
nothing in any PERL documentation on simple serial communications.
I found the same "talk-to-modem.pl" script, but it did not run out of the
box. After modifying it a bit, I got it to send hayes commands, but I
still can't read from the modem. I'll keep playing with it, but there
must be someone out there who knows how to make this work!!!??
- David
--
#!/usr/bin/perl
$modem = "/dev/modem";
$number = "5551212"; # set to something that will ring
open(MODEM, "+>$modem") || die "Can't open $modem\n";
#system("stty -echo raw >/dev/cua0");# this line makes my machine hang
$out = "ATDT$number\r"; # let's try something simple
syswrite(MODEM,$out,length($out)); # could also do non-buffered "print"
sleep(10); # wait for modem to respond
sysread(MODEM, $in, 1000); # better than $i = <MODEM>
# since it gets all data at
# once, including extra newlines,
# but doesn't hang, like @i = <MODEM>;
print "($in)\n";
if ($in =~ /OK/ ) { # do this instead of $in eq "OK"
# because modem may send other junk
print "OK received\n";
} else {
print "OK NOT received\n";
}
close MODEM;
exit;
--
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Thu, 02 Oct 1997 15:50:23 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: problem with redirection
Message-Id: <3434090D.683F68EF@mail.uca.edu>
Good afternoon (evening, morning, whatever, wherever),
Using perl 5.004.03 (GS) for Win32 on a Win 95 Fastrack server and the
CGI.pm module, I cannot get redirection to work. I cannot find in any
documentation, FAQ's, etc. where this is not supported in this
configuration, but it sure doesn't seem to be (someone on the
..servers.mswindows newsgroup seems to have a similar problem, he/she
was attributing it to Fastrack). My script follows:
---------------beginning of script -----------------
#!/usr/bin/perl
#location test
use CGI qw(:standard);
$CGI::OS = 'WINDOWS';
#Location: 'http://spo.uca.edu';
#Location: http://spo.uca.edu;
#URI: http://spo.uca.edu;
#print $query->redirect(-uri=>'http://spo.uca.edu');
#print $query->redirect(-uri=>'http://spo.uca.edu',nph=>1);
------------ end of script ------------
Obviously, line 1 is irrelevant, since this is a Windows system.
Certainly, as the script is written here, no errors are found (well, it
doesn't do anything), but if any one of the redirection lines are
uncommented, the program crashes, whether from the command line or from
a browser. For browser input, the server error message is either:
"the CGI program C:\\PERL5004\\bin\\Perl.exe did not produce a valid
header (name without value: got line " (missing operator before
po?)")" for the Location and URI lines
or
"the CGI program C:\\PERL5004\\bin\\Perl.exe did not produce a valid
header (program terminated without a valid CGI header (check for core
dump or other abnormal termination)" for the redirect lines.
CGI.pm is in the same directory as the script, and works fine with other
scripts not involving redirection, so I tentatively have ruled that out
as a problem.
Any advice is most welcome.
Cameron Dorey
camerond@mail.uca.edu
------------------------------
Date: 2 Oct 1997 20:05:19 GMT
From: jefff@tiac.net (Jeff Fayne)
Subject: shell script
Message-Id: <610upv$325@news-central.tiac.net>
I am trying to write a perl script to run in my shell under
linux (perl version 5.003). Right now the only problem I have
is trying to send a control character to the shell. Here is the
senario:
telnet to an address
send ^] (to get to the telnet command prompt)
send quit
telnet to another address
Is there an easier way to quit from a telnet session without having to send
the ^]? If not, how can I send that character?
----------
Jeff Fayne
jefff@tiac.net
------------------------------
Date: 2 Oct 1997 21:06:56 GMT
From: Jeff Gostin <jgostin@shell2.ba.best.com>
Subject: Re: shell script
Message-Id: <6112dg$d8v$3@nntp1.ba.best.com>
Jeff Fayne <jefff@tiac.net> wrote:
: Is there an easier way to quit from a telnet session without having to send
: the ^]? If not, how can I send that character?
Actually, it may prove easier for you to use one of the Net::???? modules.
Take a look at CPAN (http://www.perl.org/CPAN) for details.
There are ways of doing what you want, but it's hackish. Basically, you'd
do something like this:
#!/usr/local/bin/perl5 -w
$sitename = "foo.bar.org";
open (TELNET_SESSION, "|telnet $sitename");
sleep(10);
print TELNET_SESSION "\c]"; #\c] == CTRL-];
sleep(1);
print TELNET_SESSION "close";
#that's all folks! :)
It's hackish, and doesn't allow for good "flow control" between the remote
end and the local end, but if you can't/won't/don't-want-to use a
Net::XXXXXX Module, then this'll have to do.
--Jeff
------------------------------
Date: 29 Sep 1997 12:44:35 +1000
From: greg@turing.une.edu.au (Greg Zevin)
Subject: Re: String Concat Acting Weird
Message-Id: <60n4mj$vlr@turing.une.edu.au>
rkjones@fas.harvard.edu (Raymon Jones) writes:
>Greetings,
>I'm having a strange problem with string concatenation, and wondered what
>in the $#(#$* I'm doing wrong.
>I'm working with the UnixDate function in the Date::Manip module. Here's
>the scoop . . .
>I'm trying to get back the current year and month from this function, so
>I've got something along the lines of:
>$curyear, $curmonth = &UnixDate($date, "%Y %m");
>This much seems to be working fine. But, if then go to concatenate the
>stuff, such that I can create a date string 09-01-1997 (so that I can call
>ParseDate with it), the concatenation is funny. I've been doing something
>like this:
>$firstday = $curmonth . '-01-' . $curyear;
>Then, when I print it out, instead of the 09-01-1997 that I expected, I
>get something more along the lines of:
>-01-1997 03
Well, it's obvious you're getting empty $curmonth and $curyear got
both month and year. It happened most likely 'cause you should have put
parens around: ($curyear, $curmonth) = &UnixDate($date, "%Y %m");
Hope this will help.
Greg
------------------------------
Date: 2 Oct 1997 19:26:13 GMT
From: chip@rio.atlantic.net (Chip Salzenberg)
Subject: Re: symbolic dereferencing of my() variables -- can it be done?
Message-Id: <610sgl$t33$1@news1.atlantic.net>
According to c.c.eiftj@78.usenet.us.com (Rahul Dhesi):
>In <Pine.GSO.3.96.970923075321.1200J-100000@usertest.teleport.com> Tom
>Phoenix <rootbeer@teleport.com> writes:
>>Rethink the way you're attacking the problem, and use (perhaps) a hash or
>>another technique instead. Every programming problem can be solved without
>>using eval STRING and without using soft references. Hope this helps!
>
>But it seems to make it even more ugly. Everywhere else in the code I
>simply used $a, $b, etc. With hashes I would replace every instance by
>$x{'a'}, $x{'b'}, etc. which is tedious and error-prone.
Well, you don't need the quotes.
But if you need variables in a hash, symbol tables are hashes! So
there is no reason not to just put the variables in a symbol table.
In other words: If my() hurts, then stop using my().
--
Chip Salzenberg - a.k.a. - <chip@pobox.com>
"He's Mr. Big of 'Big And Tall' fame." // MST3K
------------------------------
Date: 2 Oct 1997 19:18:56 GMT
From: chip@rio.atlantic.net (Chip Salzenberg)
Subject: Re: sysread() question
Message-Id: <610s30$sv8$1@news1.atlantic.net>
According to alex@kawo2.rwth-aachen.de (Trudno zhit' v derevne bez nagana.):
> my $bytes_read = sysread $SOCKET, $seq, 1; # line 43
> return 0 unless $bytes_read; # error or EOF
> my $bytes_to_read = $seq;
I think you mean ord($seq), to get the ASCII value as a number.
--
Chip Salzenberg - a.k.a. - <chip@pobox.com>
"He's Mr. Big of 'Big And Tall' fame." // MST3K
------------------------------
Date: 2 Oct 1997 23:18:46 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: usemymalloc
Message-Id: <611a4m$hoe@agate.berkeley.edu>
In article <610fo0$85i$1@nntp1.ba.best.com>,
Malcolm Hoar <malch@malch.com> wrote:
> I have a large Perl 5 program that is very stable on
> multiple operating systems with multiple versions of
> Perl 5.
>
> However, on a couple of systems, we have seen mucho
> weirdness.
>
> 1. One specific function gives the error:
>
> "Bad free() ignored at ....".
You need to fix this, unless it is DB_File. Berkeley DB has very buggy
allocation.
>
> 2. The other system does all kinds of weird stuff. I
> found a reproduceable example where we push items
> onto a list but, later on, when we come to shift
> them off, some of them have just disappeared :-(
"1" shows that your memory allocation algorithms are so buggy that
even simple-minded check can find them ;-). "2" may be related to
other bugs like the above one.
_Always_ use Perl's malloc, it will help you to find bugs in your
programs easier. Especially with -DDEBUGGING, which will try to find
memory overruns too.
Ilya
P.S. After the jumbo malloc patch Perl's malloc.c will not find bad
free()s for allocations less than 81 byte, unless DEBUGGING or you
specifically asked it to when you compile (but I do not remember the
#define offhand).
After all the optimization were put in, it was taking circa 2% of
footprint to have these checks enabled for smaller chunks, so I took it
off.
------------------------------
Date: 2 Oct 1997 18:55:45 GMT
From: chip@rio.atlantic.net (Chip Salzenberg)
Subject: Re: XS: sv_2mortal (when is it necessary?)
Message-Id: <610qnh$rt0$1@news1.atlantic.net>
According to ced@bcstec.ca.boeing.com (Charles DeRykus):
>I concluded from reading Sriram that function arguments
>passed on the stack need to be mortalized since they
>live and die in the scope of that one-liner when they're
>thrown on the stack.
More precisely, anything that lives _only_ on the stack needs to be
mortalized, because when things are removed from the stack their
refcounts aren't decremented, and the decrement has to happen or there
will be memory leaks.
--
Chip Salzenberg - a.k.a. - <chip@pobox.com>
"He's Mr. Big of 'Big And Tall' fame." // MST3K
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 1117
**************************************