[11255] in Perl-Users-Digest
Perl-Users Digest, Issue: 4855 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 9 13:07:30 1999
Date: Tue, 9 Feb 99 10:00:22 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 9 Feb 1999 Volume: 8 Number: 4855
Today's topics:
(Off Topic) HTTP/LWP protocol oddness challange (Bill Moseley)
Converting CSV to LDIF <martin.lonnar@edt.ericsson.se>
Re: cookies pointers (Matt)
Counting the resolution of a TIFF <mpriatel@activesystems.ca>
download file with perl-script <mfn@hem.passagen.se>
Re: HELP on assoc. array (Larry Rosler)
Helpdesk script <efn@aakb.bib.dk>
how do I call a perl script from bourne shell mduwjd@maersk.com
Re: How do I use CGI.pm to fetch parameters? droby@copyright.com
Re: job hit counts, a mini unscientific survey <burton@lucent.com>
Re: job hit counts, a mini unscientific survey <burton@lucent.com>
Re: libwww for NT <KlausRusch@atmedia.net>
NEWBIE QUESTION: How do i code this? id# checking and d <paxtond@ix.netcom.com>
Re: Newbie Shopping Cart Question <burton@lucent.com>
Perl CGI Script EMails nothing <AE@Kline-uk.com>
Re: Problems with installation of Perl on LINUX box <Tony.Curtis+usenet@vcpc.univie.ac.at>
Re: Problems with installation of Perl on LINUX box <jimreidford@btinternet.com>
Re: Program needs compactification (Peter J. Kernan)
Re: regular expression (Charles DeRykus)
Re: regular expression (Bart Lateur)
Re: Rounding for Euro currency (Larry Rosler)
Re: sending mail from nt with perl 4.x...?? (Bart Lateur)
Re: Sorting on multiple fields <greg@erinedwards.com>
Understanding my yong@shell.com
use/require question? <cdlawson@xnet.com>
Using PERL system call with MS IIS 4.0 (Rolland Suh)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 9 Feb 1999 09:42:39 -0800
From: moseley@best.com (Bill Moseley)
Subject: (Off Topic) HTTP/LWP protocol oddness challange
Message-Id: <MPG.112a1368f07091d29896ab@206.184.139.132>
This started out as a Perl issue, but now I'm scratching my head.
If you hate off topic questions, please excuse me and move on. But if
you know HTTP protocol, or are a curious type....
[I did posted a similar question to the lower volume
comp.infosystems.www.authoring.cgi]
I use LWP::Simple and LWP::UserAgent to check that URLs are reachable
before redirecting to them in a script.
LWP is reporting pages at one site error 500s that I can reach fine via
Netscape or lynx. The 500 error is probably a problem with their
scripts. Fine.
But, since I can read the pages with lynx and Netscape but not with LWP,
I assumed LWP was the problem. I switched to using telnet to see if I
could figure out what the difference was.
What's driving me crazy is how is it that Netscape and lynx can read the
pages, but I can't via telnet or LWP?
Is it that telnet and LWP are doing something wrong? (Does Netscape and
telnet send crlf or just lf, and Netscape and lynx send the opposite?)
I though, "Well, their scripts are assuming they will get headers that
LWP isn't sending." So, I used Tom & Nathan's local little web server
(from The Perl Cookbook) to capture what lynx and Netscape send on a
request.
I then cut-n-pasted those request to telnet and still got the 500 error.
It only happens on some URIs at that site, too.
For example, here: what I'm sending via telnet (which I tried both from a
unix machine and from my Win 95 machine).
51) ~ %telnet www.library.ca.gov 80
Trying 206.40.21.202...
Connected to ferguson.library.ca.gov.
Escape character is '^]'.
HEAD http://www.library.ca.gov/ HTTP/1.0
Accept: text/html, text/plain, text/sgml, */*;q=0.01
Accept-Encoding: gzip, compress
Accept-Language: en
Host: 209.24.234.230
User-Agent: Lynx/2.8.1rel.1 libwww-FM/2.14
Negotiate: trans
HTTP/1.1 500 Server Error
Server: Netscape-Enterprise/3.5.1G
Date: Tue, 09 Feb 1999 17:27:47 GMT
Content-length: 305
Content-type: text/html
Connection: close
Ok, but watch this:
51) ~ %telnet www.library.ca.gov 80
Trying 206.40.21.202...
Connected to ferguson.library.ca.gov.
Escape character is '^]'.
HEAD http://www.library.ca.gov/index.html HTTP/1.0
Accept: text/html, text/plain, text/sgml, */*;q=0.01
Accept-Encoding: gzip, compress
Accept-Language: en
Host: 209.24.234.230
User-Agent: Lynx/2.8.1rel.1 libwww-FM/2.14
Negotiate: trans
HTTP/1.1 200 OK
Server: Netscape-Enterprise/3.5.1G
Date: Tue, 09 Feb 1999 17:02:53 GMT
Content-type: text/html
Last-modified: Fri, 22 Jan 1999 07:26:46 GMT
Content-length: 17671
Accept-ranges: bytes
Connection: close
So asking for '/' doesn't work, but '/index.html' does work (which by
Netscape return the same page). Maybe '/' is a cgi script that redirects
to index.html???
These one doesn't work either:
HEAD /html/main.cfm HTTP/1.0
or
HEAD / HTTP/1.0\
Accept: */*
User-Agent: Mozilla/4.05 [en] (Win95; I ;Nav)
Any ideas?
--
Bill Moseley mailto:moseley@best.com
------------------------------
Date: Tue, 09 Feb 1999 17:41:56 +0100
From: "Martin Lvnnar" <martin.lonnar@edt.ericsson.se>
Subject: Converting CSV to LDIF
Message-Id: <36C06554.98557BB7@edt.ericsson.se>
Hi,
Is there a script/module to quickly convert CSV files to LDIF files?
/martin lvnnar
------------------------------
Date: Tue, 09 Feb 1999 16:13:23 GMT
From: mtoledo@frognet.net (Matt)
Subject: Re: cookies pointers
Message-Id: <36c05ba9.3572797@news.frognet.net>
On Mon, 8 Feb 1999 10:13:50 +1100, Patrick Fong
<patfong@yoyo.cc.monash.edu.au> wrote:
>I dont think you can use Perl to read and write cookies... then again I am
>newbie :-).
There is a perl library that you can use that automates a lot of
cookie handling. I found it at...
HTTP Cookie Library Version 2.1
Copyright 1996 Matt Wright mattw@worldwidemart.com
Created 07/14/96 Last Modified 12/23/96
Script Archive at: http://www.worldwidemart.com/scripts/
Here is a snippet of code of mine that utilizes the cookie library
You'll have to alter it for your own needs.
#!/usr/bin/perl
###### Cookie Information ###########
require 'the path to the cookie-lib.pl file';
$Cookie_Path = '/';
$Cookie_Domain = '.mydomain.com';
&GetCookies('jones');
if ($Cookies{'jones'} ne '')
{
&GetCookies('jones');
print "Content-type: text/html\n\n";
print "<html>\n";
print "<head>\n";
print "<title>CGI Cookie Tester</title>\n";
print "</head>\n";
print "<body bgcolor='#FFFFFF' text='#000000'>\n";
print "<center><h1>I Found The Cookie!</h1>\n";
print "$Cookies{'jones'}\n";
print "</html>\n";
print "</body>\n";
}
------------------------------
Date: Tue, 9 Feb 1999 11:07:46 -0500
From: "Mark Priatel" <mpriatel@activesystems.ca>
Subject: Counting the resolution of a TIFF
Message-Id: <p6Zv2.4252$134.39459@tor-nn1.netcom.ca>
I'm trying to build a script which converts TIFF images to NIFF, the only
real difference being the header fields of the NIFF - one such field being
resolution.
Does anyone know how to count pixels in an image?
Any samples or pointers to sites/faqs would be really appreciated!
Thanks,
_____________________
Mark Priatel
ActiveSystems, Inc.
------------------------------
Date: Tue, 9 Feb 1999 18:47:46 +0100
From: "Martin Franson" <mfn@hem.passagen.se>
Subject: download file with perl-script
Message-Id: <36c07503.0@d2o11.telia.com>
Hi
I want to download a file from a server from a perl-script on my intranet.
An example: I want to see if a file called mat.html exist in the dir mfn
under http://hem.passagen.se
Is that possible?
Please help me if you can
... Martin Franson ...
------------------------------
Date: Tue, 9 Feb 1999 09:07:13 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: HELP on assoc. array
Message-Id: <MPG.112a0b1349a99586989a12@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <36C055FA.C77480E1@giss.nasa.gov> on Tue, 09 Feb 1999
10:36:26 -0500, Jay Glascoe <jglascoe@giss.nasa.gov> says...
...
> hi. Attached, please find a cleaned up version of your code.
...
> main();
> %!PS-Adobe-3.0
> %%Title: foo2.pl
> %%Creator: Jay Glascoe (using ps-print v3.06.3)
> %%CreationDate: 10:34:10 Feb 09 1999
> %%Orientation: Portrait
> %% DocumentFonts: Times-Roman Times-Italic Courier Courier-Bold Courier-Oblique Courier-BoldOblique Helvetica Helvetica-Bold
> %%Pages: (atend)
> %%EndComments
<SNIP> about 1000 lines of PostScript!
And I though vcards were bad...
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 09 Feb 1999 17:59:23 +0100
From: Esben Fjord <efn@aakb.bib.dk>
Subject: Helpdesk script
Message-Id: <36C0696B.BBC10526@aakb.bib.dk>
Does anyone know a good helpdesk script writen in perl and easy to
implement on a Windows NT server?
Thanks in advance
--
Esben Fjord Nielsen, IT-Konsulent/Webmaster (Consultant/Webmaster)
Aarhus Kommunes Biblioteker, Hovedbiblioteket, Moellegade 1, DK-8000
Aarhus C
Phone +45 8730 4541 Fax +45 8730 4540 email efn@aakb.bib.dk
web: http://www.aakb.bib.dk/hb
------------------------------
Date: Tue, 09 Feb 1999 15:53:38 GMT
From: mduwjd@maersk.com
Subject: how do I call a perl script from bourne shell
Message-Id: <79pllt$bd2$1@nnrp1.dejanews.com>
how do I call a perl script from bourne shell:
What would be the proper syntax to call perl from bourne and have the perl
program run concurrently. The perl script does decoding of web form data and
prints it to a log file. It is not necessary that the perl script return
anything to bourne.
I am trying the following code but the perl script does not pick up some of
the data from the form. /usr/lpp/perl/track& <STDIN
This code decodes everything and prints it to the log but does not return to
perl.
/usr/lpp/perl/track
Appreciate a response, thanks.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 09 Feb 1999 16:14:58 GMT
From: droby@copyright.com
Subject: Re: How do I use CGI.pm to fetch parameters?
Message-Id: <79pmtn$cjk$1@nnrp1.dejanews.com>
In article <3vNv2.58$hR.1144@news6.ispnews.com>,
"Sam Schulte" <schultsm@hotmail.com> wrote:
> The below should work Jonathan. Why can't people just answer questions in
> this group instead of all this "go read more" stuff?
>
Ahem.
Jonathan answered the question. The answer was "I dont see anything wrong
with the Perl code and the way in which it is called is out of the scope of
this group really."
That was the correct answer. Any remaining problem has absolutely nothing to
do with Perl. And is REALLY out of the scope of this group.
The Perl code works when called up by full URL, but not as a server-side
include (at least on my system). Precisely why is nicely documented in the
mod_include section of the Apache documentation. As is an approach to making
an SSI for this that works. (Posted by John Jarret elsewhere in this
thread.)
Whether the reason or solution is the same on el_pollo_diablo's system, I
wouldn't venture to guess, as I'm not an SSI guru.
At any rate, it's not Perl.
> #!/usr/local/bin/perl
>
> #####################
> # headlines.pl
> # Jonathan Stowe
> # 2/8/99
> #####################
This is rudeness in the extreme. Take credit for your own crap instead of
signing someone else's name to it.
It amazes me that in the same thread we have one poster saying this is an
appropriate place to ask SSI/CGI questions because we give sensible answers,
and another poster griping that we don't answer questions.
--
Don Roby
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 09 Feb 1999 10:56:23 -0600
From: Burton Kent <burton@lucent.com>
To: "Randal L. Schwartz" <merlyn@stonehenge.com>
Subject: Re: job hit counts, a mini unscientific survey
Message-Id: <36C068B7.12365ECC@lucent.com>
JAPH,
And what about my other favorite language --
Java?
Burton
Randal L. Schwartz wrote:
>
> Using Dejanews, I counted the number of times each of the following
> words appeared in "misc.jobs.offered" from 1 Oct 98 to today (about 15
> weeks):
>
> Unix 870K (queried as "unix | linux")
> C 510K (includes C++)
> Basic 390K (includes "visual basic")
> Cobol 240K
> HTML 210K
> Perl 140K <<<<<< ding ding ding
> Excel 120K
> CGI 61K
> Smalltalk 26K
> TCL 11K
> Fortran 10K
> PL/1 7K
> Lisp 3K
> Python 2K
>
> Note that Lisp beat out Python. :)
>
> print "Just another Perl hacker,"
>
> --
> Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
> Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
> Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
> Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
> Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Tue, 09 Feb 1999 10:56:40 -0600
From: Burton Kent <burton@lucent.com>
Subject: Re: job hit counts, a mini unscientific survey
Message-Id: <36C068C8.6A48C125@lucent.com>
JAPH,
And what about my other favorite language --
Java?
Burton
Randal L. Schwartz wrote:
>
> Using Dejanews, I counted the number of times each of the following
> words appeared in "misc.jobs.offered" from 1 Oct 98 to today (about 15
> weeks):
>
> Unix 870K (queried as "unix | linux")
> C 510K (includes C++)
> Basic 390K (includes "visual basic")
> Cobol 240K
> HTML 210K
> Perl 140K <<<<<< ding ding ding
> Excel 120K
> CGI 61K
> Smalltalk 26K
> TCL 11K
> Fortran 10K
> PL/1 7K
> Lisp 3K
> Python 2K
>
> Note that Lisp beat out Python. :)
>
> print "Just another Perl hacker,"
>
> --
> Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
> Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
> Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
> Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
> Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Tue, 09 Feb 1999 17:39:31 +0100
From: Klaus Johannes Rusch <KlausRusch@atmedia.net>
To: Bill.Palmer@online.disney.com
Subject: Re: libwww for NT
Message-Id: <36C064C3.838F3B8A@atmedia.net>
Bill Palmer wrote:
>
> Does anyone know where a version of libwww for perl WIN32 on NT might be
> found?
http://www.ActiveState.com/packages/zips/
Klaus Johannes Rusch
--
KlausRusch@atmedia.net
http://www.atmedia.net/KlausRusch/
------------------------------
Date: Tue, 09 Feb 1999 11:26:46 -0500
From: "Mr. Paxton *S*" <paxtond@ix.netcom.com>
Subject: NEWBIE QUESTION: How do i code this? id# checking and decrement
Message-Id: <36C061C4.6A7E00BD@ix.netcom.com>
Thanks to the help of several people on this newsgroup I now have a
working perl script/html form combination that takes the input from the
form, error checks it, scores the test portion of the input, writes a
web page, writes to several files, and send email back to the person who
filled out the form. I have one other aspect that I need to put in the
script. I have thought about this particular addition for some time and
would like to implement it. I would like to be able to use the
identification number that the form user enters to check a text file I
have set up that contains the users' id numbers and how many times they
may use the form to score the test. I would then like to decrement that
associated number for each usage. When the number reaches zero I would
like the script to generate an html document saying such and of course
not let the user score the test. So I guess I need a text file where
each line contains the user id # and number of times left? So, my
question is (if you haven't figured it out yet) how do I code this?
1) check text file for id #
2) check same text file for "number of times left to use"
3) decrement "number of times left to use" after form has been
successfully processed (write to text file, overwriting current "number
of times left to use" with lower nimber for the associated id)
4) create html document for user to see if id# is not found in text file
and/or "number of times left to use" has been decremented to 0.
I hope that I have explained this well enough to follow.
Thanks,
Dan
--
Please remove "nospam" in order to reply...
------------------------------
Date: Tue, 09 Feb 1999 11:02:02 -0600
From: Burton Kent <burton@lucent.com>
Subject: Re: Newbie Shopping Cart Question
Message-Id: <36C06A0A.7742E0F8@lucent.com>
Minivend runs as a daemon, watching a socket which
will be called by the .CGI program. Since the daemon
is already up and running, and the .cgi caller is
very small, it's -=FAST=-. Responds to requests,
in a jiffy, even if your databases of products
are huge.
It's a bit of a memory hog, but does its job better
than anything else available. At least the last time
I checked.
I like it a lot.
Burton
Kevin D. Chester wrote:
>
> Hi B. Funk,
>
> I see that you recommended Minivend to this person. Is it easy to install and
> get up & running? What's the deal with it being a daemon (sp?). I visited on
> of the sites that currently running it and the site did minivend's version
> of a "time out". Is this common or only with high traffic sites. Currently
> I'm running a version of perlshop and like some of the options that I see in
> minivend. In you opinion is minivend an upgrade or basically the same as what
> I'm currently using?
>
> Thanks for the input!
>
> Kevin
>
>
------------------------------
Date: Tue, 9 Feb 1999 16:40:12 -0000
From: "AE { : - )" <AE@Kline-uk.com>
Subject: Perl CGI Script EMails nothing
Message-Id: <918583026.26052.0.nnrp-10.c2dee8a1@news.demon.co.uk>
Hi I have been just starting to learn perl and my first script just don't
work.
It debugs ok and it sends the mail ok. Unfortunately it does not send the
main message and i cannot find a syntax error in the script.
I know it's bad practice to just post a load of code to a ng however if
anyone can see a bug screaming out then please mail me.
I checked the content length and the script definately receives some text
but then loses it somewhere
Thanks in advance
Alex
#! /bin/perl
#This is the sub main part of the script
%data_in = &Parse_String();
foreach $key (sort keys(%data_in))
{
$mail .="$key:\n";
foreach (split (" : ",$data_in{$key}))
{
$mail .= "$_\n\n";
}
}
&Email_Str ($mail);
&ResponsePage;
sub Parse_String
{
local (%Parse_String, $Parse_String,$Pair_Value,@Pair_Values,$name,$value);
#Check how the data was sent : POST or GET
if ($ENV{'REQUEST_METHOD'} eq "POST")
{
read(STDIN,$Parse_String,$ENV{'CONTENT_LENGTH'});
}
else
{
$Parse_String=$ENV{'QUERY_STRING'};
}
#NOW TAKE THE STRING AND CONVERT + TO SPC
$Parse_String=~ s/\+/ /g;
#CREATE ASSOCIATIVE ARRAY AND ADD VALUES
@Pair_Values= split(/&/,Parse_String);
foreach $Pair_Values (@Pair_Values)
{
($name,$value)=split(/=/,$Pair_Values);
$name= ~s/%([a-fA-F0-9] [a-fA-F0-9])/pack("C",hex($1))/ge;
$value= ~s/%([a-fA-F0-9] [a-fA-F0-9])/pack("C",hex($1))/ge;
#IF MULTIPLE VALUES WITH SAME NAME THEN DEAL WITH IT
if (defined($Parse_String{$name}))
{
$Parse_String{$name} .= " : " . $value;
}
else
{
$Parse_String {$name}=$value;
}
}
return %Parse_String;
}
#Write Confirmation Page
#Temporary Response Page
sub ResponsePage {
local (%ResponsePage);
print "Content-type: text/html\n\n";
print "<html><Title>Form Posted</Title>";
print "<Body><p><p><p><p><H1>Thankyou For Filling this Form in</H1>";
Version</a>";
print "</Body> </html>";
return %ResponsePage;
}
#send Email
sub Email_Str
{
local ($message) =@_;
open (MAIL, "|/usr/lib/sendmail -t") ||
die "Context-type: text/text\n\nCan't open /usr/lib/sendmail !\n";
print MAIL "To: alexe\@kline-uk.com\n";
print MAIL "From: alexe\@kline-uk.com\n";
print MAIL "Subject: Mail FeedBack\n";
print MAIL "$message \n\n";
return close(MAIL)
}
--
The Wizzard
------------------------------
Date: 09 Feb 1999 17:05:25 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Problems with installation of Perl on LINUX box
Message-Id: <83d83jwoje.fsf@vcpc.univie.ac.at>
Re: Problems with installation of Perl on LINUX box,
Jim <jimreidford@btinternet.com> said:
Jim> Trying to install the latest version of
Jim> Perl(5.005) and it fails during the run of the
Jim> Configure script as it tries the test compile.
Jim> Error message
Jim> /usr/i486-linux/bin/ld: cannot open -ldl: No
Jim> such file or directory I can' compile the test
Jim> program (The supplied flags might be incorrect
Jim> with this C compiler)
You don't appear to have the dynamic linking (-ldl)
library on your system. You need to find out if you
really need it for your system/distribution and if
so, get it and install it from that distribution.
(This thread then should be moved into a linux
newsgroup.)
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien. | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: Tue, 09 Feb 1999 16:19:14 +0000
From: Jim Reidford <jimreidford@btinternet.com>
Subject: Re: Problems with installation of Perl on LINUX box
Message-Id: <36C06002.29FA@btinternet.com>
Tony Curtis wrote:
>
> Re: Problems with installation of Perl on LINUX box,
>
> Jim> Error message
>
> Jim> /usr/i486-linux/bin/ld: cannot open -ldl: No
> Jim> such file or directory I can' compile the test
> Jim> program (The supplied flags might be incorrect
> Jim> with this C compiler)
>
> You don't appear to have the dynamic linking (-ldl)
> library on your system. You need to find out if you
> really need it for your system/distribution and if
> so, get it and install it from that distribution.
>
> (This thread then should be moved into a linux
> newsgroup.)
>
> hth
> tony
Thanks for the pointer Tony, when I ran the script I just took the
defaults thinking that was safer. Strangely during the script it
appeared to find the library as it gave a message
Found -ldl (shared)
Would I be correct in thinking that i don't necessarily need dynamic
linking
--
Jim Reidford
--
"Due to financial constraints,
the light at the end of the tunnel
has been turned off until further notice !!"
------------------------------
Date: 9 Feb 1999 16:01:56 GMT
From: pete@theory2.phys.cwru.edu (Peter J. Kernan)
Subject: Re: Program needs compactification
Message-Id: <79pm5k$5vt$1@pale-rider.INS.CWRU.Edu>
In article <79lipn$m69$1@client2.news.psi.net>,
abigail@fnx.com (Abigail) writes:
> perl -pale '@F{@F}=@F}for(keys%F){'
inspired by this strange and sneaky construct and a kind note from
one of my perl betters;
perl -la0pe '}for (sort keys%{{map{$_,1}@F}}){'
(not as concise, but almost as nice)
--
The cat will mew, and dog will have his day. --Hamlet
------------------------------
Date: Sat, 6 Feb 1999 01:39:35 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: regular expression
Message-Id: <F6pLxz.6AI@news.boeing.com>
In article <36BB817E.395A@boeing.com>,
JD Anderson <jd.anderson@boeing.com> wrote:
>I need a pattern like this X.+Y except it must exclude the instance
>XrrY.
Perhaps, just:
/X.+Y/ and !/XrrY/
but, here's a single regex possibility:
/X # pattern opens with X
(?: # then alternatives:
(?:.?) | # 0 or 1 character ok
(?:[^r]r) | # 2 chars - no starting r
(?:r[^r]) | # 2 chars - no ending r
(?:[^r][^r] | # 2 chars - neither r
(?:...+) # any 3 or more char's
) # end alternatives
Y/sx; # pattern ends with Y
perldoc perlre for meanings of C<s> and C<x> modifiers.
hth,
--
Charles DeRykus
------------------------------
Date: Tue, 09 Feb 1999 17:18:08 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: regular expression
Message-Id: <36c06cdb.247382@news.skynet.be>
JD Anderson wrote:
>I need a pattern like this X.+Y except it must exclude the instance
>XrrY.
Why? Er... not my problem. You could use negative lookahead. Or, you
could try something like this:
while(/(XrrY)|(X.+Y)/g) {
next if $1; # /XrrY/
# now it matches /X.+Y/ but not /XrrY/
blah;
}
It *could* be faster than the negative lookahead.
Bart.
------------------------------
Date: Tue, 9 Feb 1999 08:51:45 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Rounding for Euro currency
Message-Id: <MPG.112a076f4efa01df989a11@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <m1u2wvr444.fsf@halfdome.holdit.com> on 09 Feb 1999 07:25:31
-0800, Randal L. Schwartz <merlyn@stonehenge.com> says...
> >>>>> "Larry" == Larry Rosler <lr@hpl.hp.com> writes:
>
> Larry> $new = sprintf("%9.2f", int($old*20+.5) /20);
>
> Larry> should do just as well, and somewhat faster. Why pad to a nine-
> Larry> character string when all you want is a number?
>
> Well, here's another way. sprintf "%.0f" *rounds*, it doesn't
> truncate. (It's %d and int() that *truncate*.) So, let's use
> sprintf twice:
>
> $new = sprintf "%.2f", (sprintf "%.0f", $old * 20) / 20;
>
> And that should work for both positive and negative numbers, although
> we're going from number to string twice. Ugh. :)
>
> print "Just another Perl sprinter,"
Good thought! You omitted to quote this from the remainder of my post:
LR> Someone should note that this 'add 0.5 and truncate to int'
LR> algorithm fails if the value is negative. Probably the simplest
LR> way to round an arbitrary number to integer is:
LR>
LR> ... sprintf('%.0f', $old * 20) ...
Just Another illustration of how 'great minds think alike'! :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 09 Feb 1999 16:36:38 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: sending mail from nt with perl 4.x...??
Message-Id: <36c06395.19674244@news.skynet.be>
jamesht wrote:
>Subject: sending mail from nt with perl 4.x...??
>I'm sorry to ask you about this terribly hobbled system, but that's what
>I have to work with.
Jeezes! Perl4! Why don't you just try to run DOS instead?
;-)
>How does one send mail from nt without using a module?? Are there good
>libraries, or a good reference? All I've ever seen has either been for
>sendmail or for some win32 module...
Maybe "BLAT.EXE" is your answer. That is sortof a Sendmail equivalent
for NT, controllable through the command line.
Bart.
------------------------------
Date: Tue, 09 Feb 1999 12:09:10 -0500
From: Gregory Rohman <greg@erinedwards.com>
Subject: Re: Sorting on multiple fields
Message-Id: <36C06BB5.7E128EC9@erinedwards.com>
Thanks for the link... problem solved!
James Ludlow wrote:
>
> Gregory Rohman wrote:
>
> > Is there a way to sort the records in reverse-chronological order? I
> > don't need them sorted in the actual text data file... they just need to
> > be sorted by day, month, and year when they are printed back out.
>
> The FAQ is your friend:
>
> http://www.perl.com/CPAN-local/doc/FAQs/FAQ/PerlFAQ.html#How_do_I_sort_an_aray_by_anyth
>
> $ perldoc perlfaq4
>
> --
> James Ludlow (ludlow@us.ibm.com)
> (Any opinions expressed are my own, not necessarily those of IBM)
--
Gregory E. Rohman, Producer | greg@erinedwards.com
Erin/Edwards Communications | http://www.erinedwards.com/greg
http://www.erinedwards.com
------------------------------
Date: Tue, 09 Feb 1999 17:27:22 GMT
From: yong@shell.com
Subject: Understanding my
Message-Id: <79pr5c$h0d$1@nnrp1.dejanews.com>
Programming Perl says "Subroutines called from within the scope of such a
private variable cannot see the private variable unless the subroutine is also
textually declared within the scope of the variable." But why does the code
below print a my variable correctly?
#!/usr/shell/bin/perl -w
{ my $a="TEST";
&mysub($a);
}
sub mysub
{ print "This is a test of ", shift, ".\n";
}
It prints "This is a test of TEST." But mysub is declared outside of $a's
private block. Thanks.
Yong
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 9 Feb 1999 17:18:45 GMT
From: Chad Lawson <cdlawson@xnet.com>
Subject: use/require question?
Message-Id: <79pqll$huc$1@flood.xnet.com>
I asked this question before, but I phrased it badly, so I don't think
anyone knew what I meant...
Instead of maintaining one large perl script, I would like to break down
the file into pieces with each file containing the routines related to
one type of function.
I.e. all my address book functions in one file, the threaded message board
functions in another.
Then, at run time, the main file (index.cgi) will load all the files with
thier pieces into itself. Meaning each of these snipits of code are all
part of the main:: namespace.
Is there a way to have a script be broken up into multiple files, but at
runtime be treated as ONE file. As if I WAS maintaining one large file
with all the functions in it?
If I'm still not being clear, please let me know.
Thanks in advance,
Chad Lawson
"He deals the cards as a mediation...the sacred geometry of chance,
the hidden law of a probable outcome, the numbers lead a dance."
--Sting, "Shape of My Heart"
------------------------------
Date: 9 Feb 1999 10:55:31 -0600
From: rolland@MCS.COM (Rolland Suh)
Subject: Using PERL system call with MS IIS 4.0
Message-Id: <79ppa3$4pg@Mars.mcs.net>
Keywords: IIS system call child fork
Hi,
With PERL and MS IIS 4.0, how can I use "system" call to run a child process,
and have the result go back through the parent, to the IIS and finally back
to the browser? (All through the parent's STDOUT)
Please consider the following code. Whenever I run parent.pl, I know that
child.pl gets executed, but the "Hello World from Child Process" never makes
back to the parent, and therefore it never makes back to the browser through
IIS. I guess child.pl cannot access the STDOUT of the parent.pl.
parent.pl
$|=5; # Flush everything.
print "Content-type: text/html\n\n";
print "Trying to call child process.\n";
system "perl.exe child.pl" || die "Could not fork.";
print "Finished calling child process.\n";
child.pl
$|=5; # Flush everything.
print "Hello World from the Child Process.\n";
Thanks in advance,
Rolland
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 4855
**************************************