[6380] in Perl-Users-Digest
Perl-Users Digest, Issue: 5 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 24 16:47:13 1997
Date: Mon, 24 Feb 97 13:00:20 -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 Mon, 24 Feb 1997 Volume: 8 Number: 5
Today's topics:
[Q] Pattern Matching with Lists? <pf@sys.uea.ac.uk>
Re: [Q] Perl in win3.11? (Ilya Zakharevich)
Re: ARGV fails on Win32/NT (Andrew Myers)
Breaking lines after n characters <ltorres@campus.ruv.itesm.mx>
Re: C-style preprocessing for a newbie... <seay@absyss.fr>
Re: Control character question <rootbeer@teleport.com>
Re: crypt() in NT Perl (Neil S. Briscoe)
EDI/X.12 related perl modules? <skolgan@Helios.goldworks.com>
Re: Email Problem (Neil S. Briscoe)
Formatting Question <rdarnese@nortel.ca>
Re: futur de perl et java-script <tchrist@mox.perl.com>
Re: How to override "open" function correctly <cedar.w.milazzo@boeing.com>
Re: How to spam - legitimately (William R. Somsky)
Re: How to spam - legitimately <tchrist@mox.perl.com>
Re: How to spam - legitimately (Chris Nandor)
Re: Inline packages <mconley@pms110.pms.ford.com>
Re: Links Related To comp.lang.perl.misc - FREE ACCESS <merlyn@stonehenge.com>
Re: Multi-line processing (Mike Stok)
Re: PERL for NT & Netscape Enterprise Server (Andrew Myers)
Perl FTP->HTML script?? (Neil Johnson)
Re: Random Temp File in Perl 5.002 <lmichael@gdc.com>
Re: Regular Expression question (Jeffrey)
Trying to understand regex's (Kevin Posen)
web opens DOS window on scripts <xaren@ascentech.com>
Re: Where is FAQ? (Nathan V. Patwardhan)
Re: Yet another desirable pack format: (was re: Strange <rootbeer@teleport.com>
Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 24 Feb 1997 19:13:38 +0000
From: Paul Felton <pf@sys.uea.ac.uk>
Subject: [Q] Pattern Matching with Lists?
Message-Id: <3311E862.41C6@sys.uea.ac.uk>
I don't know whether this is a simple question or not so apologies in
advance - I've only been writing in the language a few weeks.
I want to do something like this:
if ($list =~ /@MONTHS.*@MONTHS/)
where @MONTHS = ('Jan','Feb','Mar','Apr','May','Jun',etc);
This is a simple example (I don't actually want to use months) but it
illustrates the principle. I know it could be written as:
if ($list =~ /(Jan|Feb|Mar|Apr|May|June|etc).*(Jan|Feb|etc)/)
but this is a bit cumbersome and could become quite nasty with the lists
I actually want to use! I also need to extract which member of
the list it matched with.
Is this possible or am I trying to push the language too far?
TTFN
Paul
--
----------------------------------------------------------------------
Paul Felton, SYS, UEA, Norwich, NR4 7TJ +44 1603 592305
------ Views expressed are not necessarily those of SYS or UEA -------
"I'd rather be watching IPSWICH TOWN!"
------------------------------
Date: 24 Feb 1997 19:23:52 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: [Q] Perl in win3.11?
Message-Id: <5esps8$c8h$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Ric Harwood
<ric@discoveryinternational.com>],
who wrote in article <331162ed.1998281@news.demon.co.uk>:
> =head2 C<PERL_SH_DIR>
>
> Specific for OS/2. Gives the directory part of the location for
> F<sh.exe>.
>
> But not it seems where or how to set this [for dos/w3.11]. Unless I
> am loooking in the wrong place?
I do not follow you. What else do you want? Or maybe you do not know
how to set environment variables? Then you need to switch to your
friendly Win3.11 group.
Oups, I see what your confusion may be. I think I already fixed this
chunk in 3_28: it reads: "Specific for EMX port" instead of "Specific
for OS/2".
Note that if you use 3_05, then due to a bug you need to use forward
slashes in PERL_SH_DIR.
Ilya
------------------------------
Date: Mon, 24 Feb 1997 19:42:55 GMT
From: andy@tml.co.za (Andrew Myers)
Subject: Re: ARGV fails on Win32/NT
Message-Id: <3311ee38.16997116@news.pipex-sa.net>
On 19 Feb 1997 15:08:10 GMT, "Trond Ruud" <troruud@online.no> wrote:
>Hi,
>Does anyone know about this problem on NT installations:
>The script argument list ARGV is always empty!
>I.E:
>when issuing:
>
>$ test.pl arg1 arg2
HI
I had the same problem and spent 3 hours trying to get it to work
using the registry and many other ways - the final way we went was to
use the "querystring" environment variable.
eg
ENV{'querystring'} and this gets the "FIRST" argument only.
but you can always concatinate the arguments together and use the
"split" command to split them apart.
Hope this helps
Cheers
Andrew
------------------------------
Date: Mon, 24 Feb 1997 12:56:35 -0600
From: Luis Torres <ltorres@campus.ruv.itesm.mx>
Subject: Breaking lines after n characters
Message-Id: <3311E462.5755@campus.ruv.itesm.mx>
------------4B864A0E2B0C0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii
Hello all... anyone knows how to take a really big string and break it
into an "x" number of parts based on the number of characters on a
line... in other less confusing words Im getting a bunch of text and I
want to break it in many lines so it fits in a single window.
The text is the body of a mail message entered by the user of a web
email gateway... has anyone noticed that if you read that kind of
messages from Netscape mail all the text appears on one line (unless the
user hits return of course)
Ive tried to use the WRAP=PHYSICAL attribute to insert line breaks like
the ones that appear on the textarea but it doesnt work...
Hope you can help.
L.T.
------------4B864A0E2B0C0
Content-Transfer-Encoding: 7bit
Content-Type: text/html; charset=us-ascii
<HTML><BODY>
<DT> Hello all... anyone knows how to take a really big string and
break it into an "x" number of parts based on the number of characters
on a line... in other less confusing words Im getting a bunch of text and
I want to break it in many lines so it fits in a single window.</DT>
<DT> </DT>
<DT>The text is the body of a mail message entered by the user of a web
email gateway... has anyone noticed that if you read that kind of messages
from Netscape mail all the text appears on one line (unless the user hits
return of course)</DT>
<DT> </DT>
<DT>Ive tried to use the WRAP=PHYSICAL attribute to insert line breaks
like the ones that appear on the textarea but it doesnt work...</DT>
<DT> </DT>
<DT>Hope you can help.</DT>
<DT> </DT>
<DT>L.T.</DT>
</BODY>
</HTML>
------------4B864A0E2B0C0--
------------------------------
Date: Tue, 25 Feb 1997 01:47:21 +0000
From: Douglas Seay <seay@absyss.fr>
To: Douglas Seay <seay@absyss.fr>
Subject: Re: C-style preprocessing for a newbie...
Message-Id: <331244A9.5002@absyss.fr>
> Steven Kapp wrote:
> >
> > Hi,
> >
> > I would like to use Perl to expand a C-style macro "IFDEBUG(x)" to
> > "x". I have looked in the FAQ and CPAN but have not found anything that
> > does just this. Also, as I am relatively new to Perl, I am not sure if
> > I have found some regexp code which does this but I did not recognize
> > it.
> >
> > Steve
> > skapp@kodak.com
oops, I mis-read what you really asked.
try something like
$var =~ s/IFDEBUG\(([^)]*)\)/$1/;
the \( matches the opening paren
([^)]*) matches one or more non ) and saves it in $1
the \) matches the closing paren
in the second half of the s/// structure, the matched
section ("x") is substituted back in the string.
note that this won't handle nested ( ) pairs.
doug seay
seay@absyss.fr
------------------------------
Date: Mon, 24 Feb 1997 11:06:57 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Pierre Darbouze <pd34+@andrew.cmu.edu>
Subject: Re: Control character question
Message-Id: <Pine.GSO.3.95q.970224110553.22067L-100000@kelly.teleport.com>
On Mon, 24 Feb 1997, Pierre Darbouze wrote:
> suppose I am running a script, but I don't want the script to be
> terminated by a Ctrl-C, but rather I just want ^C printed to the screen.
> How could I accomplish this?
Find out what signal is sent by your system when Ctrl-C is pressed (often
SIGINT), then use the techniques in perlipc(1) to trap that signal. Hope
this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 24 Feb 1997 19:08:57 GMT
From: neilb@zetnet.co.uk (Neil S. Briscoe)
Subject: Re: crypt() in NT Perl
Message-Id: <memo.970224190731.4311A@zetnet.co.uk>
In article <330DABD1.7305@bgraham.com>, bgraham@bgraham.com (Bo Graham)
wrote:
> Hello,
>
> The crypt function is documented *not* to be supported in NT Perl. I am
> searching for the equivalent..... or failing that... an NT port of Matt
> Wright's wwwadmin.pl
>
Build 110 of NTPerl had, as a comment about one of its improvements
"crypt() now produces the same results as Unix." I'd expect later
versions to have kept that functionality.
Regards
Neil
------------------------------
Date: Mon, 24 Feb 1997 12:30:06 -0500
From: Serge Kolgan <skolgan@Helios.goldworks.com>
Subject: EDI/X.12 related perl modules?
Message-Id: <Pine.SOL.3.91.970224122757.14993M-100000@Helios.goldworks.com>
is there any tools available to do in/outbound EDI processing in perl?
any info will be greatly appreciated, because i fear that i'll have to
reinvent a bicycle...
please cc the answer to me as i am not reading this group regularly...
Greets,
Serge.
-----------------------------------------------------------------------------
... a confusion of the real with the ideal never goes unpunished. -- Goethe
------------------------------
Date: 24 Feb 1997 19:08:59 GMT
From: neilb@zetnet.co.uk (Neil S. Briscoe)
Subject: Re: Email Problem
Message-Id: <memo.970224190734.4311B@zetnet.co.uk>
In article <5elti3$rjs@news1.fast.net>, kolis@fast.net (Pat Kolis) wrote:
> Hi,
>
> I created a relatively simple form to capture information and then send
> an email to somebody. The form and CGI/Perl program work fine with one
> exception. When the email is sent and ultimately received, it lacks a
> subject and a from address.
>
> Does anyone know how to set these parameters? Code listed below.
> Thank you.
>
Yes. Don't use the mail program to send mail. Get libnet module from
your local CPAN site and use Net::SMTP. Then you can control all the
headers you put in your mail.
Regards
Neil
------------------------------
Date: 24 Feb 1997 20:06:55 GMT
From: Richard Arnesen <rdarnese@nortel.ca>
Subject: Formatting Question
Message-Id: <5esscv$9po@nrtphc11.bnr.ca>
First off thanks to everyone who answered my last question
about regular expressions.
Now what I want to do is print a filehandle to a file
using write and format.
If I use format to send it to stdout, no problemo.
However if I attempt to send it to a handle
I opened view the open() command I get errors on the
beginning of the format line. Am I missing something.
--
########################################################
# Richard D. Arnesen Jr. # The opinions stated do #
# Unix DCA Support # not necessarily reflect#
# Nortel, RTP # those of my employers #
# rdarnese@nortel.ca ##########################
###############################
------------------------------
Date: 24 Feb 1997 20:47:06 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: futur de perl et java-script
Message-Id: <5esuoa$34m$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
buhr@stat.wisc.edu (Kevin Buhr) writes:
:without waiting for someone to post an intermediate translation (and
:most of the time, someone will), you'll want to post in English.
I dunno. I haven't seen a translation of my posting. :-)
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
"The young think they are immortal, and are determined to prove otherwise."
--Larry Wall
------------------------------
Date: Mon, 24 Feb 1997 19:44:21 GMT
From: Cedar Milazzo <cedar.w.milazzo@boeing.com>
Subject: Re: How to override "open" function correctly
Message-Id: <3311EF95.4BE1@boeing.com>
Honza Pazdziora wrote:
>
> Cedar Milazzo <cedar.w.milazzo@boeing.com> writes:
>
> > Can anyone tell me how to override the "open()" function correctly?
> > I'd like to have a function called open which prepends a path to a
> > filename, then calls the regular open with the new filename. I have the
> > function which prepends the path defined as open now, but I can't make
> > the second part (calling the builtin open) work. Any ideas?
>
> Camel book page 289 says that the original versions of the built-in
> functions are always accessible via the CORE pseudopackage (eg.
> CORE::chdir()).
>
> Hope this is it.
>
> --
OK thanks.
But - and I may sound like a dunce here but I'm kinda new to perl - how
do I access the CORE::open() function? Do I have to somehow include
CORE?
Thanks again.
------------------------------
Date: 24 Feb 1997 19:52:29 GMT
From: somsky@dirac.phys.washington.edu (William R. Somsky)
Subject: Re: How to spam - legitimately
Message-Id: <5esrht$77t@nntp1.u.washington.edu>
In article <331192c1.44849480@samba.rahul.net>,
Terry Carroll <carroll@tjc.com> wrote:
> It's pretty common now to hear "email" as a noun. "eletter" would be an
> abomination.
Hmm... "email" as what I'd call a "substansive" noun I've heard:
"I got _some_ email". It's like "The postman delivered some mail"
or "I drank some water".
But "email" as what I'd call an "objective" noun I haven't heard:
"I got _an_ email". That'd be like "The postman delivered a mail"
or "I drank a water".
I suppose we could/might start using "email" in the sense of
"a piece of email" or "an email message", but I'm not comfortable
with it. But I agree that "eletter" doesn't sound right either.
I usually say things like "I receives some email" or "I received
an email message" or just "I received email", and avoid completely
the notion of _an_ email.
By the by, does anyone know if there are established terms for the
two different types/usages of nouns I'm referring to here as
"substansive" and "objective"? Ie, nouns/noun usages that specify
a substance that doesn't come in any discrete units, eg, "water",
"air" (atoms/molecules don't count here), things where you don't
say "I had 23 waters" (hmm... ordering "a water" meaning "a glass of
water" in a restaraunt would be a separate usage) versus nouns/noun
usages that specify discrete items that can be identified and
counted, things where you do say, "I see 3 cars"?
________________________________________________________________________
Dr. William R. Somsky somsky@phys.washington.edu
Department of Physics, Box 351560 B432 Physics-Astro Bldg
Univ. of Washington, Seattle WA 98195-1560 206/616-2954
------------------------------
Date: 24 Feb 1997 20:21:02 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How to spam - legitimately
Message-Id: <5est7e$34m$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, carroll@tjc.com (Terry Carroll) writes:
:>Why does this sound wrong to my ear?
:
:Because you haven't noticed the adaption of the English language?
People are always trying to learn me to talk good. They claim
it's adaption of the English language. I call it corruption.
:It's pretty common now to hear "email" as a noun.
Of course it's a noun. But it's a mass noun, just like mail
is, not a count noun, the way message is.
:"eletter" would be an
:abomination.
Hmm.. why is that?
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
You know, by the time you get done with all this, the "Swiss Army
Chainsaw" is going to be more like a Swiss Army Tactical Nuke.... :-)
--Brandon Allbery on perl in <1991Feb21.002412.20045@NCoast.ORG>
------------------------------
Date: Mon, 24 Feb 1997 15:34:48 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: How to spam - legitimately
Message-Id: <pudge-ya02408000R2402971534480001@news.idt.net>
In article <8cvi7itdjw.fsf@gadget.cscaper.com>, Randal Schwartz
<merlyn@stonehenge.com> wrote:
#If I know Tom, that's not what he's complaining about. In some minds,
#"email" is an aggregate noun, like "people". So, you can get a huge
#influx of "email", you just can't get 37 new "emails" (ugh, it even
#hurts my ears while I'm typing it). I suppose that's because "mail",
#at least in the US, is *also* an aggregate noun. The postman brings
#"the mail" for the day. I get a "piece of mail". I don't get 12
#"mails" in one day. Since email is derived from mail, I can see why I
#have the same weird reaction to "emails". (Ugh... just reacted
#again. :-)
#
#So, there's no such word as "emails".
Just because it doesn't make grammatical sense does not mean there is no
such word.
I contend it IS a word, and SHOULD be a word. That email is singular and
collective plural and emails is a legitimate plural form as well.
You were right on the money when you said you get "a piece of mail." Most
people, when they are talking about mail collectively, say "mail." But if
the plural emphasis is not on the mail as a collection but on the
individual pieces of mail, one says "pieces of mail."
Now, properly, one would expect someone to say "pieces of email." However,
this being the Internet, that is just too long and clumsy. So we adapt the
language to fit the standard.
If this were a language with a more full tense structure, we would have two
plural forms, one for "email" and one for "pieces of email." But we do
not. And since we are too lazy to say "pieces of email," "emails" will
have to suffice. You can't stop it. Don't even bother trying.
#================================================================
We used to laugh at Grandpa when he'd head off to go fishing. But
we wouldn't be laughing that evening, when he'd come back with
some whore he picked up in town.
--Jack Handey
Chris Nandor pudge@pobox.com
PGP Key 1024/B76E72AD http://pudge.net/
Keyfingerprint = 08 24 09 0B CE 73 CA 10 1F F7 7F 13 81 80 B6 B6
------------------------------
Date: Mon, 24 Feb 1997 14:43:43 -0500
From: Mike Conley <mconley@pms110.pms.ford.com>
Subject: Re: Inline packages
Message-Id: <3311EF6F.3DBF@pms110.pms.ford.com>
Thanks to Randal Schwartz for the answer. Randal suggested
BEGIN { package MyTest ..... }
BEGIN { MyTest->import(); }
and this worked just fine. (Actually they work both in the same
BEGIN block or both outside the BEGIN blocks too.)
Actually, my problem was understanding order of execution. The import()
must be called AFTER the package declaration is processed. My code
called import() from BEGIN processing, before the package was
processed.
Mike Conley wrote:
>
> Why won't myfunc import? How do I get it imported?
>
> #!/usr/local/bin/perl -w
>
> { package MyTest;
> use Exporter;
> @ISA = qw(Exporter);
> @EXPORT = qw(myfunc);
>
> sub myfunc {
> print "MyTest::myfunc called ...\n";
> }
>
> 1;
> }
>
> BEGIN { MyTest->import(); } # doesn't help
>
> MyTest::myfunc(); # 1. works
> myfunc(); # 2. doesn't work, why?
>
--
Mike Conley
mconley@ford.com
CAD/CAM/PIM Test Data Systems
ECC MD-5
24-81251 FAX: 39-04565
------------------------------
Date: 24 Feb 1997 13:28:10 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Links Related To comp.lang.perl.misc - FREE ACCESS
Message-Id: <8chgj2q78l.fsf@gadget.cscaper.com>
>>>>> "links" == links <links@m2c.com> writes:
links> For Free Access To Links Related To comp.lang.perl.misc Set Your Web Browser
links> To:
links> http://www.m2c.com/links/compute.htm
links> Courtesy Of Surfing Links By M2C
And the only two links that are here are to the fairly unmaintained
Perl page at UFL, and the perl5-info page at metronet. Not a whole
lot of stuff. Don't waste your time.
I've now rejected *two* of their attempts to post this mostly useless
information into comp.lang.perl.announce. Duh. Get a clue. :-)
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 553 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
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@ora.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: 24 Feb 1997 19:48:10 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Multi-line processing
Message-Id: <5esr9q$lic@news-central.tiac.net>
In article <3311ECF0.5B60@riag.com>, Daniel Mills <dmills@riag.com> wrote:
>Hello,
>How would I set up the following example to strip out all comments from
>a C program including those that extend over multiple lines of the input?
>I can't seem to make /m modifier work.
>
>open(FILEIN,'program.c');
>while(<FILEIN>){
> if(/(\*)(.*?)(\*)/){
> $comment_buf = $2;
> }
>}
The multiline modifier may well be working, from your regex it looks like
you probably wanted to use /s as it changes the interpretation of the .
metacharacter to include newlines, the /m affects the ^ and $ anchors.
Presumably you have set $/ to something like undef or "", as by default
the <FILEIN> reads a single line as a record so the regex only ever gets
to operate on a line a time anyway...
With the /s modifier the patten above might still mess up, maybr it's a
thinko that's caused you th think of the // delimiters in the regex as
part of the /* */ delimiters in the C.
Consider the following code & output
!/usr/local/bin/perl -w
$_ = ' this = some ("pseudo"); /* C code (*)
which contains a
multiline comment
*/
four = 2 * two;
if (it(works)) { ... ';
if(/(\*)(.*?)(\*)/s){
$comment_buf = $2;
print "Got '$comment_buf'\n";
}
if (($comment_buf) = m:/\*(.*?)\*/:s) {
print "Got '$comment_buf'\n";
}
__END__
Got ' C code ('
Got ' C code (*)
which contains a
multiline comment
'
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Mon, 24 Feb 1997 20:18:48 GMT
From: andy@tml.co.za (Andrew Myers)
Subject: Re: PERL for NT & Netscape Enterprise Server
Message-Id: <3311f052.17535013@news.pipex-sa.net>
>i have tried to follow the various instructions for PERL and
>for Enterprise Server 3.0beta2 and am now trying the following:
>
> http://host/cgi-bin/myscript.pl
>
>with the /cgi-bin/ being defined as a shell cgi directory from the
>netscape administration server - what i get back on the web page
>calling the script is an error message saying:
>
Hi
Make sure your Perl Program has this line before any output is
returned
print "Content-type: text/html\n\n";
Hope this helps
Cheers
Andrew
------------------------------
Date: Mon, 24 Feb 1997 20:02:58 GMT
From: njohnson@enterprise.net (Neil Johnson)
Subject: Perl FTP->HTML script??
Message-Id: <3311f00e.10391841@news.enterprise.net>
Hi,
I'm slowly starting to learn Perl and have attempted to write my first
script. I am trying to write a Perl script that will retreive an ftp
directory listing and create an HTML file will the files listed in it.
I hope to add options so it can sort the files by file date, size etc.
I have worked out how to create the HTML but don't know how to retrive
the file list in the directory. Is there a script already like this
that I could obtain to give me some hints??
Any help would be great!!!
Neil
njohnson@enterprise.net
------------------------------
Date: 24 Feb 1997 14:38:32 -0500
From: Laurence Michaels <lmichael@gdc.com>
Subject: Re: Random Temp File in Perl 5.002
Message-Id: <bhqafouc7uv.fsf@gdc.com>
tadmc@flash.net (Tad McClellan) writes:
>
> Mark Thompson (mwt@cyberg8t.com) wrote:
>
> : I need to make a random temporary file, sortof like tmpnam() in C.
> : Does Perl offer this functionality? If not, any suggestions on how to
> : implement something like this?
>
>
> This is not in the least bit "random", nor is it the least bit
> sophisticated, but it's what I usually do (I'm a non-random,
> unsophisticated type of guy ;-). I also don't want to spend more
> than 20 seconds figuring out how to get the temp file name that
> I want.
>
>
> for ($num=0; -e "/tmp/file.$num"; $num++) {}
>
> print "/tmp/file.$num is a unique filename\n";
>
>
> --
> Tad McClellan SGML Consulting
> Tag And Document Consulting Perl programming
> tadmc@flash.net
What about the (admittedly rare) occurence of ~18 million files in /tmp,
all called /tmp/file.0, /tmp/file.1, /tmp/file.2, ... /tmp/file.18000000?
Do scalars 'wrap' the way they do in C?
Perhaps a better way would be:
for ($num=1; ($num==0) or (-e "/tmp/file.$num"); $num++) {}
if (($num==0) and (-e "/tmp/file.0")) {die "No temp files available\n";}
else {print "/tmp/file.$num is a unique filename\n";}
Hope this helps,
Laurence Michaels
lmichael@gdc.com
I do not speak for GDC in any official or unofficial capacity.
------------------------------
Date: 24 Feb 1997 15:07:24 GMT
From: jfriedl@tubby.nff.ncl.omron.co.jp (Jeffrey)
To: tadmc@flash.net (Tad McClellan)
Subject: Re: Regular Expression question
Message-Id: <JFRIEDL.97Feb25000724@tubby.nff.ncl.omron.co.jp>
Tad McClellan <tadmc@flash.net> wrote:
|> : What is the correct output for
|> : ((a*)(b*))* Input: abbbababb?
|>
|> : I recently installed the win32 perl5 package and am unsure if
|> : it's giving me correct output.
|>
|>
|> It gives me the same output with 5.003 on Linux...
|>
|> It matches the above, but says $1, $2, and $3 are all empty.
This makes sense. All $1, $2, and $3 are subject to a final star, and the
final time the outer parens match, bth inner parens match nothing (as is
allowed). Hence, $1 contains nothing as well.
Had you had a set of parens around the *whole* thing, that $1 would be
the same as $&, the entire text matched.
|> Perl doesn't really match the longest possible string (maybe Jeffrey
|> will jump in here?).
It might sometimes match (what turns out to be) the longest string, it
might sometimes not. It's what I call regex-directed. As the engine works
back and forth through the regex trying to find a ``path'' that leads to
the end of the regex, the text matched when it finally gets there is the
match that's returned. For example, with the string "analogy", the regex
/a|an/ will find the first "a", even though the leading "an" is longer.
That's because the regex's leading "a" is matched before the "an" even gets
a chance.
Jeffrey
----------------------------------------------------------------------------
Jeffrey Friedl <jfriedl@omron.co.jp> Omron Corp, Nagaokakyo, Kyoto 617 Japan
See my Jap<->Eng dictionary at http://www.wg.omron.co.jp/cgi-bin/j-e
O'Reilly's Regular Expression book: http://enterprise.ic.gc.ca/~jfriedl/regex/
------------------------------
Date: Mon, 24 Feb 1997 20:41:22 GMT
From: posenj@lancet.co.za (Kevin Posen)
Subject: Trying to understand regex's
Message-Id: <5esue6$md6@news1.saix.net>
Hi.
I'm taking a course in Perl and am currently learning regex's. My book gave me this expression:
($first, $middle, $last) = (/\b(\w+)\b\s+\b(.*)\b\s?\b(\w+)\b/);
This is meant to put the words into their respective variables (first word into $first etc.). But it
doesn't work when using only one word because it can't find a last word and so no variables get
initialised. It is meant ot work (I can see this from the context of the program), and it comes out
of a published book (which should be checked). Is their a problem with my version of Perl (for DOS)
or is the book wrong?.
I derived this expression to do the task:
($first, $excess, $middle, $last) = (/\b(\w+)\b(\s?\b(.*)\b\s+\b(\w+)\b)?/);
The problem is that it has to introduce a fourth variable (which I could happily do without). Is
there a way to rewrite it using only my original three variables?
Any help is greatly appreciated!!!
Thanks.
Kevin Posen
------------------------------
Date: Mon, 24 Feb 1997 12:00:48 -0700
From: Wayne Will <xaren@ascentech.com>
Subject: web opens DOS window on scripts
Message-Id: <3311E560.7649@ascentech.com>
I'm almost certain I've missed something in setup.
When my scripts are opened from a browser, it dowloads it, and runs it
in a DOS window. I try taking off read access rights, and the browser
can't find the file.
I'm useing this to access the script from a form, and have reduced
everything to the simplest of commands.
<FORM METHOD="get" ACTION="temp/register.pl">
Can anyone help or give a suggestion?
No one around here has anymore Ideas.
Thanks.
------------------------------
Date: 24 Feb 1997 19:46:40 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Where is FAQ?
Message-Id: <5esr70$lfb@fridge-nf0.shore.net>
Daniel Mills (dmills@riag.com) wrote:
: I'm new to the group and would like to know how to get to the FAQ
Try: http://www.perl.com/perl/FAQ
--
Nathan V. Patwardhan
nvp@shore.net
"Lane, this is pure snow!
Do you have any idea what
the street value of this mountain is?"
--Charles Demar from _Better Off Dead_
------------------------------
Date: Mon, 24 Feb 1997 11:04:37 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Jonathan King <king@cogsci.ucsd.edu>
Subject: Re: Yet another desirable pack format: (was re: Strange pack/unpack...)
Message-Id: <Pine.GSO.3.95q.970224105316.22067K-100000@kelly.teleport.com>
On 24 Feb 1997, Jonathan King wrote:
> Any chance of seeing signed and ordered shorts after 5.004? Any
> better chance if I provided a nifty patch? :-)
Yes and YES. :-)
To be more explicit: The chances of seeing a feature in a future Perl
greatly improve when the patch has already been written. I don't know
enough to be able to say whether the Perl maintainers will feel this patch
to be useful enough to include. (Some of them may well loathe the idea,
while others may be writing the patch right now while reading Usenet in
another window. :-)
Before you write any code to implement this, you should probably ask the
folks at the Perl Porters Mailing List <perl5-porters@perl.org> what they
think. Be sure to tell them about how you want to implement this on
big-endian and little-endian systems. (That is, if it's supposed to "do
the same thing", it has to do it in a different way to make the same thing
happen.) Also, can you say why this should be a part of pack rather than a
module? (I'm not saying it shouldn't be a part of pack.)
If no one objects, or if you can reach a consensus, go ahead and start
coding. Good luck!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Jan 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
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 5
***********************************