[12950] in Perl-Users-Digest
Perl-Users Digest, Issue: 360 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 4 05:07:21 1999
Date: Wed, 4 Aug 1999 02:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 4 Aug 1999 Volume: 9 Number: 360
Today's topics:
Re: << Print Command Won't Work (Larry Rosler)
Re: << Print Command Won't Work (elephant)
Re: << Print Command Won't Work <alex@kawo2.rwth-aachen.de>
Re: Can I use a variable as a file descriptor ? <cmd@maths.uq.edu.au>
chdir isn't working when using a variable for the direc <rwyatt1@lucent.com>
Re: chdir isn't working when using a variable for the d (elephant)
Re: Escaping HTML tags (Andreas Fehr)
Re: Escaping HTML tags (Abigail)
Re: Help Please <gellyfish@gellyfish.com>
Re: High demand for Perl programmers? <gellyfish@gellyfish.com>
Re: How can I know what modules are installed on server (Anno Siegel)
Re: how to check if scalar is blank? (Dan Zetterstrom)
Re: how to remove cr/lf ??? <nospam.newton@gmx.net>
Re: mySql & Perl -> Something simple (Steve MacLellan)
Re: Newbie Q: Removing files from a folder <andrewf@beausys.freeserve.co.uk>
Re: Newbie: @INC problem with non-super-user installati <alex@kawo2.rwth-aachen.de>
open3 and print to STDOUT <pkotala@logis.cz>
Re: OPEN3() Function (I.J. Garlick)
Re: password protected site (Fulko van Westrenen)
Re: Perl or CGI (David H. Adler)
Re: Perl or CGI (David H. Adler)
Re: Perl seems to be LAME! <andrewf@beausys.freeserve.co.uk>
Re: Perl seems to be LAME! <rra@stanford.edu>
Re: Possible to get a HTML file from somewhere and use <alex@kawo2.rwth-aachen.de>
Re: strange error (Anno Siegel)
Re: tar (Martin Gleeson)
Useless error when {} unbalanced (Filip M. Gieszczykiewicz)
Re: Useless error when {} unbalanced (Abigail)
Re: Using ActivePerl on Win32 (win98) <gellyfish@gellyfish.com>
Re: using perlcc <alex@kawo2.rwth-aachen.de>
Re: Working Telnet Script Needed <gellyfish@gellyfish.com>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 4 Aug 1999 00:24:05 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: << Print Command Won't Work
Message-Id: <MPG.12118a6b8624c394989db2@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <37a7df15.0@scctn03.sp.edu.sg> on Wed, 4 Aug 1999 14:33:10
+0800, zexl <laoch98@yahoo.com> says...
> I am running ActivePerl under WINNT. I got a program that goes somthing like
> that:
>
> print "Content-type:text/html \n\n";
After the program compiles, you will need to have a space after the
colon. I doubt that the extra space at the end matters, though.
> print << 'End';
> <html>
> <head>
> <title> My CGI </title>
> </head>
> <body>
> <h1> My CGI </h1>
> <em> Hello, INTERNET! </em>
> </body>
> </html>
> End
>
> Whenever I compiled, I got such error:
> Can't find string terminator "End" anywhere before EOF ...
Look for the following under Quirks in the ActivePerl FAQ:
Why do I get an error using Perl's here-doc syntax (<<), that says
"Can't find string terminator anywhere before EOF"?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 4 Aug 1999 18:23:23 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: << Print Command Won't Work
Message-Id: <MPG.1212a38291ed2ebc989bdb@news-server>
Larry Rosler writes ..
>Look for the following under Quirks in the ActivePerl FAQ:
>
>Why do I get an error using Perl's here-doc syntax (<<), that says
>"Can't find string terminator anywhere before EOF"?
sure that question isn't in perlwin32faq8 (Programming) ? .. because it
is in my documentation
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Wed, 04 Aug 1999 10:50:47 +0200
From: Alex Farber <alex@kawo2.rwth-aachen.de>
To: zexl <laoch98@yahoo.com>
Subject: Re: << Print Command Won't Work
Message-Id: <37A7FEE7.632E8845@kawo2.rwth-aachen.de>
Hi Zexl,
remove the spaces
zexl wrote:
> print "Content-type:text/html \n\n";
^here
> print << 'End';
^and here
Regards
Alex
--
Ich studiere Elektrotechnik (Technische Informatik) an der RWTH Aachen
und bin ein guter Perl-Programmierer (arbeite seit 4 Jahren als Intranet-
Entwickler). Kann auch C, Java, SQL, JavaScript und HTML, CGI und TCP/IP.
Ich suche eine gut bezahlte Diplomstelle in Koeln, Aachen oder Umgebung.
------------------------------
Date: Wed, 04 Aug 1999 17:44:27 +1000
From: cmd <cmd@maths.uq.edu.au>
Subject: Re: Can I use a variable as a file descriptor ?
Message-Id: <37A7EF5B.B7C38253@maths.uq.edu.au>
dja7 wrote:
> Can I use a variable as a file descriptor ?
> If so, do I have to do anything more than define the variable ?
Forgive me if I have no idea what you're asking, but to use a variable
as a filehandle in an open command, you can define it as a typeglob
(whatever that means).
*FH = 'AFILE';
open(FH, "a path");
or
sub spawn {
local *FH = shift;
open(FH, "a path");
etc
}
Hope this helps anyways,
Chris.
------------------------------
Date: Wed, 04 Aug 1999 09:03:21 +0100
From: Randy Wyatt <rwyatt1@lucent.com>
Subject: chdir isn't working when using a variable for the directory
Message-Id: <37A7F3C9.B26278CA@lucent.com>
Hello,
Specifically, I am using HP-UX 10.20 and HP-UX 11.0, perl 5.005_002.
I need to be able to change directory to the value represented by a variable.
#!/opt/perl5/bin/perl
$tmpdir = "tmp";
chdir('$tmpdir');
The directory tmp is in the current working directory and the permissions are
the directory are 755. Does anybody have any ideas ?
Thanks,
Randy
------------------------------
Date: Wed, 4 Aug 1999 18:32:04 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: chdir isn't working when using a variable for the directory
Message-Id: <MPG.1212a58a3287994c989bdc@news-server>
Randy Wyatt writes ..
>I need to be able to change directory to the value represented by a variable.
>
>#!/opt/perl5/bin/perl
>$tmpdir = "tmp";
>chdir('$tmpdir');
^ ^
hint: what do those do ?
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Wed, 04 Aug 1999 07:45:01 GMT
From: backwards.saerdna@srm.hc (Andreas Fehr)
Subject: Re: Escaping HTML tags
Message-Id: <37a7ee8b.8415200@news.uniplus.ch>
On Tue, 3 Aug 1999 21:10:01 -0700, lr@hpl.hp.com (Larry Rosler) wrote:
>>
>> You're looking for a subroutine that does the work of a 10 char Perl program?
>
>OK. I give up. Here's the best I can do at this golf game:
>
snip
>
>Neither of those comes even near to 10 characters. I give up.
>
I might be wrong, but it should work if you send your file
to a browser with a 'text/plain' header. (This is not a 10
char Perl program, but these are 10 chars...)
Andreas
------------------------------
Date: 4 Aug 1999 02:47:52 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Escaping HTML tags
Message-Id: <slrn7qfs03.s67.abigail@alexandra.delanet.com>
Larry Rosler (lr@hpl.hp.com) wrote on MMCLXIV September MCMXCIII in
<URL:news:MPG.12115cf7e10060d3989db0@nntp.hpl.hp.com>:
\\ In article <slrn7qf7ep.s67.abigail@alexandra.delanet.com> on 3 Aug 1999
\\ 20:57:17 -0500, Abigail <abigail@delanet.com> says...
\\ >
\\ > You're looking for a subroutine that does the work of a 10 char Perl progra
\\
\\ OK. I give up. Here's the best I can do at this golf game:
\\
\\ #!/usr/local/bin/perl -w
\\ use strict;
\\
\\ $_ = '"x<y>z&w"';
\\
\\ s/["&<>]/&#${\ord$&};/g; # 24 characters
\\
\\ print;
\\
\\ $_ = '"x<y>z&w"';
\\
\\ my %h =
\\ ('"' => '"', '&' => '&', '<' => '<', '>' => '>' );
\\
\\ s/./$h{$&}||$&/eg; # 18 characters (plus the hash initialization)
\\
\\ print;
\\ __END__
\\
\\ Neither of those comes even near to 10 characters. I give up.
perl -wi -pe 's.<.<.g' file
0123456789
There's never a need to escape " or > if the effect you are after is
to make HTML tags visible. Knowing the field you play on helps in both
golf and Perl golf. ;-)
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 4 Aug 1999 10:03:28 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Help Please
Message-Id: <37a801e0_2@newsread3.dircon.co.uk>
Marshall Culpepper <marshalc@americasm01.nt.com> wrote:
> chop($user=<STDIN>);
Whilst it *may* not matter in this case it is generally recommended to
use chomp where you only want to remove $/ from the end of the line -
chop will remove the last character regardless.
/J\
--
"Michael Ancram, you haven't got a hope in hell of winning the next
election" - Huw Edwards, BBC News
------------------------------
Date: 4 Aug 1999 09:26:50 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: High demand for Perl programmers?
Message-Id: <37a7f94a$1_2@newsread3.dircon.co.uk>
Dan Woods <dwoods@ucalgary.ca> wrote:
>> I suspect that people who know how to post job notices
>> with the Perl Mongers, or in the appropriate jobs.* newsgroups,
>> are more coputer-savvy and less desperate than many people who
>> frantically post here.
>
> Where else are Perl contracts/jobs posted or listed to ?
> Not everyone has a service provider (like universities) which
> subscribe to job.* newsgroups, and so you would never see those
> postings.
See the Perlmongers Jobs Mailing Lists described at :
<http://www.pm.org/mailing_lists.shtml>
/J\
--
"What is the future for beef? Curtains?" - Graham Norton
------------------------------
Date: 4 Aug 1999 08:59:38 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How can I know what modules are installed on server?
Message-Id: <7o8vdq$bsm$1@lublin.zrz.tu-berlin.de>
99% Energy <Spam@IsBadForTheInternet.com> wrote in comp.lang.perl.misc:
>I don't care if you get so offended because I include the quoting or after.
*plonk*
Anno
------------------------------
Date: Wed, 04 Aug 1999 08:28:54 GMT
From: methabol@hem.passagen.se (Dan Zetterstrom)
Subject: Re: how to check if scalar is blank?
Message-Id: <37b6f538.111473860@news.algonet.se>
On Tue, 3 Aug 1999 14:20:04 -0500, "Paul Glidden"
<paul.glidden@unisys.com> wrote:
>I don't see what the problem is here, assign a value to the scalar at
>initialization that it will most likely never have, then test for this
>value.
>
Aha, you mean like some old databases and programs used to have '99'
to signify a non-existing year? Sounds like a really, really clever
hack today, doesn't it?
Perl already has undef, so just use it...
//DZ
--
Come the end, the only thing remaining
was the darkness in his soul.
Facing his fate with serenity
never to awake from the digital daydream.
------------------------------
Date: Wed, 04 Aug 1999 10:19:47 +0200
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.net>
Subject: Re: how to remove cr/lf ???
Message-Id: <37A7F7A3.BC075027@gmx.net>
elephant wrote:
>
> you are right here Philip .. the test that I performed was stupidly
> wrong .. my apologies
Life happens. Enjoy Perl on whichever platform you use!
Cheers,
Philip
------------------------------
Date: Wed, 04 Aug 1999 08:34:15 GMT
From: maclell@col.ca (Steve MacLellan)
Subject: Re: mySql & Perl -> Something simple
Message-Id: <37a7df64.114952317@news.tor.metronet.ca>
On Tue, 3 Aug 1999 18:27:23 -0700, lr@hpl.hp.com (Larry Rosler) wrote:
>This is off-topic, but the </TD>, </TH>, and </TR> tags are all
>optional. So the </TD> there is just HTML noise.
Yes, optional if you only want it to dsiplay in MSIE. If you want it
to display in Netscape you have to close Table elements.
_______________________________________
Dog Byte Enterprises
Marketing Solutions and Web
Development for Small Business
http://welcome.to/dogbyte
_______________________________________
------------------------------
Date: Wed, 4 Aug 1999 08:09:22 +0100
From: Andrew Fry <andrewf@beausys.freeserve.co.uk>
Subject: Re: Newbie Q: Removing files from a folder
Message-Id: <x4ezLDAic+p3EwJB@beausys.freeserve.co.uk>
In article <MPG.121109a65f7b7484989da8@nntp.hpl.hp.com>, Larry Rosler
<lr@hpl.hp.com> writes
>In article <x3y1zdkekx8.fsf@tigre.matrox.com> on Tue, 3 Aug 1999
>15:14:27 -0400 , Ala Qumsieh <aqumsieh@matrox.com> says...
>>
>> Andrew Fry <andrewf@beausys.freeserve.co.uk> writes:
>>
>> > I want a little utility that will tidy up various Win95/WinNT
>> > folders for me ...
>>
>> So directories are being called "folders" these days? Interesting ..
>
><URL:http://x29.deja.com/[ST_rn=ps]/getdoc.xp?AN=504861089.1>
>
>Subject: Re: Geekspeak Programming Contest
>Date: 1999/07/24
>Author: Tom Christiansen <tchrist@mox.perl.com>
>
>directory = folder
According to Win95 Windows Help,...
"Folders -
Your documents and programs are stored in folders, which you can see in
My Computer and Windows Explorer. In previous versions of Windows,
folders were called directories."
---
Andrew Fry
"Time flies like an arrow. Fruit flies like a banana". (Groucho Marx).
------------------------------
Date: Wed, 04 Aug 1999 10:57:16 +0200
From: Alex Farber <alex@kawo2.rwth-aachen.de>
To: Pierre Mart <pierremart@hotmail.com>
Subject: Re: Newbie: @INC problem with non-super-user installation
Message-Id: <37A8006C.A97C2D2B@kawo2.rwth-aachen.de>
Hi Pierre,
Pierre Mart wrote:
> How can I correct this? I don't want to put a line
> @INC = ('/usr/home/pierre/perl5/lib/perl5');
> in every script I wrote. (Hey, it doesn't even work!!!)
maybe setting PERL5LIB helps? See perldoc perlrun
Regards
Alex
--
Ich studiere Elektrotechnik (Technische Informatik) an der RWTH Aachen
und bin ein guter Perl-Programmierer (arbeite seit 4 Jahren als Intranet-
Entwickler). Kann auch C, Java, SQL, JavaScript und HTML, CGI und TCP/IP.
Ich suche eine gut bezahlte Diplomstelle in Koeln, Aachen oder Umgebung.
------------------------------
Date: Wed, 4 Aug 1999 09:04:23 +0200
From: "Pavel Kotala" <pkotala@logis.cz>
Subject: open3 and print to STDOUT
Message-Id: <933750420.466250@gate.logis.cz>
When I use Open3 (on WinNT), and then print to stdout, then message is shown
at the end of script, not just at the moment of printing. For example in the
example below, running this script I see message 1, then I must press key
and then I see messages 2 and 3.
Any Idea why? How can I do it work?
-----------------------------------------------------
use IPC::Open3;
print "1\n";
open3(\*IN, \*OUT, \*ERR, "dir c:\\");
close(IN);
close(OUT);
close(ERR);
print "2\n";
<STDIN>;
print "3\n";
-----------------------------------------------------
Thank You
Pavel Kotala
------------------------------
Date: Wed, 4 Aug 1999 08:28:28 GMT
From: ijg@connect.org.uk (I.J. Garlick)
To: Greg Guerin <gregory_guerin@hp.com>
Subject: Re: OPEN3() Function
Message-Id: <FFxM7G.CLz@csc.liv.ac.uk>
[Posted and mailed]
In article <37A6FA32.507B8285@hp.com>,
Greg Guerin <gregory_guerin@hp.com> writes:
> that I have. Does anyone know where I can find information on the open3
> function or have a sample of code that uses it? Thanks in advance.
The Sendmail.pm module by Zenin uses open3 quite effectively.
sub Send {
my $self = shift;
my $IN_SENDMAIL = new FileHandle;
my $OUT_SENDMAIL = new FileHandle;
my $ERR_SENDMAIL = new FileHandle;
my $UUser;
($UUser = $self->{Header}{'From'}) =~ s/^.+<(.+)>$/$1/;
my $FOOL_SENDMAIL = "-f ".$UUser;
my ($key, $val) = ();
my $sendError = '';
open3 $IN_SENDMAIL, $OUT_SENDMAIL, $ERR_SENDMAIL, $SENDMAIL,
@SENDMAIL_OPTIONS, $FOOL_SENDMAIL, ($self->{que} ? $SENDMAIL_QUE : '')
or ($Error = "Can not fork to run $SENDMAIL @SENDMAIL_OPTIONS: $!",
return);
The full module is availabke from his home server
ftp://thrush.omix.com/pub/perl/modules/Mail-Sendmail-1.10.tar.gz
Also I think I read somewhere that open 2 calls open3? So have a look in
the IPC directory.
--
Ian J. Garlick
ijg@csc.liv.ac.uk
Science is facts; just as houses are made of stones, so is science made
of facts; but a pile of stones is not a house and a collection of facts
is not necessarily science.
-- Henri Poincaire
------------------------------
Date: 4 Aug 1999 08:04:57 GMT
From: fulko@dizzy.ipo.tue.nl (Fulko van Westrenen)
Subject: Re: password protected site
Message-Id: <slrn7qft15.e4r.fulko@dizzy.ipo.tue.nl>
On Tue, 3 Aug 1999 15:15:10 -0400, James A Culp III <admin@futuristic.net>
wrote:
>
>
>Fulko van Westrenen <fulko@trane.wtm.tudelft.nl> wrote in message
>news:slrn7qef09.d1.fulko@trane.wtm.tudelft.nl...
>>
>> Hello,
>>
>> I would like to make a password protected page with perl:
>> after you enter a user/password you can update a database.
>> I have some ideas about how this should be done but is
>> the some documentation on this subject?
>>
>
>Your best bet might be to consider password protected directories on your
>webserver. If this is an option it would most likely be considerably easier
>to implement, and probably more efficient.
>
>I recently had the need to do similar database manipulation via the web and
>found it considerably easier to password protect a separate directory in my
>cgi-bin and set up a normal database manipulating cgi in that directory.
>Then if a user tries to utilize the cgi he/she/it is prompted for a username
>and password first.
>
>If your website is hosted on an Apache webserver and you are the admin you
>might do a search in the documentation or at http://www.apache.org/ for the
>keyword "htaccess" and "AuthConfig".
I never thought about using Apache for this. This looked like very
usefull information:
http://www.apacheweek.com/features/userauth
Thanks,
Fulko
>
>
>
>
>
>
--
Fulko van Westrenen
email: f.c.v.westrenen@tue.nl
alternative: fulko@ipopc150.ipo.tue.nl
temporary: fulko@monk.wtm.tudelft.nl
------------------------------
Date: 4 Aug 1999 03:09:25 -0400
From: dha@panix.com (David H. Adler)
Subject: Re: Perl or CGI
Message-Id: <slrn7qfpp5.8nn.dha@panix.com>
On Tue, 03 Aug 1999 21:33:36 GMT, pricerbumanto@my-deja.com
<pricerbumanto@my-deja.com> wrote:
>In article <a1btcprmao.fsf@cyclone.jprc.com>,
> Jason Reed <jcreed@cyclone.jprc.com> wrote:
>>
>> Kio estas malbona pri esperanto?
>
>Laux mia kompreno, "perlcoder" simple konstatas, ke la angla mutle pli
>disvastigxas ol E-o, k en tre diversaj sferoj, k do sekve, proporcie pli
>utila. Kompreneble, al mi sxajnas iom artajxa tiu kontrauxstaro de la
>angla "kontraux" E-o; kial ne lerni ambaux la du lingvojn? Unue E-on,
>cxar gxi estas relative multe pli lernebla, ecx por eneuxroplingvano,
>due (gxis la atingebla nivelo) la anglan lingvon. Tamen cxu io simila
>eblas, rilate al Perl k Python, mi ne pretas sugesti! ;-)
Hmm... Babelfish doesn't do Esperanto, does it? :-/ Of course, if it
did, I'm not sure we'd get anything useful... :-)
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Just Install Perl. - Chris Nandor
------------------------------
Date: 4 Aug 1999 03:14:09 -0400
From: dha@panix.com (David H. Adler)
Subject: Re: Perl or CGI
Message-Id: <slrn7qfq21.8nn.dha@panix.com>
On Tue, 03 Aug 1999 05:45:23 GMT, CGI <PerlCoder@Unix.com> wrote:
>I went to www.virtualave.net because they are a free web server that
>gives you CGI access. The only language they support is Perl, so I
>didn't really have a choice to use another language. However, they
IMO, choice is good.
>probably picked Perl for good reasons, so I think it's a good choice
But you don't know what those reasons are? Hm.
>for me too. Also, I noticed there are a lot of messages on this
>newsgroup, so I figure a lot of people are using Perl.
Well, yes, a lot of people are, but there's also a lot of traffic on
several pornographic newsgroups. Now that I think about it, though, I
would imagine there *are* a lot of people using pornography... :-)
Seriously, although I'm a major advocate of Perl, none of these strike
me as particularly good reasons to use it, and *certainly* not to use
it exclusively.
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"Take myself, subtract films, and the remainder is zero"
- Akira Kurosawa
------------------------------
Date: Wed, 4 Aug 1999 08:16:00 +0100
From: Andrew Fry <andrewf@beausys.freeserve.co.uk>
Subject: Re: Perl seems to be LAME!
Message-Id: <OYq8DGAwi+p3EwNo@beausys.freeserve.co.uk>
In article <7o7qul$8bq$1@nnrp1.deja.com>, Makarand Kulkarni
<makarand_kulkarni@my-deja.com> writes
>
>> And with the search algorithm about 11 seconds!
>
>The time taken depends on several factors like
>kind of machine you are using, RAM it has, CPU Clock
>Rate etc etc. It is not Perl related.
Of course it is also language related ... particularily
if you write in a very inefficient style.
---
Andrew Fry
"Time flies like an arrow. Fruit flies like a banana". (Groucho Marx).
------------------------------
Date: 04 Aug 1999 00:25:54 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Perl seems to be LAME!
Message-Id: <ylk8rc3t31.fsf@windlord.stanford.edu>
Moritz Mertinkat <bluebit@gmx.net> writes:
> I'm using a text file (~1.11 MB) with about 10000 entries
> for searching. Now, when I just run through all the lines
> - without even doing *anything* - it takes up to 7 seconds!
> And with the search algorithm about 11 seconds!
Well, yeah. You're loading the entire thing into memory, forcing Perl to
constantly expand an array and allocate a ton of memory.
> foreach $line (<FILE>) {
Try while (<FILE>) instead and use $_ instead of $line.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Wed, 04 Aug 1999 10:59:41 +0200
From: Alex Farber <alex@kawo2.rwth-aachen.de>
To: lpwong@my-deja.com
Subject: Re: Possible to get a HTML file from somewhere and use it as string?
Message-Id: <37A800FC.FBD7CA60@kawo2.rwth-aachen.de>
Hi Martin,
lpwong@my-deja.com wrote:
> I'm a newbie of writting Perl/CGI. Recently i want to write a simple
> CGI (hopefully) to extract some links from a HTML located in other
> server. Is it possible to get the HTML using Perl/CGI and then convert
> it into a string for pre-format before display? thanks in advance.
take a look at LWP Perl module:
ftp://ftp.gwdg.de/pub/languages/perl/CPAN/modules/by-module/LWP/
Regards
Alex
--
Ich studiere Elektrotechnik (Technische Informatik) an der RWTH Aachen
und bin ein guter Perl-Programmierer (arbeite seit 4 Jahren als Intranet-
Entwickler). Kann auch C, Java, SQL, JavaScript und HTML, CGI und TCP/IP.
Ich suche eine gut bezahlte Diplomstelle in Koeln, Aachen oder Umgebung.
------------------------------
Date: 4 Aug 1999 08:16:07 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: strange error
Message-Id: <7o8ss7$bqn$1@lublin.zrz.tu-berlin.de>
Makarand Kulkarni <makarand_kulkarni@my-deja.com> wrote in comp.lang.perl.misc:
>
>> Have a program with perfectly matched brackets, quotes, etc.
>
>Make sure you do not have braces/brackets on the comment lines.
...or in any kind of quoted text.
Anno
------------------------------
Date: Wed, 04 Aug 1999 18:37:48 +1000
From: gleeson@unimelb.edu.au (Martin Gleeson)
Subject: Re: tar
Message-Id: <gleeson-ya02408000R0408991837480001@news.unimelb.edu.au>
In article <MPG.121110d6aee93562989da9@nntp.hpl.hp.com>,
lr@hpl.hp.com (Larry Rosler) wrote:
>In article <slrn7qeq5c.vl8.fl_aggie@thepentagon.com> on 3 Aug 1999
>22:07:34 GMT, I R A Darth Aggie <fl_aggie@thepentagon.com> says...
>> On 3 Aug 1999 15:55:05 -0700, Tom Christiansen <tchrist@mox.perl.com>, in
>> <37a76539@cs.colorado.edu> wrote:
>> + The program is called, surprisingly enough, "tar". :-)
>> And who says TC can't be nice to beginners?
>Indeed.
>He forgot to add that 'tar' comes from 'Tape ARchive', which relates to
>a utility called 'ar' that makes archives. The tapes are long gone, of
>course.
>And a '.tar' file has come to be called a 'tarball' for some reason or
>other. Though 'tarbaby' might be better (per Uncle Remus).
I was under the impression that a gzipped or compressed tar file was
called a 'tarball'. Presumably for the reason that it's no longer a '.tar'
file.
Cheers,
Marty.
--
Martin Gleeson
Webmaster, The University of Melbourne, Australia.
<URL:http://www.unimelb.edu.au/%7Egleeson/>
Imagine, if you will, a world without hypothetical situations...
------------------------------
Date: 4 Aug 1999 07:04:34 GMT
From: fmgst+@pitt.edu (Filip M. Gieszczykiewicz)
Subject: Useless error when {} unbalanced
Message-Id: <7o8om2$9g3$1@usenet01.srv.cis.pitt.edu>
URGH! The longer my scripts get, the more annoying the perl error for
unbalanced {} is getting. Missing { is informative:
Unmatched right bracket at /tmp/mkHOME.pl line 103, at end of line
syntax error at /tmp/mkHOME.pl line 103, near "}"
Execution of /tmp/mkHOME.pl aborted due to compilation errors.
But boy you miss a } and you're screwed:
Missing right bracket at /tmp/mkHOME.pl line 1778, at end of line
syntax error at /tmp/mkHOME.pl line 1778, at EOF
Execution of /tmp/mkHOME.pl aborted due to compilation errors.
I have thus two strategies:
1) DATE all my changes and then search for latest date in src as
area of most likely trouble
2) vi's "%" matching of {}() for the brute-force cases...
not too fun with >1500 lines....
Oh gurus, what's the answer?
--
Filip "I'll buy a vowel" Gieszczykiewicz | http://www.repairfaq.org/
Always and everything for the better!
Now exploring whatever, life, and the meaning of it all... and 'not' :-)
------------------------------
Date: 4 Aug 1999 03:07:59 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Useless error when {} unbalanced
Message-Id: <slrn7qft5j.s67.abigail@alexandra.delanet.com>
Filip M. Gieszczykiewicz (fmgst+@pitt.edu) wrote on MMCLXIV September
MCMXCIII in <URL:news:7o8om2$9g3$1@usenet01.srv.cis.pitt.edu>:
'' URGH! The longer my scripts get, the more annoying the perl error for
'' unbalanced {} is getting. Missing { is informative:
''
'' Unmatched right bracket at /tmp/mkHOME.pl line 103, at end of line
'' syntax error at /tmp/mkHOME.pl line 103, near "}"
'' Execution of /tmp/mkHOME.pl aborted due to compilation errors.
''
'' But boy you miss a } and you're screwed:
''
'' Missing right bracket at /tmp/mkHOME.pl line 1778, at end of line
'' syntax error at /tmp/mkHOME.pl line 1778, at EOF
'' Execution of /tmp/mkHOME.pl aborted due to compilation errors.
''
'' I have thus two strategies:
''
'' 1) DATE all my changes and then search for latest date in src as
'' area of most likely trouble
Use RCS or another version control system, and check in often.
Also, since this error is a compile error, compile often. Even if
your program isn't going to work, compile, compile, compile. I always
hit ALT-P in my editor if I finish a subroutine, or reach another
"milestone". ALT-P saves the file, then runs perl -wc on it.
'' 2) vi's "%" matching of {}() for the brute-force cases...
'' not too fun with >1500 lines....
Don't make files that long. Perl has a lot of possibilities that can
help you in keeping smaller files.
Note that this isn't a typical Perl problem, other languages suffer
with the same "problem".
You could of course switch to Python that uses far less {}'s. ;-)
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 4 Aug 1999 09:33:24 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Using ActivePerl on Win32 (win98)
Message-Id: <37a7fad4_2@newsread3.dircon.co.uk>
Alyne & Warren <Warren@home.com> wrote:
> Hi All!
>
> I don't know if this question is appropriate -- please educate me if this is
> the wrong forum...
>
comp.infosystems.www.servers.ms-windows
> I'd like to use Perl on Window98. I have used a certain form on *nix
> machines successfully and would love to put it on my desktop, too. I
> downloaded Active Perl. I used my "form" (via IE) with a POST method and
> upon execution, IE thinks I am trying to download the file instead of
> posting data to it. Any ideas as to what I'm doing wrong? I use Perl all
> the time on *nix machines but am ignorant of the changes necessary to using
> it on Win32 boxes...
>
How to configure various HTTP servers to run Perl programs is discussed
in the Win32 Specific FAQ that is installed in as part of the HTML
documentation that can be found in your start menu.
/J\
--
"The chef's salty balls have dropped" - Christopher Price, BBC NEWS 24
------------------------------
Date: Wed, 04 Aug 1999 10:53:43 +0200
From: Alex Farber <alex@kawo2.rwth-aachen.de>
To: henryf@sminter.com.ar
Subject: Re: using perlcc
Message-Id: <37A7FF97.AC509B6@kawo2.rwth-aachen.de>
Hi Sebastian,
Matias Gorfinkiel wrote:
> I'm trying to compile a perl script on a Sun with Solaris 2.6 when I run
> perlcc xxxx.pl it gives me the following error:
>
> ld: fatal: library -ldb: not found
it is Berkeley db library (for .dbm files) but have no idea what's wrong.
Maybe you have to install it before Perl? (I have never installed Perl yet).
Regards
Alex
--
Ich studiere Elektrotechnik (Technische Informatik) an der RWTH Aachen
und bin ein guter Perl-Programmierer (arbeite seit 4 Jahren als Intranet-
Entwickler). Kann auch C, Java, SQL, JavaScript und HTML, CGI und TCP/IP.
Ich suche eine gut bezahlte Diplomstelle in Koeln, Aachen oder Umgebung.
------------------------------
Date: 4 Aug 1999 09:56:42 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Working Telnet Script Needed
Message-Id: <37a8004a_2@newsread3.dircon.co.uk>
HC <carvdawg@patriot.net> wrote:
>> it's ironic that you're complaining about a rant that I made to someone
>> who was ranting at someone else .. did you actually read the thread ? ..
>> I wonder why do I not see a similar post directed to "HC" ?
>
> Probably b/c I didn't rant at Chris.
>
No but you *did* whine:
HC <carvdawg@patriot.net> wrote:
>
> Wow, Dave! You don't have anything to contribute, so you hammer the guy!
> I know, I know, you're going to reply with something along the lines of "we're
> not required to give a response" or something similarly witless.
^K
/J\
--
"I sign my paintings Vincent because people can't pronounce Van Gough"
- Vincent Van Gough
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
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 V9 Issue 360
*************************************