[16916] in Perl-Users-Digest
Perl-Users Digest, Issue: 4328 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 15 00:06:49 2000
Date: Thu, 14 Sep 2000 21:05:14 -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: <968990713-v9-i4328@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 14 Sep 2000 Volume: 9 Number: 4328
Today's topics:
Re: can i run a cgi script within javascript tag? <drclue@drclue.net>
Re: can i run a cgi script within javascript tag? (Tony L. Svanstrom)
Re: can i run a cgi script within javascript tag? <drclue@drclue.net>
Re: format @<<< <rick.delaney@home.com>
Re: Getting started w/ Perl <hstone@netdirect.net>
Re: golf (Was Re: transliterating file names in a dir) <rick.delaney@home.com>
Re: golf (Was Re: transliterating file names in a dir) (Abigail)
Re: golf (Was Re: transliterating file names in a dir) <stephenk@cc.gatech.edu>
Re: Help in RegExp to highlight keyword in HTML file (Robert Hallgren)
Re: Help in RegExp to highlight keyword in HTML file (Abigail)
help regarding split <yingying3@peoplepc.com>
Re: help regarding split (Mike Stok)
Re: help regarding split (Robert Hallgren)
Re: Is there a good freeware/shareware IDE for PERL? (Abigail)
Re: Is there a good freeware/shareware IDE for PERL? (Tony L. Svanstrom)
Re: killfiles? scores? I wish I had these luxuries <hstone@netdirect.net>
Re: print and CGI scripts (Gwyn Judd)
Re: print and CGI scripts <david.obrien@ssmb.com.au>
Re: print and CGI scripts <uri@sysarch.com>
Re: print and CGI scripts <david.obrien@ssmb.com.au>
Re: print and CGI scripts <uri@sysarch.com>
Re: Req.: The perfect Perl Editor? (Gwyn Judd)
Shortest code for Fibonacci? <cmc77@pantheon.yale.edu>
Re: Silly grep tricks (Abigail)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 14 Sep 2000 19:25:55 -0700
From: ".." <drclue@drclue.net>
Subject: Re: can i run a cgi script within javascript tag?
Message-Id: <39C188B3.D3855BE9@drclue.net>
klidge wrote:
>
> I would like to ask you if it's possible for a cgi script written in perl
> to run from within a javascript script
> example:
> Html source:
> <script language="javascript">
> --the code i need here---
> </script>
> In order for the "result" after accessing the page would be the same as the
> htm source was:
> <script language="javascript">
> document.write('this line has been generated from a cgi perl script');
> </script>
>
> thank you in advance
Sortof.
You could declare an ILAYER inside a DIV , then if IE is detected
overwrite the contents of the DIV with an IFRAME.
Now you can create a request in the IFRAME/ILAYER that represents
a request to your server side javascript , which would in turn , output
javascript to update the interaction
--
--=<> Dr. Clue (A.K.A. Ian A. Storms) <>=--
--=<[]>=- http://www.drclue.net
--=<[]>=- C++ HTML JavaScript DHTML CGI TCP/IP SQL JAVA VRML NSAPI
--=<[]>=- http://www.drclue.net/F1.cgi/HTML/HTML.html (My famous
HTML/CGI guide.)
------------------------------
Date: Fri, 15 Sep 2000 04:29:59 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: can i run a cgi script within javascript tag?
Message-Id: <1egzggo.1d40lem1zg29kN%tony@svanstrom.com>
.. <drclue@drclue.net> wrote:
> klidge wrote:
> >
> > I would like to ask you if it's possible for a cgi script written in perl
> > to run from within a javascript script
> > example:
> > Html source:
> > <script language="javascript">
> > --the code i need here---
> > </script>
> > In order for the "result" after accessing the page would be the same as the
> > htm source was:
> > <script language="javascript">
> > document.write('this line has been generated from a cgi perl script');
> > </script>
> >
> > thank you in advance
>
> Sortof.
>
> You could declare an ILAYER inside a DIV , then if IE is detected
> overwrite the contents of the DIV with an IFRAME.
>
> Now you can create a request in the IFRAME/ILAYER that represents
> a request to your server side javascript , which would in turn , output
> javascript to update the interaction
Nah, iframe doesn't have to be used, if you are going to use a
SCRIPT-tag then simply add a src to it and get the result of the
Perl-script that way.
/Tony
--
/\___/\ Who would you like to read your messages today? /\___/\
\_@ @_/ Protect your privacy: <http://www.pgpi.com/> \_@ @_/
--oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
on the verge of frenzy - i think my mask of sanity is about to slip
---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
\O/ \O/ ©99-00 <http://www.svanstrom.com/?ref=news> \O/ \O/
------------------------------
Date: Thu, 14 Sep 2000 20:47:23 -0700
From: ".." <drclue@drclue.net>
Subject: Re: can i run a cgi script within javascript tag?
Message-Id: <39C19BCB.1E629EAE@drclue.net>
"Tony L. Svanstrom" wrote:
>
> .. <drclue@drclue.net> wrote:
>
> > klidge wrote:
> > >
> > > I would like to ask you if it's possible for a cgi script written in perl
> > > to run from within a javascript script
> > > example:
> > > Html source:
> > > <script language="javascript">
> > > --the code i need here---
> > > </script>
> > > In order for the "result" after accessing the page would be the same as the
> > > htm source was:
> > > <script language="javascript">
> > > document.write('this line has been generated from a cgi perl script');
> > > </script>
> > >
> > > thank you in advance
> >
> > Sortof.
> >
> > You could declare an ILAYER inside a DIV , then if IE is detected
> > overwrite the contents of the DIV with an IFRAME.
> >
> > Now you can create a request in the IFRAME/ILAYER that represents
> > a request to your server side javascript , which would in turn , output
> > javascript to update the interaction
>
> Nah, iframe doesn't have to be used, if you are going to use a
> SCRIPT-tag then simply add a src to it and get the result of the
> Perl-script that way.
My perception of this question was that it was a post load
issue which required user adjustable content from the current page
delivery be routed to a perl cgi , whose output was used in that page to
complete the task, which is a bit different than simply
rendering dynamic javascript at page delivery.
If it was that simple , then what your suggesting is what I would have.
--
--=<> Dr. Clue (A.K.A. Ian A. Storms) <>=--
--=<[]>=- http://www.drclue.net
--=<[]>=- C++ HTML JavaScript DHTML CGI TCP/IP SQL JAVA VRML NSAPI
--=<[]>=- http://www.drclue.net/F1.cgi/HTML/HTML.html (My famous
HTML/CGI guide.)
------------------------------
Date: Fri, 15 Sep 2000 02:27:13 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: format @<<<
Message-Id: <39C18B90.1730EFAD@home.com>
[posted & mailed]
rathmore@tierceron.com wrote:
>
> format FILE =
> @<<<@<<<
> $y, $z
> .
>
> If $y and $z = "" then:
> It looks like this when it writes to the file: ""
> I want it to look like this: " "
There is no special option to do this with format/write. There are a
couple of techniques in perlform that you could use, though.
If you made the format:
format FILE =
@<<<@<<<SOMETHING
$y, $z
.
Then you could either open a pipe to yourself and just strip SOMETHING
with
s/SOMETHING$//;
Or you could use the swrite in perlform to get the output in a scalar
and do the same thing.
But probably you'd just be better off just using printf:
printf "%-4s%-4s" => $x, $y;
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Fri, 15 Sep 2000 03:00:18 GMT
From: Harry Stone <hstone@netdirect.net>
Subject: Re: Getting started w/ Perl
Message-Id: <B5E6FB32.F63%hstone@netdirect.net>
in article 8pjf8m$88v$1@nnrp1.deja.com, Phil at gphil111@my-deja.com wrote
on 9/11/00 3:28 PM:
> "Lincoln Marr" <lincolnmarr@nospam.europem01.nt.com> wrote:
>>
>> "Phil" <gphil111@my-deja.com> wrote in message
>>>> Id really like to get into learning perl (specifically for cgi
Phil,
I wanted to share my experience with doing basically the
same thing you're considering. I jumped in with both feet. I
opened my mouth at work and told my boss I was teaching ( hah! )
myself on my own time. Right now I'm working on a new distributed
printing system kind of like the one used at Cisco Systems. The
spooler daemon is my own nasty creation in Perl. So far my
experience with Perl has been a real frustrating, fun, and painful
eye-opener, and probably the most I've learned in a short time
in my life. My code won't see this group for a long time, though,
since it's what I think Larry calls 'baby talk', but that's part of
the power of Perl. If you don't have any deadlines to hit, you can
make it _really_ rudimentary until you get in the hang of the
process of writing code. I've found some of my best learning was
going back to some of the monstrosities that I've written and
making them alot more elegant or expanding their functionality with
something new I've learned. You will find that Perl will make you
absolutely furious at times, because it obviously has some horrible
bug that only you have discovered. You'll know you're on the
right track when that bug turns out to be perl blindly following orders
and doing exactly what you told it to do, instead of what you
meant. That's when you start to see the difference between
what you "said" and what you meant, which you might find is
a problem if you have no coding background, like me.
>> Do you have a Unix box you can get started on? If not then you can
Yep, and 15 of them at work where I'm the admin. Nothing like trial
by fire. DON'T try to test your new filesystem-traversing core file
eliminator on a production box. I didn't fall into that trap, but I saw
a fellow do the same with a shell script, and it ain't pretty. DLT is
a hell of a lot slower when the phone is ringing. Seriously, though,
get copy of Linux and set up your home system for dual-boot,
and play around. Breaking your Linux install and figuring out on
your own how to fix it is a great learning tool. It just doesn't seem
like it at the time. It's also a great teacher of the unix philosphy
( with an attitude, granted ) when you see how the system is
laid out, and all the little tools that do one thing very well.
>> knew only html and javascript, and I didn't have too much trouble
> picking up
> O'Reilly's 'Learning
>> Perl' and 'Programming Perl' - these books really got me on my way.
I've had really good luck with O'Reilly books. I broke the piggy bank and
bought the Perl CD Bookshelf CD, which has six, IIRC, books on it, and it's
been money very well spent. Elements of Programming with Perl has been
a lot of help, as well. It covers not just Perl, but the process of 'how to
code' which I was really lacking. I'm still no _real programmer_ but I
don't get the shakes when presented with a new problem.
>> However, if you want to become a proper programmer (like many people
> in this
>> newsgroup) this isn't really the best way to go about it. If you want
I'd agree, I don't think my experience is common. I definitely don't think
that I'm smarter than other people or anything, I just think I got lucky,
and have stuck with it since Perl is What The Big Boys Use.
A friend of mine has gone back to school after a long time off, and he's
becoming a competent C/C++ programmer, and it's formal instruction
that's done it. He knows far less about computers and networks, etc.
than I do, but he can develop a solution to a problem and turn it into
code much quicker than I can.
Okay, I'll stop rambling. If you decide to jump in, just try to
stick with it, and keep learning along the way. Oh, and RTFM,
loser. Sorry, I just wanted to get the first shot in on your
Perl career.
Seeya,
harry
------------------------------
Date: Fri, 15 Sep 2000 02:41:22 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: golf (Was Re: transliterating file names in a dir)
Message-Id: <39C18EE0.5DE64F94@home.com>
Larry Rosler wrote:
>
> I can see the two arguments. So tell me about the comma before the
> 'for'. It seems like list context, with a trailing nothing before the
> 'for'.
It is list context since print is a list op.
> print 'x', for 0;
>
> works just fine, but I can't see how to parse it.
print('x',) for 0;
> For that matter, so does this:
>
> 1, for 0;
(1,) for 0;
As you know, Perl kindly lets us leave trailing commas in lists so that
we can easily add more items later. Though this last case isn't really
a list.
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: 15 Sep 2000 02:53:04 GMT
From: abigail@foad.org (Abigail)
Subject: Re: golf (Was Re: transliterating file names in a dir)
Message-Id: <slrn8s33mf.4mc.abigail@alexandra.foad.org>
Larry Rosler (lr@hpl.hp.com) wrote on MMDLXXI September MCMXCIII in
<URL:news:MPG.142ac23d72cd95e598ad65@nntp.hpl.hp.com>:
'' In article <slrn8s0qv0.ku0.abigail@alexandra.foad.org> on 14 Sep 2000
'' 06:11:45 GMT, Abigail <abigail@foad.org> says...
'' >
'' > I missed the obvious obfuscation touch:
'' >
'' > perl -e'rename"$_",y, ,-,x0|lc,for<*>'
''
'' There are lots of cute touches in there, particularly the trailing null
'' unused argument instead of a space. (Why does this get by the two-
'' argument prototype for remane()?)
Because @a = ("a", "b",); print scalar @a; prints 2, not 3.
'' But I wonder why you waste two strokes to stringify the original
'' filename. Perl isn't the shell, so any interior spaces in the filename
'' don't cause any problems on interpolation.
I first wondered that myself too. Then I tried without them and saw the light.
Vg'f orpnhfr gur frpbaq nethzrag bs eranzr zbqvsvrf $_. Vs gur svefg
nethzrag bs eranzr vf $_, eranzr() jvyy gel gb eranzr gur inyhr bs gur
zbqvsvrq $_. "$_" ubjrire perngrf n arj inyhr, jvgu gur byq inyhr bs $_.
Abigail
--
END {print "Hacker\n"} # A kingfisher flying
INIT {print "Perl " } # over a lake. Four young
BEGIN {print "Just " } # girls beside a pool.
CHECK {print "another "}
------------------------------
Date: Thu, 14 Sep 2000 23:26:50 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: golf (Was Re: transliterating file names in a dir)
Message-Id: <39C196F9.EE4B5F59@cc.gatech.edu>
Larry Rosler wrote:
> > :: -- My submission:
> > :: -- perl -e 'rename"$_",(tr/A-Z /a-z-/+1&&$_)for(<*>)'
> > ::
> > :: Saving 12 strokes:
> > ::
> > :: perl -e'rename"$_",y/ /-/x0|lc,for<*>'
> >
> > I missed the obvious obfuscation touch:
> >
> > perl -e'rename"$_",y, ,-,x0|lc,for<*>'
>
>
> But I wonder why you waste two strokes to stringify the original
> filename. Perl isn't the shell, so any interior spaces in the filename
> don't cause any problems on interpolation.
I see you've already got the reason from 3 different people, but I thought you might
like to know that I got the idea from a question in perlfaq4 about why you should NOT
use quotes just to stringify scalars. I guess in golf all the practical principles
go out the window :-)
--
Stephen Kloder | "I say what it occurs to me to say.
stephenk@cc.gatech.edu | More I cannot say."
Phone 404-874-6584 | -- The Man in the Shack
ICQ #65153895 | be :- think.
------------------------------
Date: Fri, 15 Sep 2000 01:13:40 GMT
From: sandhall@swipnet.se (Robert Hallgren)
Subject: Re: Help in RegExp to highlight keyword in HTML file
Message-Id: <slrn8s2tsd.2on.sandhall@poetry.lipogram>
On Thu, 14 Sep 2000 16:03:24 GMT,
parvaist@my-deja.com <parvaist@my-deja.com> wrote:
> I would like to create a regexp to highlight a keyword in a html text.
> Highlight means add the <FONT COLOR=...>keyword</FONT> tags.
Have you considered a HTML-parser? For example HTML::SimpleParse?
use HTML::SimpleParse;
my $parser = new HTML::SimpleParse($HTML_input);
foreach $node ($parser->tree) {
$node->{content} =~ s{keyword}{<font color="red">keyword</font>}g
if $node->{type} eq 'text';
print $parser->execute($node);
}
You could manage without the parser (a parser may be overkill - kind of
depends on what you want to do). The regexp I came up with is ugly as
h..l though (I'm sure someone can come up with something better).
$HTML_input =~ s
{
<.*?>|(keyword)|.*?
}
{
defined $1 ? "<font color=\"red\">$&</font>" : $&
}gxe;
Robert
--
Robert Hallgren <sandhall@swipnet.se>
PGP: http://www.lipogram.com/pgpkey.asc
5F1E 95C2 F0D8 25A3 D1BE 0F16 D426 34BD 166A 566C
------------------------------
Date: 15 Sep 2000 03:02:37 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Help in RegExp to highlight keyword in HTML file
Message-Id: <slrn8s348c.4mc.abigail@alexandra.foad.org>
jason (elephant@squirrelgroup.com) wrote on MMDLXXI September MCMXCIII in
<URL:news:MPG.142bf8b23f7390ae9897b2@localhost>:
$$ parvaist@my-deja.com <parvaist@my-deja.com> wrote ..
$$ >I would like to create a regexp to highlight a keyword in a html text.
$$ >Highlight means add the <FONT COLOR=...>keyword</FONT> tags. Of course,
$$ >if the keyword in contained in an HTML tag (example: <A
$$ >HREF="keyword.html">), it should not been highlighted !!!!
$$ >
$$ >Can you help me by creating this regexp ??
$$
$$ Abigail might be able to - but you won't like her answer ;)
You might be able to, by using tons of (??{ }) constructs. However,
one must create recursion that way, and by doing so, Perl becomes
highly unstable, with a tendency to core dump.
Abigail
--
map{${+chr}=chr}map{$_=>$_^ord$"}$=+$]..3*$=/2;
print "$J$u$s$t $a$n$o$t$h$e$r $P$e$r$l $H$a$c$k$e$r\n";
------------------------------
Date: Thu, 14 Sep 2000 20:10:56 -0400
From: "yingying3" <yingying3@peoplepc.com>
Subject: help regarding split
Message-Id: <39c1763e$1@flexnet239.uunt.net>
Please advise if possible to split a delimited(",") string, in which all
fields are wraped with double quota. But some fields include comma(",")
within the double quotas, such as,
"aaa","bbb bb","ccc,cc","ddd, d, ddd","ee"
If the split function doesn't work, what is the better way to split the
string?
Thank you for help.
DT
------------------------------
Date: Fri, 15 Sep 2000 01:21:10 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: help regarding split
Message-Id: <aQew5.7428$RJ.45635@typhoon.austin.rr.com>
In article <39c1763e$1@flexnet239.uunt.net>,
yingying3 <yingying3@peoplepc.com> wrote:
>Please advise if possible to split a delimited(",") string, in which all
>fields are wraped with double quota. But some fields include comma(",")
>within the double quotas, such as,
>"aaa","bbb bb","ccc,cc","ddd, d, ddd","ee"
>
>If the split function doesn't work, what is the better way to split the
>string?
You might want to read through the frequently asked questions (FAQs) and
their answers which should be installed on any machine with a reasonably
recent perl.
For your question
perldoc perlfaq4
(part 4 of the FAQs, whose index can be found using perldoc perlfaq)
might be useful as it includes:
How can I split a [character] delimited string except when
inside
[character]? (Comma-separated files)" [character]? (Comma-
separated files)" Take the example case of trying to split
a string that is comma-separated into its different
fields. (We'll pretend you said comma-separated, not
comma-delimited, which is different and almost never what
you mean.) You can't use `split(/,/)' because you
shouldn't split if the comma is inside quotes. For
example, take a data line like this:
SAR001,"","Cimetrix, Inc","Bob Smith","CAM",N,8,1,0,7,"Error, Core Dumped"
[...]
and presents several solutions. If perldoc isn't installed on your system
then http://www.perl.com/pub/doc/manual/html/pod/perlfaq4.html might be
useful.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ |
GPG PGP Key 1024D/059913DA | Fingerprint 0570 71CD 6790 7C28 3D60
stok@colltech.com (CT - work) | 75D2 9EC4 C1C0 0599 13DA
------------------------------
Date: Fri, 15 Sep 2000 02:07:57 GMT
From: sandhall@swipnet.se (Robert Hallgren)
Subject: Re: help regarding split
Message-Id: <slrn8s312r.2sf.sandhall@poetry.lipogram>
On Thu, 14 Sep 2000 20:10:56 -0400,
yingying3 <yingying3@peoplepc.com> wrote:
> Please advise if possible to split a delimited(",") string, in
> which all fields are wraped with double quota. But some fields
> include comma(",") within the double quotas, such as, "aaa",
> "bbb bb","ccc,cc","ddd, d, ddd", "ee"
It may work, but it's not optimal. You should consider changing
the delimiter to something not used in the fields (if you have
that option). A simple benchmark shows a 120% boost if you get
rid of the lookahead/lookbehind.
@bar = split /(?<="),(?=")/, $foo;
If there will never be a field with a comma as the first sign
(",aaa" for example), you can gain a little performance.
@bar = split /(?<="),/, $foo;
Robert
--
Robert Hallgren <sandhall@swipnet.se>
PGP: http://www.lipogram.com/pgpkey.asc
5F1E 95C2 F0D8 25A3 D1BE 0F16 D426 34BD 166A 566C
------------------------------
Date: 15 Sep 2000 02:45:57 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Is there a good freeware/shareware IDE for PERL?
Message-Id: <slrn8s3394.4mc.abigail@alexandra.foad.org>
Victor Koldun (lkh@class.class.lviv.ua) wrote on MMDLXXI September
MCMXCIII in <URL:news:39C0E5B8.6804A8FF@class.class.lviv.ua>:
__
__
__ Does anyone know of some good and freeware/shareware PERL IDE to build
__ and debug scripts without the Internet access?
FreeBSD, and don't listen to those penguin freaks!
Abigail
--
perl -we 'print q{print q{print q{print q{print q{print q{print q{print q{print
qq{Just Another Perl Hacker\n}}}}}}}}}' |\
perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w
------------------------------
Date: Fri, 15 Sep 2000 05:04:08 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Is there a good freeware/shareware IDE for PERL?
Message-Id: <1egzi1h.1sj5hku17hr5ogN%tony@svanstrom.com>
Abigail <abigail@foad.org> wrote:
> Victor Koldun (lkh@class.class.lviv.ua) wrote on MMDLXXI September
> MCMXCIII in <URL:news:39C0E5B8.6804A8FF@class.class.lviv.ua>:
> __
> __
> __ Does anyone know of some good and freeware/shareware PERL IDE to build
> __ and debug scripts without the Internet access?
>
>
> FreeBSD, and don't listen to those penguin freaks!
Nah, Darwin is what people should use. :)
/Tony
--
/\___/\ Who would you like to read your messages today? /\___/\
\_@ @_/ Protect your privacy: <http://www.pgpi.com/> \_@ @_/
--oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
on the verge of frenzy - i think my mask of sanity is about to slip
---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
\O/ \O/ ©99-00 <http://www.svanstrom.com/?ref=news> \O/ \O/
------------------------------
Date: Fri, 15 Sep 2000 03:09:55 GMT
From: Harry Stone <hstone@netdirect.net>
Subject: Re: killfiles? scores? I wish I had these luxuries
Message-Id: <B5E6FD78.F64%hstone@netdirect.net>
in article Pine.GSO.4.21.0009122232340.10747-100000@crusoe.crusoe.net, Jeff
Pinyan at jeffp@crusoe.net wrote on 9/12/00 9:33 PM:
> Sorry if this is off-topic, but I use the meager PINE, and I don't think I
> have the ability to kill-file people or score postings. What news readers
> are you folks using?
Hehee.. set flamethrowers on incinerate... I'm using Outlook Express.
Hey, it came with my new Mac. I bought the new Mac because I wanna
run OS X, which comes with, get this, Perl. Yep, Apple. BTW, does
anyone know whether Perl under OS X will be more like unix Perl,
considering the new system architecture of OS X? I tried goofing
around with MacPerl for awhile, but it just ain't the same for me.
harry
ps- I use Mutt at work for mail, so I'm not a total heathen. I hope.
------------------------------
Date: Fri, 15 Sep 2000 02:06:08 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: print and CGI scripts
Message-Id: <slrn8s310d.3s7.tjla@thislove.dyndns.org>
I was shocked! How could Dave O'Brien <david.obrien@ssmb.com.au>
say such a terrible thing:
>I'm sorry, but my first post was confusing. What I *should* have
>written, was that I'm trying to *prevent* output to the browser from
>print statements. The reason is that I'm using print statments to write
>to a file, and they are currently showing up in the browser.
Correct me if I am wrong but it sounds to me like you are misusing (or
misunderstanding the print() statement. Print just by itself goes to
standard output:
print "Hi there!"; # seen in browser
But if you supply a file to print to it goes there instead:
open SOME_FILE, "a_file.txt" or die "Couldn't open the file: $!";
print SOME_FILE "some data"; # not seen in browser
Have a look at the documentation:
perldoc -f print
perldoc -f open
perldoc perlopentut
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
There's nothing like a girl with a plunging neckline to keep a man on his toes.
------------------------------
Date: Fri, 15 Sep 2000 14:02:35 +1000
From: Dave O'Brien <david.obrien@ssmb.com.au>
Subject: Re: print and CGI scripts
Message-Id: <39C19F5B.2A07F64B@ssmb.com.au>
Gwyn Judd wrote:
>
> I was shocked! How could Dave O'Brien <david.obrien@ssmb.com.au>
> say such a terrible thing:
>
> >I'm sorry, but my first post was confusing. What I *should* have
> >written, was that I'm trying to *prevent* output to the browser from
> >print statements. The reason is that I'm using print statments to write
> >to a file, and they are currently showing up in the browser.
>
> Correct me if I am wrong but it sounds to me like you are misusing (or
> misunderstanding the print() statement. Print just by itself goes to
> standard output:
>
> print "Hi there!"; # seen in browser
>
> But if you supply a file to print to it goes there instead:
>
> open SOME_FILE, "a_file.txt" or die "Couldn't open the file: $!";
>
> print SOME_FILE "some data"; # not seen in browser
>
> Have a look at the documentation:
>
> perldoc -f print
> perldoc -f open
> perldoc perlopentut
>
> --
> Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
> There's nothing like a girl with a plunging neckline to keep a man on his toes.
That is the exact code I'm using, and it still outputs to the browser,
as well as the file. It means when I'm processing 20 files, all those
files are output to the browser! Very annoying.
thanks for your response
Dave
------------------------------
Date: Fri, 15 Sep 2000 03:12:25 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: print and CGI scripts
Message-Id: <x7u2bifiw6.fsf@home.sysarch.com>
>>>>> "DO" == Dave O'Brien <david.obrien@ssmb.com.au> writes:
DO> Gwyn Judd wrote:
>>
>> open SOME_FILE, "a_file.txt" or die "Couldn't open the file: $!";
^^^^^^^^^^
missing > for output files.
DO> That is the exact code I'm using, and it still outputs to the browser,
DO> as well as the file. It means when I'm processing 20 files, all those
DO> files are output to the browser! Very annoying.
if that is true you have the same bug. getting output from a cgi script
and not sending it to a browser is easy. one debug trick is to create a
fifo and open it for output in the cgi. run tail -f on it from another
window. then you can see what you want in the cgi in realtime.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Fri, 15 Sep 2000 14:25:07 +1000
From: Dave O'Brien <david.obrien@ssmb.com.au>
Subject: Re: print and CGI scripts
Message-Id: <39C1A4A3.9F98D75C@ssmb.com.au>
Uri Guttman wrote:
>
> >>>>> "DO" == Dave O'Brien <david.obrien@ssmb.com.au> writes:
>
> DO> Gwyn Judd wrote:
> >>
> >> open SOME_FILE, "a_file.txt" or die "Couldn't open the file: $!";
> ^^^^^^^^^^
>
> missing > for output files.
>
> DO> That is the exact code I'm using, and it still outputs to the browser,
> DO> as well as the file. It means when I'm processing 20 files, all those
> DO> files are output to the browser! Very annoying.
>
> if that is true you have the same bug. getting output from a cgi script
> and not sending it to a browser is easy. one debug trick is to create a
> fifo and open it for output in the cgi. run tail -f on it from another
> window. then you can see what you want in the cgi in realtime.
>
> uri
>
Thanks Uri,
I am opening the file correctly, and the new file is being created, but
as it is being created, each line is printed to the browser and file at
the same time. Could you explain the tail -f solution you suggested?
Thanks
Dave
------------------------------
Date: Fri, 15 Sep 2000 03:37:50 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: print and CGI scripts
Message-Id: <x7pum6fhps.fsf@home.sysarch.com>
>>>>> "DO" == Dave O'Brien <david.obrien@ssmb.com.au> writes:
DO> I am opening the file correctly, and the new file is being created, but
DO> as it is being created, each line is printed to the browser and file at
DO> the same time. Could you explain the tail -f solution you suggested?
show the code. you can't print to 2 places at the same time without
either tied handles or multiple calls to print.
as for the tail -f idea, what is there to explain? just do what i said,
open a fifo for output in the cgi and print there, read from it with a
tail -f. 3 simple operations.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Fri, 15 Sep 2000 02:10:51 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Req.: The perfect Perl Editor?
Message-Id: <slrn8s3198.3s7.tjla@thislove.dyndns.org>
I was shocked! How could Craig Berry <cberry@cinenet.net>
say such a terrible thing:
>Mark-Jason Dominus (mjd@plover.com) wrote:
>: In article <slrn8s0tfu.4t8.tim@degree.ath.cx>,
>: Tim Hammerquist <tim@degree.ath.cx> wrote:
>: > pico
>:
>: I find pico impossible because it doesn't do line numbering. When the
>: compiler says you have an error on line 57, you have to count 57 lines
>: down manually.
>
>Not quite *that* bad. Ctrl-c reports the current line; so you can page
Whereas with vi(m) all you need to do is ':57' and it will take you
there. Or with emacs all you need to do is think '57'.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
:TOPS-20:: /tops-twen'tee/ n. See {{TWENEX}}.
From "The New Hackers Dictionary", version 4.2
------------------------------
Date: Thu, 14 Sep 2000 23:19:36 -0400
From: Clint Mario Cleetus <cmc77@pantheon.yale.edu>
Subject: Shortest code for Fibonacci?
Message-Id: <Pine.GSO.4.10.10009142301000.15482-100000@morpheus.cis.yale.edu>
Hi,
I am looking for a concise and elegant way to calculate the Fibonacci
Number corresponding to a given number. But it should also avoid recursion
in order to be efficient. I wrote a standard subroutine for this:
sub Fib
{
$num = shift;
return 1 if $num < 2;
$f1 = $f2 = 1;
for ($i = 1; $i < $num; $i++)
{
$f = $f1 + $f2;
$f1 = $f2;
$f2 = $f;
}
return $f;
}
But this seems to be like any other standard C subroutine. Please let me
know if you have one-liners or atleast a much more elegant solution for
this.
Thanks.
------------------------------
Date: 15 Sep 2000 03:06:00 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Silly grep tricks
Message-Id: <slrn8s34em.4mc.abigail@alexandra.foad.org>
Alan Barclay (gorilla@elaine.furryape.com) wrote on MMDLXXI September
MCMXCIII in <URL:news:968974147.482651@elaine.furryape.com>:
() In article <MPG.142a133ef297f9e98ad5f@nntp.hpl.hp.com>,
() Larry Rosler <lr@hpl.hp.com> wrote:
() >In article <968895240.227134@elaine.furryape.com>,
() >gorilla@elaine.furryape.com says...
() >
() >...
() >
() >> print "",(grep { /e/ } @a)[0],"\n";
() >>
() >> Note, if you pass it to print, you'll have to force the parser to not
() >> interpt the parenthesis as a function, that's what the useless "" is for.
() >
() >Instead of 'the useless ""' argument, a simple unary '+' is more
() >general, more obvious, trivially more efficient, and two strokes
() >shorter.
()
() No doubt about the two strokes, but I personally find it clearer to
() use unary '+'s only when the scalar contains a number. Seeing a
() + screams arithemetic to me.
So, you don't like magical decrement either? Or unairy minus?
Also, using C<print "",(grep { /e/ } @a)[0],"\n";> because it's clearer
than C<print +(grep { /e/ } @a)[0],"\n";> is, uhm, interesting.
Abigail
--
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
print } sub __PACKAGE__ { &
print ( __PACKAGE__)} &
__PACKAGE__
( )
------------------------------
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 4328
**************************************