[9158] in Perl-Users-Digest
Perl-Users Digest, Issue: 2776 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 1 08:08:03 1998
Date: Mon, 1 Jun 98 05:01:16 -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 Mon, 1 Jun 1998 Volume: 8 Number: 2776
Today's topics:
Re: alternation, grouping, and backreferences (Ronald J Kimball)
Re: Any kind of help is hard to find. <quednauf@nortel.co.uk>
Re: c.l.p.misc is `perl support' (was Re: O'Reilly has (Ronald J Kimball)
Re: Converting 31.12.1998 -> 12/31/1998 (Stefan Scholl)
Re: Email address checker - comments welcome (Ronald J Kimball)
Re: Email address checking (Ronald J Kimball)
Re: file output and modules (Jonathan Stowe)
Help with pipes, bidirectional communication (John Sandstrom)
Re: HELP::Comparing strings <carton.lao@shaw.wave.ca>
Re: How do I tell if Perl is in foreground or backgound (Charlie Stross)
I get no errors, but I get no Sys::Syslog(ing)... (T Perkins)
Re: Internet Relay Chat (Chris Nandor)
Re: LABOR CRISIS: Perl SW Guru NEEDED MA Intranet Start (Ronald J Kimball)
Re: LABOR CRISIS: Perl SW Guru NEEDED MA Intranet Start <ebohlman@netcom.com>
Re: location of archive <quentin@shaddam.amd.com>
Re: More double standards out of the FSF <peterm@zeta.org.au>
Re: More double standards out of the FSF <hp@pobox.com>
Re: Non-greedy regexp still eatting all the pies! (Ronald J Kimball)
Re: Perl + CGI (Jonathan Stowe)
Re: Perl 5.005_xxx (Ronald J Kimball)
Re: perl for windows 3.1? <chris.wareham@blackwell.co.uk>
Perl Scripts <rocka@infoserve.net>
Re: Perl Scripts <Dave.Cross@gb.swissbank.com>
Re: reading variable lists <sdh1@anchor.hotmail.com>
Re: reading variable lists (Jonathan Stowe)
Re: Reading whole file into a scalar mike808@my-dejanews.com
Re: Reading whole file into a scalar (Charlie Stross)
Re: seek advice on simple first program (Ronald J Kimball)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 27 May 1998 00:19:18 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: alternation, grouping, and backreferences
Message-Id: <1d9nrrq.xx4fyk1l0i898N@bay2-63.quincy.ziplink.net>
David Boyce <David.Boyce@fmr.com> wrote:
> I'm really trying to find out (a) where this
> behavior is documented (did I miss it?) and (b) is it considered a
> feature and why? Because it seems more intuitive to me that whichever
> pattern matches in this case would assign to $1.
>From perlre:
When the bracketing construct ( ... ) is used, \<digit> matches
the digit'th substring.
>From Programming Perl (2ed, p 65):
...Pairs of parentheses are numbered by counting left parentheses
from the left.
In other words, $1 corresponds to the first (), $2 to the second (), and
so on. Why would it be any other way?
It's not a feature, so much as standard implementation. As far as I
know, every language with capturing parentheses works that way.
Consider the following with your method in mind:
'1 2 3 5' =~ /(1 (2) (3) |(4) )(5)/;
$1 = '1 2 3 '
$2 = '2'
$3 = '3'
$4 = '5'
'4 5' =~ /(1 (2) (3) |(4) )(5)/;
$1 = '4 '
$2 = '4'
$3 = '5'
Note how '5' ends up in a different variable depending on which
alternative matches.
Perhaps you wanted to use $+, which contains whatever the last bracket
match matched.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Mon, 01 Jun 1998 09:56:16 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: Any kind of help is hard to find.
Message-Id: <35726CB0.6B4F6DDC@nortel.co.uk>
There we go again (Imagine hard Hip Hop beats spiced up with the sound of
my hardDisk when NT4 is leaking all over the place again):
Michael Dori wrote:
> I have noticed that all the help that is proffered on most questions,
> especially from new users, is usually returned in the form of "LOOK IT
> UP".
I find it amazing that people's experiences can differ so widely when
dealing with the same group. But then Newsgroups are just an (useful)
extension of society, and therefore everyone perceives the services
provided, etc. completely different. Also quite redundant to discuss
about. So a solution would be to say, e.g. "I still can't manage to embed
Perl in my toaster, however I LOOKED into the FAQ..." A potential replier
would then KNOW that you looked for it, and, if that person already
embedded Perl into the toaster (he / she? are there any shes? surely
already did), will most certainly help you (That's the feeling I've got
in this newsgroups anyway)...So I suppose that in future I will state
myself which resources I already used.
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: Thu, 28 May 1998 00:39:34 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: c.l.p.misc is `perl support' (was Re: O'Reilly has helped promote the acceptance of Perl)
Message-Id: <1d9poqw.1iut3dejuqjk0N@bay1-535.quincy.ziplink.net>
Russell Schulz <Russell_Schulz@locutus.ofB.ORG> wrote:
> it seems `mightly clear' to me that the readers of c.l.p.misc do
> NOT want to be `perl support', except for particularly interesting
> problems.
That's because we've already answered the uninteresting problems over
and over again. Hence the FAQ.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 1 Jun 1998 10:27:28 GMT
From: stesch@parsec.inka.de (Stefan Scholl)
Subject: Re: Converting 31.12.1998 -> 12/31/1998
Message-Id: <slrn6n50gg.oe.stesch@parsec.inka.de>
On Thu, 1998-05-28 15:21:22+02, ak <ak@informatik.tu-cottbus.de> wrote:
> I want to convert european dates to american dates. Has anyone a
Why not convert them to an international date?
(ISO 8601)
------------------------------
Date: Thu, 28 May 1998 00:39:30 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Email address checker - comments welcome
Message-Id: <1d9po78.oojhdezezvg0N@bay1-535.quincy.ziplink.net>
Larry Rosler <lr@hpl.hp.com> wrote:
> /^ [^\s@?]+ @ (?: \w[^\s.]* \. )+ \w\w+ $/x
DB<1> $re = '^ [^\s@?]+ @ (?: \w[^\s.]* \. )+ \w\w+ $'
DB<2> p 'invalid@address@foo.bar' =~ /$re/x
1
DB<3> p 'also@invalid.__' =~ /$re/x
1
Bzzt! Thank you for playing.
Please refer to Appendix B of Mastering Regular Expressions, by Jeffrey
Friedl.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Fri, 29 May 1998 22:34:50 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Email address checking
Message-Id: <1d9t8sx.1b5xgs71hqv4kuN@bay1-195.quincy.ziplink.net>
Craig Berry <cberry@cinenet.net> wrote:
> Conversely, the regex /\w+\@\w+\.\w+/ will not match any invalid internet
> addresses
It won't???
invalid@address.__
this is not a valid@email.address
a@b.1234567890
See, this is tricky even for people who are aware of all the
difficulties.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Mon, 01 Jun 1998 06:57:22 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: file output and modules
Message-Id: <357244c3.3822065@news.btinternet.com>
On 31 May 1998 03:31:48 GMT, Chris Schafer wrote :
>Two questions....
>
>What is the search path for modules and libs in perl on a unix box. I am using the
>perl distribution which IBM distributes with AIX on the SP and cannot load
>modules correctly. Is this searching a env variable? Do I have to tell it
>where they are located?
>
You need to print out the @INC array to determine where perl is
looking for modules. If you find that the modules are in a place that
perl is not looking at then you will have to add this path to @INC
probably something like this:
use lib '/usr/local/lib/perl5';
for example.
If this causing you a great problem you might need to recompile perl.
>also
>
>I have been attempting to do output to a file. I do the output close the
>file and then want to `cat $filename | mail $username` this appears to work
>but the file is empty. Then the program ends and I check the file and the
>data is there? I have also tried to simply read the file after I close it
>and it comes up blank as well. I have tried making the program wait several
>minutes and still no data. It appears the writes are not occuring till the
>program ends. But I am not even getting the data that was in the file
>before the program ran. I want to try and use the FILEHANDLE->autoflush(1);
>but due to the first problem I am stuck. Any advice would be most
>appreciated.
>
If you set $| (aka $OUTPUT_AUTOFLUSH) to some non zero value then that
will flush after every write to the selected file handle. eg:
open(TEST,">testfile") || die;
select TEST
$| = 1;
print "This is a test";
select STDOUT;
$| = 0;
close TEST;
You dont however have to do 'cat $filename | mail' - you can open a
pipe to mail right there in your own program like:
open(MAIL" | /usr/bin/mail") || die;
print MAIL, "this is a test";
close( MAIL) || die "Error with mail";
One less external program to spawn and no temporary file.
>Thanks
>Chris
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Mon, 01 Jun 1998 09:35:21 GMT
From: revok@aol.com (John Sandstrom)
Subject: Help with pipes, bidirectional communication
Message-Id: <6kts8a$7qs@bgtnsc02.worldnet.att.net>
I wrote a simple program to read a uuencoded file, pipe it to a C
executable, then pipe the result back to a scalar var. To my
amazement, it seemed worked the first time, except when I viewed the
resulting JPG, several lines of pixels were missing from the bottom. I
know the decode program is working properly because typing the
commands directly into the command line (cat ./base64.uue | ./decode
>test1.jpg) gives me a complete file (giving me a file size of 48814,
rather than the 45056 perl version). Setting binmode makes no
difference (as it shouldn't in UNIX). setting $| all over the place
doesn't help.
I'm also curious why this program creates a huge file called
decode.core.
This has been driving me nuts for two days, killing my weekend. If I'm
forgetting something obvious, I deserve every flame I get.
#!/usr/local/bin/perl -w
use IPC::Open2;
use FileHandle;
use Symbol;
# use diagnostics;
open(uue,"< ./base64.uue") || die "can't open\n";
read(uue, $bsf,137918);
close(uue);
($RDR,$WTR) = FileHandle::pipe;
$pid = open2($RDR,$WTR,'./decode');
$WTR->autoflush();
print $WTR $bsf;
close($WTR);
# this doesn't work either
# while (<$RDR>){
# $jpe .= "$_";
# }
$RDR->read($JPE,60000);
close($RDR);
open(IDX,">test1.jpg") || die "Can't open (-i) test1.jpg:
$!\n";
print IDX "$JPE";
close(IDX);
-------------------------------------------
John Sandstrom
------------------------------
Date: Mon, 01 Jun 1998 03:08:00 GMT
From: Carton Lao <carton.lao@shaw.wave.ca>
To: Johan Priwshy <Centollo@iname.com>
Subject: Re: HELP::Comparing strings
Message-Id: <35721BD0.3E07794C@shaw.wave.ca>
stringwise equality compare is 'eq'.
if ($str1 eq $str2) in your case will not be true.
perlop contains information on all the perl operators.
Carton
Johan Priwshy wrote:
> Hi there. I've a little problem comparing strings.
> let's say we have these two variables:
> $str1 = "test";
> $str2 = "test";
>
> and let's say we can compare them within an if statement:
> if ($str1 == $str2) {
> bla bla
> }
>
> I've found THIS DOESN'T work!!
> let's have a look to this piece of code:
> print "$row[0] \n";
> print "$password \n";
> if ($row[0] == $password) {
> print "\n\n the password DO match!!";
> }
>
> and let's see what it outputs:
> > brasil
> > monkey
> > the password DO match!!
>
> What the hell am I doing wrong??
> can you please help me??? Thanks in advance
>
> please. reply also to <rasta at hehe dot com>
> sam.
------------------------------
Date: Mon, 01 Jun 1998 11:43:42 GMT
From: charlie@antipope.org (Charlie Stross)
Subject: Re: How do I tell if Perl is in foreground or backgound?
Message-Id: <slrn6n555j.qq4.charlie@cs.ed.datacash.com>
In the name of Kibo the Compassionate, the Merciful,
on Sat, 30 May 1998 22:12:56 -0400, Robert Dorfman
the supplicant <dorfmanr@netlabs.net> inscribed:
>
> ... How can I tell if my script is running in foreground or
>background? Also, would running in the background be different from
>being started by cron?
Not sure if there's any canonical way of telling the difference, but you
should be able to figure out your parent process's PID and, from that,
figure out if your process was spawned by crond or a shell.
You might also want to look at open filehandles (STDIN being connected
to /dev/tty is usually a bit of a giveaway ;-).
In event of _real_ doubt and confusion (say you've renamed /bin/bash to
/usr/sbin/crond for some very good reason :), you could try setting an
alarm for ten seconds, trap the ALRM signal, and in the meantime print
"hello, are you there? press any key ..." to STDOUT. If the alarm
throws you into whatever sub you hung off $SIG{ALRM}, it's a fair bet
that nobody saw the message and pressed the 'any' key; otherwise, if a
key was pressed, you've got hard evidence that somebody's watching.
-- Charlie
------------------------------
Date: 1 Jun 1998 05:59:25 GMT
From: 3c9x5.remove@altabates.com (T Perkins)
Subject: I get no errors, but I get no Sys::Syslog(ing)...
Message-Id: <6ktfvt$r2a$1@aegis.altabates.com>
I know the syslog daemon is OK 'cuz at the shell things are fine:
logger -p user.notice 'Narf'
tail /var/log/messages
>May 31 22:16:53 MyHost root: Narf
In perl however, all is quiet. Here's my script:
#!/usr/bin/perl
use Sys::Syslog;
use File::Basename;
openlog(basename($0),'ndelay,pid','user');
syslog('notice','Narf');
closelog();
exit(1);
TIA
--
__o
_(\<._ Tor Perkins, Alta Bates Medical Center
(_)/ (_) 3c9x5@altabates.remove.com (lose the '.remove' to reply...)
------------------------------
Date: Mon, 01 Jun 1998 11:36:26 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Internet Relay Chat
Message-Id: <pudge-0106980730470001@192.168.0.3>
In article <6ksii0$92e$1@lennon.postino.com>, danny@lennon.postino.com
(Danny Aldham) wrote:
# Chris Nandor (pudge@pobox.com) wrote:
# : Net::IRC is a good module, but Perl does not run inside the browser. You
# : need to grasp the reality that HTML and HTTP are not suited to this task,
# : and that some other program needs to do it. It just so happens that you
# : can make a program run embedded in a web page, but only Java is really
# : suited to the task at this time.
#
# What ever happened to Penguin and the idea of downloading perl code
# to run via the browser? And with the release of Netscape source code,
# has anyone considered putting a perl virtual machine into it?
I don't know what is up with Penguin (all I know is that it has been
stagnant on CPAN for a year), but it certainly is possible to do it, and
there has been talk of it. But all I have heard is talk.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Thu, 28 May 1998 00:39:36 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: LABOR CRISIS: Perl SW Guru NEEDED MA Intranet Start-up 80K+>+Equity
Message-Id: <1d9ppod.rrkz659qbel7N@bay1-535.quincy.ziplink.net>
[newsgroup distribution adjusted]
John Chambers <jc@ral1.zko.dec.com> wrote:
> a much more credible explanation is that the employers are making up fake
> requirements and fake shortages as a technique of keeping pay scales low.
Wouldn't a labor shortage result in higher pay scales?
high demand and low supply equals high prices
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Mon, 1 Jun 1998 11:39:21 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: LABOR CRISIS: Perl SW Guru NEEDED MA Intranet Start-up 80K+>+Equity
Message-Id: <ebohlmanEtvF1L.5nA@netcom.com>
Ronald J Kimball <rjk@coos.dartmouth.edu> wrote:
: [newsgroup distribution adjusted]
: John Chambers <jc@ral1.zko.dec.com> wrote:
: > a much more credible explanation is that the employers are making up fake
: > requirements and fake shortages as a technique of keeping pay scales low.
: Wouldn't a labor shortage result in higher pay scales?
: high demand and low supply equals high prices
If the supply remains low, certainly. But the alleged software labor
shortage is usually invoked to justify
1) Relaxation of restrictions on hiring foreign nationals
and
2) Increasing the number of CS graduates
Both of which would increase the supply of programmers who would be
willing to work for a low cost to the employer. A recent grad is cheaper
than a 15-year veteran (and remember that in the US where health
insurance is normally handled as an employee benefit, a younger workforce
means lower premiums). Foreign nationals are usually legally tied to a
particular employer for a few years, so the employer doesn't have to
worry about matching offers from other companies trying to hire them away.
------------------------------
Date: 31 May 1998 22:35:07 -0500
From: Quentin Fennessy <quentin@shaddam.amd.com>
Subject: Re: location of archive
Message-Id: <ximsolpaj6c.fsf@shaddam.amd.com>
>>>>> "tom" == tom arnall <kloro@erols.com> writes:
tom> where is the location of the archive for this newsgroup? --
www.dejanews.com
--
Quentin Fennessy AMD, Austin Texas
Secret hacker rule #11 - hackers read manuals
------------------------------
Date: Sun, 31 May 1998 22:50:40 +0000
From: "Peter G. Martin" <peterm@zeta.org.au>
Subject: Re: More double standards out of the FSF
Message-Id: <3571DEC0.57A491DA@zeta.org.au>
Thomas Bushnell, n/BSG wrote:
>
> Anselm Lingnau <lingnau@tm.informatik.uni-frankfurt.de> writes:
>
> > You could presumably always ask Tom to give you special permission to
> > include perlfaq. If your project is commercial, he may want to have a
> > cut of the profit, which under the circumstances seems only fair. If
> > your project doesn't involve money, chances are he'll let you use his
> > stuff even so, if you say it's his originally.
>
> If I need to ask permission, then the manual isn't free in the FSF
> sense. Tom says he's been quite liberal in giving permission, which
> is a nice thing. But being given permission is not the same thing as
> freedom, and the FSF wants free documentation--specificall
> documentation free of the need to ask permission to distribute or
> modify.
In other words:
My freedom is better than your freedom.
I am holier than thou.
Your god might be +like+ mine, but mine's better, anyway, naah naaah
!
Or the cost of being polite to someone giving something away 'gratis'
is far too much to pay...
--
peterm
Peter G. Martin, Tech.Writer & Perl User, The Scribe & Chutney Trust
peterm@zeta.org.au, http://www.zeta.org.au/~peterm
ROZELLE, Australia +61 2 9818 5094
------------------------------
Date: Mon, 1 Jun 1998 06:01:56 GMT
From: robert havoc pennington <hp@pobox.com>
Subject: Re: More double standards out of the FSF
Message-Id: <wsnpvgtr76z.fsf@harper.uchicago.edu>
"Peter G. Martin" <peterm@zeta.org.au> writes:
>
> Thomas Bushnell, n/BSG wrote:
> >
> > If I need to ask permission, then the manual isn't free in the FSF
> > sense. Tom says he's been quite liberal in giving permission, which
> > is a nice thing. But being given permission is not the same thing as
> > freedom, and the FSF wants free documentation--specificall
> > documentation free of the need to ask permission to distribute or
> > modify.
>
> In other words:
>
> My freedom is better than your freedom.
>
> I am holier than thou.
>
> Your god might be +like+ mine, but mine's better, anyway, naah naaah
> !
>
No one is saying this. Re-read the quote, it has none of the tone
you're perceiving, IMO.
Havoc Pennington ==== http://pobox.com/~hp
------------------------------
Date: Mon, 25 May 1998 12:30:11 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Non-greedy regexp still eatting all the pies!
Message-Id: <1d9l32k.bi9cpe101xqtcN@bay1-214.quincy.ziplink.net>
[posted and mailed]
Glenn Morgan <gmorgan@photographics.co.uk> wrote:
>
I think this would be easier if you didn't do it in a single
substitution. First find '<tbl ...>...</tbl>'. Then see if '<cross-ref
...>...</cross-ref>' comes next. If so, swap them.
# Note that none of your examples show $3 including '</cross-ref>',
# while according to the regexes you gave I think it should.
You could use /g and pos to help some, but you need to know where the
matches begin, not just where they end.
How about this:
$text = <<EOT;
Some text<cross-ref refid="tbl1">Table 1</cross-ref><tbl
id="tbl1"><tblbdy><r><c>text</tblbdy></tbl>A line of text between two
table elements<cross-ref refid="tbl2">Table 2</cross-ref><tbl
id="tbl2"><tblbdy><r><c>text</tblbdy></tbl><cross-ref refid="tbl3">Table
3</cross-ref><tbl id="tbl3"><tblbdy><r><c>text</tblbdy></tbl>Some more
text
EOT
@text = split m{(<tbl\s.*?</tbl>|<cross-ref\s.*?</cross-ref>)}, $text;
for ($i=1; $i<=$#text; ++$i) {
if ($text[$i] =~ /^<cross-ref / and
$text[$i-1] =~ m{</tbl>$}) {
($text[$i], $text[$i-1]) = ($text[$i-1], $text[$i]);
}
}
$text = join '', @text;
print $text;
> If I could say something like this
>
> s/(.*)(<tbl [^(?:<\/tbl>)]+<\/tbl>)(<cross-ref
> refid=\"tbl.+?<\/cross-ref>)(<tbl .+?>)/$1$3$2$4/;
>
> and [^(?:<\/tbl>)] had a match width of a single character it would work.
> What exactly does happen when you try use a regexp containing a pattern like
> that (different question, I know)?
That will match any character which is not one of '()/:<>?blt'. The set
of regex metacharacters is very different from the set of character
class metacharacters.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Mon, 01 Jun 1998 06:57:24 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Perl + CGI
Message-Id: <35724946.4798083@news.btinternet.com>
On Sun, 31 May 1998 22:34:19 GMT, Jeff Yoak wrote :
>[posted and emailed]
>
>ryelah@axess.net (ryelah) wrote:
>
>>I'm using Perl for some CGI programming. I was told that you can't use the
>>DIE function in CGI scripts because the browser doesn't know what to do with
>>it?
<snip>
>
>You could look into the documentation for the Carp module for one way
To avoid confusion that should be CGI::Carp
>to handle this problem. I would also strongly suggest an article by
>brian d foy in the most recent Perl Journal ( http://www.tpj.com/ ) in
>which he covers Carp and some other related methods and issues.
Second time i've been pointed at this article - I'll have to get that
subscription together.
At the risk of getting boring you can also do something like:
>From Randal Schwartz:
$SIG{'__DIE__'} = $SIG{'__WARN__'} = sub {
my $error = shift;
chomp $error;
$error =~ s/[<&>]/"&#".ord($&).";"/ge; # entity escape;
print "Content-type: text/html\n\n[$error]\n";
exit 0;
};
>From Larry Rosler:
$SIG{'__DIE__'} = $SIG{'__WARN__'} = sub {
print "Content-type: text/plain\n\n", shift;
exit 0;
};
These handlers will print out the error message to the browser. They
assume that no output has occurred at the time of death (thus the
"Content-type\n\n" ). You could of course make the output a little
more elegant.
/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Mon, 25 May 1998 22:58:24 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Perl 5.005_xxx
Message-Id: <1d9lx04.7lz15u1ln7xcgN@bay1-139.quincy.ziplink.net>
Lloyd Zusman <ljz@asfast.com> wrote:
> But the person asking for the location of the Perl beta was almost
> certainly not a "newbie". He or she may very well have been *assumed*
> to be one without any indication of this except perhaps through some
> sort of sixth sense, but that doesn't make it so.
In which case, he or she should have no problem finding the beta version
of Perl. It's a simple test. If you can find the beta version on your
own, you can use it. If you can't find the beta version on your own,
you shouldn't use it.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Mon, 01 Jun 1998 10:07:07 GMT
From: Chris Wareham <chris.wareham@blackwell.co.uk>
Subject: Re: perl for windows 3.1?
Message-Id: <35727DD1.48761435@blackwell.co.uk>
michael tessman wrote:
>
> i'm very new to perl and am wondering if it is available somewhere for
> win 3.1
>
> thanks much...
>
> mike tessman
> mtessman@erols.com
If you look in CPAN I recall seeing a version of Perl 5 for DOS. Look under
the ports subdirectory. I think full blown Perl support for Win3.1/DOS ended
with Perl 4.036 - but then I'm a Unix weenie so what do I know?
--
=======================
"It said Windows 95
Windows NT or better on
the box, so Linux must
be supported."
=======================
------------------------------
Date: Sun, 31 May 1998 22:35:42 -0700
From: "Steven Roka" <rocka@infoserve.net>
Subject: Perl Scripts
Message-Id: <6ktem6$1ep$1@pugsley.tor.metronet.ca>
I am new at this and would like to find a perl scripts library (ie i don't
understand the technical stuff), or even better a script that will email me
information filled in a form on a web page.
Steve
------------------------------
Date: Mon, 1 Jun 1998 08:34:56 GMT
From: David Cross-cmt <Dave.Cross@gb.swissbank.com>
Subject: Re: Perl Scripts
Message-Id: <eq0n2bxa5an.fsf@gb.swissbank.com>
"Steven Roka" <rocka@infoserve.net> writes:
[groups trimmed, followups set]
> I am new at this and would like to find a perl scripts library (ie i don't
> understand the technical stuff), or even better a script that will email me
> information filled in a form on a web page.
Steve,
I've started an archive of CGI scripts, and it currently includes a
form mail script. You can find it at:
<http://www.mag-sol.com/>
Let me know how you do with it.
Dave...
--
If I wasn't so busy writing status reports,
my status report might just become a progress report.
Dave.Cross@gb.swissbank.com
------------------------------
Date: Sun, 31 May 1998 23:32:54 -0400
From: "Scott" <sdh1@anchor.hotmail.com>
Subject: Re: reading variable lists
Message-Id: <6kt7j9$g64$1@camel19.mindspring.com>
Aaron wrote in message <3571EB4F.4C98@pornoinferno.com>...
>Dear knowledgable and 'glad to help' programmer,
>
>I have the following:
>------------------------------------------------
>#!/usr/local/bin/perl
>
>$url='http://www.tyc.net/test.html';
>
> print "Content-type: text/html\n\n";
>
>if ($ENV{'HTTP_REFERER'} eq "$url") {
> print "<h1>You have succeeded</h1>";
>}
>else {
> print "<h4><center>Sorry, you can not access this ";
> print "page from $ENV{'HTTP_REFERER'}</center></h4>";
>}
>------------------------------------------------
Hows about:
$i=0;
$found=false;
while (test = $urllist[$i++])
{
$url ne $test || $found = true;
}
if ($found)
{
print "You've succeeded\n";
}
else
{
print "You're an unacceptable loser\n";
}
I have a feeling you can put the innerds of the while loop inside the test
area, but this way
is probably easier to read.
------------------------------
Date: Mon, 01 Jun 1998 06:57:18 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: reading variable lists
Message-Id: <3572393c.1355274@news.btinternet.com>
On Sun, 31 May 1998 23:43:41 GMT, Aaron wrote :
>Dear knowledgable and 'glad to help' programmer,
>
Flattery will get you nowhere ;-}
>I have the following:
>------------------------------------------------
>#!/usr/local/bin/perl
>
>$url='http://www.tyc.net/test.html';
>
> print "Content-type: text/html\n\n";
>
>if ($ENV{'HTTP_REFERER'} eq "$url") {
> print "<h1>You have succeeded</h1>";
>}
>else {
> print "<h4><center>Sorry, you can not access this ";
> print "page from $ENV{'HTTP_REFERER'}</center></h4>";
>}
>------------------------------------------------
>
>I now want to check $url against a list of urls in a seperate file
>rather than simply state a static variable such as
>$url='http://www.tyc.net/test.html'; .
>
You could try something like this:
#!/usr/bin/perl
open(URLIST,"url_list") || die " Cant open URL List - $!\n";
$got_url = 0;
while(<URLIST>)
{
chomp;
if($_ eq $ENV{HTTP_REFERER})
{
$got_url = 1;
last;
}
}
close(URLIST);
print "Content-type: text/html\n\n";
if ($got_url) {
print "<h1>You have succeeded</h1>";
}
else {
print "<h4><center>Sorry, you can not access this ";
print "page from $ENV{'HTTP_REFERER'}</center></h4>";
}
/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Mon, 01 Jun 1998 05:34:05 GMT
From: mike808@my-dejanews.com
Subject: Re: Reading whole file into a scalar
Message-Id: <6ktegd$tn0$1@nnrp1.dejanews.com>
In article <6krocl$gch$1@csnews.cs.colorado.edu>,
tchrist@mox.perl.com (Tom Christiansen) wrote:
> In comp.lang.perl.misc, mike808@my-dejanews.com writes:
> :Randal, I thought the whole purpose of the "local" construct was to RETAIN
> :the value from the enclosing scope in a "localized" _copy_ of the value.
> No, you're confused. You're thinking of
> local $x = $x;
> :Why on earth would it undef the variable?
> Because that's the rule.
Yes, Tom, I should have read the manual. perlsub sez it all.
I am humbled.
> :$/ is a perl "global" intialized during
> :perl startup. It is _not_ "undef" by default when "declared", as it has
> :already been declared, in effect, by the time our scripts start.
> Congratualations, you have managed to misunderstand local() in a way
> I've not seen before.
And you, sir, have managed to spell "congratulations" in a way I have not
seen before from such an erudite man. :)
> :TMTOWTDI. Personally, I use: local $/ = undef; to keep it on one line, but
> That's superstition.
No it's not superstition. It's clear, concise, and doesn't confuse the reader
with the additional burden of ignoring excess whitespace. I don't know about
you, but I'd rather debug / maintain code that fits on a page or two than the
same code awash in a sea of whitespace that I spend more time paging around
the code than maintaining / debugging it.
> Speculation and doubt should not enter into the matter.
> Empirical evidence should.
sub slurp
{
use Carp;
my $filename = shift or croak "Missing filename";
local $/;
open(*FOO, "<$filename") or croak "Could not open '$filename'";
my $content = <FOO>;
close(FOO) or croak "Could not close '$filename'";
$content;
}
works for me every time. Empirical enough?
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Mon, 01 Jun 1998 11:03:20 GMT
From: charlie@antipope.org (Charlie Stross)
Subject: Re: Reading whole file into a scalar
Message-Id: <slrn6n52ps.qq4.charlie@cs.ed.datacash.com>
In the name of Kibo the Compassionate, the Merciful,
on 30 May 1998 02:05:58 GMT, Shaun Sides
the supplicant <arch@abts.net> inscribed:
>I don't think you can read a file into a scalar. There's a variable $\
>which contains the record separator. The default value for this is \n,
>and changing that value isn't recommended.
Um ...
my ($foo) = join($\, (<STDIN>));
... works for me. (Not recommended, though -- at least, not without
doing a stat() on the file we're reading in first, to make sure it
isn't a raw filesystem or /dev/zero or something ;-)
-- Charlie
------------------------------
Date: Fri, 29 May 1998 22:34:53 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: seek advice on simple first program
Message-Id: <1d9t9sh.1fqnb7rme4728N@bay1-195.quincy.ziplink.net>
[posted and mailed]
Shaun Sides <arch@abts.net> wrote:
> # Program to take single spaced text files and add an
> # extra \n to the end of each line.
perl -pi -e 'print "$_\n"'
Or, in a file:
#/usr/local/bin/perl -pi
print "$_\n";
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
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 2776
**************************************