[7950] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1575 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jan 3 16:07:37 1998

Date: Sat, 3 Jan 98 13:00:24 -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           Sat, 3 Jan 1998     Volume: 8 Number: 1575

Today's topics:
     Re: "Excessive Paranoia" using crypt (Frank)
     Re: "Excessive Paranoia" using crypt (Clay Irving)
     Re: 'flock'ing - how about a full server? <tcm@tcmd.com>
     Automatic E-Mail Forwarding <BEBEAU@prodigy.net>
     Re: Automatic E-Mail Forwarding <rootbeer@teleport.com>
     Re: Camel book v. Win32 <rootbeer@teleport.com>
     Re: Help with calculating Gunning (reading level) index <randy@theory.uwinnipeg.ca>
     Re: HELP! using a while statement NOSPAM@CAM.AC.UK
     Re: I need money [Re: I need a script] <*@qz.to>
     Re: I need money [Re: I need a script] <joseph@5sigma.com>
     Is it possible to upload a file to another server in pe <Rauch@netway.at>
     Re: Is it possible to upload a file to another server i <rootbeer@teleport.com>
     Re: newbie lost with MacPerl!! (Paul J. Schinder)
     Re: Perl for (almost) everyone (was: Re: Avoiding regul (brian d foy)
     Re: PERL programmer needed. (Tad McClellan)
     Re: Perl Trick? (Jeff Stampes)
     Re: PERLIPC - FIFO: parent, child, stalled! <rootbeer@teleport.com>
     Re: recomended Perl books ? <joseph@5sigma.com>
     Re: Simple(!) regular expression problem (Tad McClellan)
     Re: Simple(!) regular expression problem <*@qz.to>
     Re: Socket ? <rootbeer@teleport.com>
     Re: time module? (M.J.T. Guy)
     Re: Unix Grep equivalent in Perl <ebohlman@netcom.com>
     Re: uploading files in perl? (Clay Irving)
     What's The Best Way... (Tony K. Olsen)
     Re: What's The Best Way... <rootbeer@teleport.com>
     Re: word wrap routine (Gabor)
     Re: word wrap routine <rootbeer@teleport.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 03 Jan 1998 17:40:33 GMT
From: FHeasley@chemistry.com (Frank)
Subject: Re: "Excessive Paranoia" using crypt
Message-Id: <34ae7724.4549443@news.halcyon.com>

On 3 Jan 1998 02:13:53 GMT, wilson@tp.silkera.net (Wilson Fang) wrote:

>
>: Frank
>
>	hi, I met the same situation, try perl for win32 in
>	http://www.activestate.com/software/default.htm
>	this version of perl supports crypt function.
>
>	Wilson

Thank you, The activestate build of perl for win32 solved the problem.

and thanks to all the others who responded with info as to what the
error really meant.

Paranoia runs deep . . . 

Frank



------------------------------

Date: 3 Jan 1998 14:06:39 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: "Excessive Paranoia" using crypt
Message-Id: <68m27v$3f8@panix.com>

In <Pine.GSO.3.96.980102155913.26534k-100000@user2.teleport.com> Tom Phoenix <rootbeer@teleport.com> writes:

>On Fri, 2 Jan 1998, Frank wrote:

>> I'm trying to implement crypt, but I'm getting this wierd message that
>> says "Function not implemented due to excessive paranoia".
>> 
>> What does this mean?  

>When Perl gives you a message you don't understand, you should first check
>the perldiag manpage, which gives more details on hundreds of messages. 
>Hope this helps! 

perldiag for the HTML enabled:

  http://www.perl.com/CPAN/doc/manual/html/pod/perldiag.html

-- 
Clay Irving <clay@panix.com>                  I think, therefore I am. I think? 
http://www.panix.com/~clay/


------------------------------

Date: Fri, 2 Jan 1998 08:41:28 -0500
From: "Ernie Johnson" <tcm@tcmd.com>
Subject: Re: 'flock'ing - how about a full server?
Message-Id: <68iqdg$mbh$1@nr1.toronto.istar.net>

>: > >>  *) your file is accessed through NFS (flock() don't work well with
NFS)
>
>: Hmmm, I wasn't aware of this - maybe it's the source of your problem.


Could also be what I discovered while playing a bit more the other day...


web server space used 100% - some process ran it up to 100%, grabbed most
cpu time and memory.. few minutes later dropped to 66% used...  (my ISP
isn't too knowledgeable)

I have a hunch that my system was opening & reading my files... something
happened just after it cleared the contents for rewriting, ran up 100% used,
couldn't write and therefore wiped data.

Makes sense to me anyway... I'm just trying to confirm this with my ISP
today since they were closed and had a crashed web server for most of
yesterday (closed 9 online stores in the process).

Ernie Johnson
tcm@tcmd.com




------------------------------

Date: Sat, 03 Jan 1998 12:26:28 -0700
From: BEBEAU <BEBEAU@prodigy.net>
Subject: Automatic E-Mail Forwarding
Message-Id: <34AE90E4.4E6F@prodigy.net>

Hello, 
	I'm trying to receive an incoming e-mail (on Linux 2.0.27), break it
onto 500 character chunks, and forward those 500 character e-mails to
another e-mail address (my text pager can receive e-mails, but truncates
after 500 characters). BUT, I can't find any references to e-mail in any
of my perl books. It would need to operate on any incoming e-mail as
soon as it arrived. 
Any good ideas on how to work this?

	Elon Bar-Evan
	elonji@seqnet.net


------------------------------

Date: Sat, 3 Jan 1998 12:42:30 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: BEBEAU <BEBEAU@prodigy.net>
Subject: Re: Automatic E-Mail Forwarding
Message-Id: <Pine.GSO.3.96.980103123906.3188L-100000@user2.teleport.com>

On Sat, 3 Jan 1998, BEBEAU wrote:

> 	I'm trying to receive an incoming e-mail (on Linux 2.0.27), 

Perl doesn't (yet) receive mail directly! :-) You probably want to use
 .forward or procmail or both; check their docs or a newsgroup about email
for more information. Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



------------------------------

Date: Sat, 3 Jan 1998 11:41:19 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Mark Folse <markfolse@rocketmail.com>
Subject: Re: Camel book v. Win32
Message-Id: <Pine.GSO.3.96.980103114007.3188F-100000@user2.teleport.com>

On Fri, 2 Jan 1998, Mark Folse wrote:

> Is the Camel Book presumably as UNIX-centric as the Llama book? Is it a
> good investment for someone stranded behind the Windows in DOSneyland?

Yes, and yes. :-)  But there's something about this in the Perl-for-Win32
FAQ, which may be helpful. Good luck!

    http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



------------------------------

Date: Fri, 2 Jan 1998 22:04:32 -0600
From: Randy Kobes <randy@theory.uwinnipeg.ca>
Subject: Re: Help with calculating Gunning (reading level) index for documents
Message-Id: <Pine.GSO.3.96.980102215436.15678A-100000@theory.uwinnipeg.ca>

On 2 Jan 1998, Josh Kortbein wrote:

> M.J.T. Guy (mjtg@cus.cam.ac.uk) wrote:
> : Bass Player <fenderbass@evang.com> wrote:
> : >$GFI = int(( (100/$b) + $c) *0.4 ))
> : >
> : >The biggest stumbling block is trying to determine the number of syllables in 
> : >a particular word. Anyone got any help on this?
> 
> : That's really a question for a linguist, not for Perl.   And in general
> : it's difficult to answer, with lots of special cases.
> 
> Hmmmm... a linguist, you say?? I hear there a few linguistically-inclined 
> perl programmers running around. :)
> 
> 
> Josh

Hi,
   Perhaps one approach to the problem would be to use the TeX::Hyphen
module in $CPAN/authors/id/JANPAZ/TeX-Hyphen-0.06.tar.gz. This uses
TeX's hyphenation rules to split up words on line breaks, which would
be a good guide to figuring out the number of syllables. A default set
of rules is given if you don't have a TeX hyphenation file handy.
TeX gets this right essentially all of the time, and also 
supports languages other than English.

		Best regards,
		Randy Kobes


Physics Department		Phone: 	   (204) 786-9399
University of Winnipeg		Fax: 	   (204) 774-4134
Winnipeg, Manitoba R3B 2E9	email:	   randy@theory.uwinnipeg.ca
Canada				http://theory.uwinnipeg.ca/





------------------------------

Date: 3 Jan 1998 17:00:30 GMT
From: NOSPAM@CAM.AC.UK
Subject: Re: HELP! using a while statement
Message-Id: <68lqre$lef$1@lyra.csx.cam.ac.uk>

In article <688ron$9a8$1@lyra.csx.cam.ac.uk>,
M.J.T. Guy <mjtg@cus.cam.ac.uk> wrote:
>Inet Admin  <inet.admin@bridge.bellsouth.com> wrote:
>>
>>____chomp($yeah);_____
>>
>># This chomp removes any triling whitespace character from you input. In this
>>case, the \n
>># character, which is foiling your eq compare at the start of the while loop.
>
>Not quite.   chomp only removes the $/ character (\n by default).   It
>never removes any other whitespace character.

In the interests of pedantic accuracy:

chomp removes the $/ _string_ (or any number of trailing newlines if $/ is the
null string - i.e. in paragraph mode). It doesn't have to be a single character..

Chris Thompson
Email: cet1 at cam.ac.uk



------------------------------

Date: 3 Jan 1998 19:35:05 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: I need money [Re: I need a script]
Message-Id: <qz$9801031423@qz.little-neck.ny.us>
Keywords: from just another new york perl hacker

brian d foy <comdog@computerdog.com> wrote:
> joseph@5sigma.com posted:
> >I have a bank account that I want to have users add money.  It would
> >be great if someone could send money to it, using the $20 and $50
> >format please 
> your rates have a granularity of $20?

Hmmm, maybe I don't understand "granularity" the same way as you, but
I'd say that the granularity is $10 (the gcd here) and the minimum
payment is $20. With those units you can hit every non-negative integer
multiple of ten except for $10 and $30. (This is essentially the postage
stamp problem: given unlimited stamps of N different denominations, what
possible postage rates are possible? Would have made a more fun contest
problem than that peg game.)

> >Help me,
> >and also email with the amount you are sending thank you
> doesn't your bank send you a nice little notice after a wire transfer? 

Maybe he doesn't trust his bank.

> or maybe we should all get FV or CyberCash accounts for these 
> situations :)

I've got some Monopoly money I could send.

Elijah
------
works near a bank whose money machines give out $20s and $50s


------------------------------

Date: Sat, 03 Jan 1998 12:46:55 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: I need money [Re: I need a script]
Message-Id: <34AE954D.5D6F2F44@5sigma.com>

That'll be great.  No tax!

	-joseph

(ok, enough of this silliness)

Eli the Bearded wrote:

> I've got some Monopoly money I could send.


------------------------------

Date: Sat, 03 Jan 1998 21:05:42 +0100
From: Roland Rauch <Rauch@netway.at>
Subject: Is it possible to upload a file to another server in pearl?
Message-Id: <34AE9A15.335@netway.at>

Is it possible that a pearl script uploads a html file to another mirror
server, so when this file gets updated it would be updated on the mirror
too?

Thanx


------------------------------

Date: Sat, 3 Jan 1998 12:47:59 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Roland Rauch <Rauch@netway.at>
Subject: Re: Is it possible to upload a file to another server in pearl?
Message-Id: <Pine.GSO.3.96.980103124340.3188M-100000@user2.teleport.com>

On Sat, 3 Jan 1998, Roland Rauch wrote:

> Is it possible that a pearl script uploads a html file to another mirror
> server, so when this file gets updated it would be updated on the mirror
> too? 

I suppose that anything is possible. But I'm not sure what you're really
asking here.

When a file is uploaded, the recipient can't tell that it was a Perl
script which did the uploading. So there's nothing Perl-specific about
that. (Maybe you need to check the docs for the server, or a newsgroup
about such software.) 

If you want a Perl script to upload something to one, two, or twenty-three
servers, that's not too hard to do. (Of course, the point of mirroring is
that you should only have to upload once.) There are modules which can
help you to write uploading code.

If you want to make an FTP mirror, there's code on CPAN to help with that.

If you want something else, could you try asking again? Thanks!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



------------------------------

Date: 3 Jan 1998 11:10:36 -0500
From: schinder@leprss.gsfc.nasa.gov (Paul J. Schinder)
Subject: Re: newbie lost with MacPerl!!
Message-Id: <68lnts$h66@clark.net>

In <68kjkr$nru@mtinsc05.worldnet.att.net> "Creede Lambard" <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print> writes:


>I don't do much CGI so I can't help you with the creating cool web pages
>part. I hear there's a book on MacPerl coming out sometime this spring from
>O'Reilly, but I can't remember the name. Check their web page (www.ora.com,
>I believe) for information.

Not O'Reilly, but Prime Time Freeware.  The authors are Vicki Brown
and Chris Nandor.  Prime Time Freeware is at <http://www.ptf.com/>,
and draft chapters of the book in .pdf format are at
<http://www.ptf.com/macperl/ptf_book/draft.html>.


>Hope this helps!

>-- Creede




-- 
--------
Paul J. Schinder
NASA Goddard Space Flight Center
schinder@leprss.gsfc.nasa.gov


------------------------------

Date: Sat, 03 Jan 1998 12:15:12 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Perl for (almost) everyone (was: Re: Avoiding regular expressions)
Message-Id: <68lra5$lh2@bgtnsc02.worldnet.att.net>
Keywords: just another new york perl hacker

In article <Pine.GSO.3.96.980102133439.26534Q-100000@user2.teleport.com>, Tom Phoenix <rootbeer@teleport.com> posted:

> On Fri, 2 Jan 1998, brian d foy wrote:
> 
> > Tom Phoenix <rootbeer@teleport.com> wrote: 
> 
> > >Perl isn't the right language for everyone; maybe you should consider
> > >learning another language that better suits the way you think.
> > 
> > huh? [this seems like a strange comment from this source.  where's
> > Tom and what have you done to him?]
> 
> Not everyone can become a programmer, and not every programmer can become
> a good Perl programmer. Is there anything strange about that?

nothing strange other than i wouldn't have expected you'd be the
one to say it.  Tad or I perhaps, but you?  

some claiming to be Tom Pheonix also posted the simple reply of
"RTFM" the same day.  i was waiting for the alien abduction story
or something.

however, i like your point about communication.  not only do different
people grok their environment differently, but they sometimes have to
work on the same bits of code.  :)

-- 
brian d foy                                 <http://computerdog.com>


------------------------------

Date: Sat, 3 Jan 1998 10:47:01 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: PERL programmer needed.
Message-Id: <52ql86.ot.ln@localhost>

brian d foy (comdog@computerdog.com) wrote:
: In article <883714026.45875202@dejanews.com>, Marcus A. Davis <marcus@alex.net> wrote:

: >The Alexander Group, Inc. provides custom Internet Applications and is
: >seeking qualified PERL programmers.  Full and part-time positions are
                     ^^^^
: >available.  Please contact Marcus A. Davis at 888.253.9637 or send email
: >with resume.

: what's "qualified" and where in the world are you?


Maybe you need to know the difference between 'perl', 'Perl', and
'PERL' to be qualified?


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: 3 Jan 1998 14:56:43 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: Perl Trick?
Message-Id: <68ljjb$r7v$1@neocad.com>

Eddie Brown (eddie@NOSPAMMING.cs.odu.edu) wrote:
: Besides having a java program execute a perl prog: does anyone know
: of a way of having a perl program execute as soon as a page is accessed?

Sure...write a perl CGI that creates the HTML on the fly, and also
does whatever 'other' processing you're attempting


--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com


------------------------------

Date: Sat, 3 Jan 1998 11:54:16 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Jihad Battikha <jbattikha@highsynth.com>
Subject: Re: PERLIPC - FIFO: parent, child, stalled!
Message-Id: <Pine.GSO.3.96.980103114317.3188H-100000@user2.teleport.com>

On Fri, 2 Jan 1998, Jihad Battikha wrote:

> Tom Phoenix wrote:
> 
> > still allowing you to do what you need. (But do you really need 
> > symbolic refs? Those are easy to get wrong.)
> 
> Actually, the references won't be that exacting -- I'll be generating
> them on-the-fly using a session ID (based on date, time of order, IP
> address, and a random number).  

Sounds like something that should be done with a hash, but of course you
know more of the details than I do.

> The only symbolics refs left when I'm done will probably only be path
> variables. 

I don't know what that means. Do you mean your $ENV{PATH}? That shouldn't
be accessed via a symbolic reference, for security reasons if nothing
else. 

[ concerning the security aspects of a FIFO ]

> starting the FIFO with a read instead of a write.  That way, no other
> process will be able to read from the FIFO until it's written to
> (afterwhich the FIFO is deleted).  

I don't know: Unless you're sure about the order of process scheduling,
this could be hard to accomplish securely. (And I wouldn't assume anything
about the order of process scheduling.) But if you open it for read before
the fork, that might be all right. 

> I looked at the CPAN PGP module & it's just too darn thick.  It's also
> terribly documented for such an eloborate package.  

Maybe you need to write a better one and submit it to CPAN. :-) From
somewhere outside the US, of course. :-)  (Seriously, we could use a
really great PGP module, but (being an American) I can't do much about
this. Maybe one of the foreigners reading this should step in.) 

[ concerning a bug in your PGP binary ]

> I sent them the bug report initially & they didn't acknowledge the bug
> so I sent them a second report detailing the problem precisely but
> somehow I don't think I can count on a new release anytime soon... :-)

Maybe you should get the PGP source and see about fixing things. The
people in a newsgroup about PGP have always been helpful in these matters;
they may even have a patch or workaround already.

Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



------------------------------

Date: Sat, 03 Jan 1998 11:17:40 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: recomended Perl books ?
Message-Id: <34AE8064.B989B38F@5sigma.com>

Yes, no question about it--MRE is excellent.

	-joseph

Randal Schwartz wrote:
> 
> jay> If you plan on doing a lot of text manipulation, should take a
> jay> look at Mastering Regular Expressions (O'reiley too) and look at
> jay> the perlre manpage.
> 
> Jeffrey Friedl's MRE is a Very Good Book.  I've been hacking regular
> expressions for 20 years now (using Unix since 1977), and I *still*
> learned a surprising amount of stuff from this book.  Congrats, Jeffrey!


------------------------------

Date: Sat, 3 Jan 1998 10:39:58 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Simple(!) regular expression problem
Message-Id: <ukpl86.ot.ln@localhost>

Denard Springle (admin@vsgcom.com) wrote:

: > >Laurel Shimer wrote:
: > >>
: > >> I am very embarassed that I just don't get how to do regular expressions
: > >> yet... Have been staring at the Camel, the Llama book and the Perl Reference
: > >> Guidetrying to figure out how to make the following two variables match
: > >>
: > >> $reqinput ="360-WG-002 ";
: > >> $reqmatch =" 360-WG-002";

: Laurel,

: Perhaps try the /g option such as:

: if ($reqmatch =- /360-WG-002/g) && ($reqinput =- /360-WG-002/g){


/g has no effect if there is only one match in the string being
searched, as in her examples.


: or the /x option such as:

: if ($reqmatch =- /360-WG-002/x) && ($reqinput =- /360-WG-002/x){


The /x option has no effect at all the way have used it there.

Seems to me that it might work (if we could understand what "work"
meant to Laurel) without those options.

Why do you suggest those options?


: or, use a third variable if you need to assure a match on any kind of
: text such as:

: $match = "360-WG-002";
: if ($reqmatch =- /$match/g) && ($reqinput =- /$match/g) {
                ^^                          ^^
                ^^                          ^^

The third suggestion has problems too.


: for example? Is this what you are looking for??

Thank you for trying though.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: 3 Jan 1998 19:44:11 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: Simple(!) regular expression problem
Message-Id: <qz$9801031433@qz.little-neck.ny.us>

Tad McClellan <tadmc@metronet.com> wrote:
> Denard Springle (admin@vsgcom.com) wrote:
> : > >> $reqinput ="360-WG-002 ";
> : > >> $reqmatch =" 360-WG-002";
> : or the /x option such as:
> : if ($reqmatch =- /360-WG-002/x) && ($reqinput =- /360-WG-002/x){
> The /x option has no effect at all the way have used it there.

True, but through his fumbling he came close to something that
would work, albeit for the wrong reasons:

#!/usr/bin/perl -w
$reqinput ="360-WG-002 ";
$reqmatch =" 360-WG-002";
if ($reqinput =~ /$reqmatch/x) { print "Works\n" }'
__END__

> Seems to me that it might work (if we could understand what "work"
> meant to Laurel) without those options.
> 
> Why do you suggest those options?

Can't speak for him, but the /x will cause the whitespace to be ignored
in the regular expression.

Elijah
------
the /x option will also alter the meaning of # in REs


------------------------------

Date: Sat, 3 Jan 1998 11:58:37 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Eddie Dodwell <eddied@wwisp.com>
Subject: Re: Socket ?
Message-Id: <Pine.GSO.3.96.980103115600.3188I-100000@user2.teleport.com>

On Fri, 2 Jan 1998, Eddie Dodwell wrote:

> I am hoping someone can tell me why this code is returning the error:
>     Could not connect to server 
>     Address family not supported by protocol family

>     unless(connect(SOCKET, $remote_sock))
>     {
>         OutputError("Could not connect to server \n $!");
>     }

It looks as if the connect() call failed at the system level; check your
system's docs for connect(3) to find out why it might fail like that. Good
luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



------------------------------

Date: 3 Jan 1998 15:53:05 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: time module?
Message-Id: <68lmt1$joh$1@lyra.csx.cam.ac.uk>

oberon  <oberon@nospam.erols.com> wrote:
>On a different, but related topic:  I've been lurking here for some time
>now (>4 months), and have seen many persons "chastised" for asking a
>question to which a perusal of the perlfaq would have answered.  So,
>I've made an effort to try to find faq's with previously published
>answers to my questions.  It has helped me many times.  But, finding a
>related faq is rather difficult, given that many of the topics read like
>this: "How_can_I_count_the_n.."  I think most would agree that this is
>non-intuitive.  :)  Is there a list of complete faq topics?

It's not very elegant, and it's not Perl, but I usually do something
like

      grep ^=head2 /my/perl/path/lib/pod/perlfaq*

That'll produce a list of 284 items (currently), so you'll want to
send the output somewhere where you can search it.

Alternatively grep for appropriate keywords.


Mike Guy


------------------------------

Date: Sat, 3 Jan 1998 18:38:29 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Unix Grep equivalent in Perl
Message-Id: <ebohlmanEM8145.31F@netcom.com>

Vandana Agarwal <vagarwal@virgo.corp.sgi.com> wrote:

: What I want to do is given a file with key values only, extract the
: records from a master file (tab delimited ) where value in one of the
: fields matches the key read from the keyfile.
         ^^^^^^^
Does "matches" here imply exact equality (as your code snippet below 
seems to suggest)?  If so, there's a very efficient way to do the test.

: To keep things simple, we can assume that the keyfile only contains the
: keys and the keys appear as the first field in the master file.

: Here is my very first try at this :
: while (<KeyFile>) {
: 	$key = $_;
:         while (<MasterFile>) {
:                 ($masterkey,$restofrecord) = split(/    /);
:                 if ($key == $masterkey) {

'==' tests for *numeric* equality, not string equality.  You want 'eq' here.

:                         print OutFile $_;
:                 }
:         }

: As you can see, all it does is prints only one record that matches
: between the two files and obviously gets out of the loop.  

I don't see where it gets out of the loop.

: What I would like to do is 

: 	while (<KeyFile>) {
: 		$key = $_;
: 		$masterrec = grep($key,masterfile); /* don't know the syntax */
: 				
: 		print outfile, $masterrec;     
: 	}

: instead of sequentially going thru the master file for each key in
: keyfile. Not sure if there is a way to do this. Searched thru the
: Camel/Lama books, but to no avail.

What you want *could* be done by using Perl's grep() function on the 
list-context version of the file input operator.  But that would *still* 
involve sequentially going through the master file, and if indeed you 
only need to test exact equality, it would be slower than your previous 
code because you'd have all the overhead of a full regular-expression match.

If you *are* looking for exact matches, a much more efficient way to do 
it would be to read through the key file once and fill up a hash with 
the keys.  Then you read through the master file once, and for each 
record extract the key and test to see if the corresponding hash entry 
exists.  Something like:

 while (<KeyFile>) {
   chomp;
   $fkeys{$_}=1;
 }
 while (<MasterFile>) {
   ($masterkey,$restofrecord) = split(/    /);
   if (defined($fkeys{$masterkey})) {
     print OutFile $_;
   }
 }

If there are N keys in the key file and M records in the master file, 
this algorithm will do a total of N+M reads.  The scanning algorithm 
(either the one you described above or the grep-based one) will have to 
do N*M reads.  If, for example, you had 100 keys and 1000 records, the 
hash-based algorithm would do 1100 reads; the scanning algorithm would do 
100,000 reads.



------------------------------

Date: 3 Jan 1998 14:20:33 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: uploading files in perl?
Message-Id: <68m321$4el@panix.com>

In <34AD5149.2DB301F2@through.the.newsgroup> Rich Stevens <reach.me@through.the.newsgroup> writes:

>    I am trying to make a program that will allow users to upload files
>to my Web server.  If you have ever used GeoCities for posting Web
>pages, you know what I'm looking for.  I want my script to take a
>filename and upload it to me through a Web page.  I would really
>appreciate any help.

Go to Perl Reference and search on "upload" -- Result:

   File Upload
   Want to upload files to your web directory without using FTP or Telnet! 
   Thanks to new features in Netscape 2.0+, you can! This script allows 
   you to enter a name for the file to be saved as, and then select a file 
   on your computer to be uploaded to the WWW server. Administrators can 
   configure which directory they will allow files to be uploaded inside 
   the script to prevent tampering. This script is ideal for admin's who 
   want to allow users to upload files, but don't want to issue separate 
   telnet accounts or teach their users the ways of FTP. 

   form-setenv
   Export of html-form variables to the Environment with the REQUEST_METHOD 
   GET and POST if you use form-setenv.pl or when you use it as a module your
   get the value of the variable direct. Also supports the ENCTYPE method 
   "multipart/form-data" used by the fileupload function of Netscape. 

   ftp.pl
   This utility allows one to upload a file to the current directory using 
   Netscape 2.X or later versions. 

   The File Transfer System 
   With the File Trasfer System, web browsers can - Create new directories 
   with password protection (5 user definable levels available) - Delete 
   empty directories - Upload files - download files - delete files

-- 
Clay Irving <clay@panix.com>                  I think, therefore I am. I think? 
http://www.panix.com/~clay/


------------------------------

Date: Sat, 3 Jan 1998 20:13:10 -0000
From: tkolsen@btinternet.com (Tony K. Olsen)
Subject: What's The Best Way...
Message-Id: <MPG.f18abefdde79f58989681@news.btinternet.com>

Hi Everyone,

	I have a webpage form that posts its results to a perl program for 
output into an delimited text file.  This works fine but I want to add a 
'memo' type field to the form which can contain anything from a few words 
to a dozen pages of text.  I was thinking of storing this text as a 
separate text file in a sub-directory and have the text filename (hidden 
form variable) as the field in the delimited text file like such:

field1;field2;field3;field4;filename;field5

	I don't foresee this as a problem but I am curious as to the best 
way in which to implement something like this.  What is the best way to 
write the text area from the form into a text file while at the same time 
writing the rest of the data into the 'database'?  Any thoughts or advice 
greatly appreciated.

	Thanks for your time.  Cheers.
-- 
       ___
      (_B_)__
     ~(@ @)~
+-oOOo-(_)-oOOo-------------------------------------------------+
| "I played before the greatest fans in baseball, the Boston    |
| fans, and I know what you're going to say about that: Old     |
| Teddy Ballgame loved those fans, all right." --- Ted Williams |
+----------------+----------------------------------------------+
| Tony K. Olsen  | URL:     http://www.btinternet.com/~tkolsen  |
| Cheltenham, UK | Email:   mailto:tkolsen@btinternet.com       |
+----------------+----------------------------------------------+


------------------------------

Date: Sat, 3 Jan 1998 12:49:25 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: "Tony K. Olsen" <tkolsen@btinternet.com>
Subject: Re: What's The Best Way...
Message-Id: <Pine.GSO.3.96.980103124823.3188N-100000@user2.teleport.com>

On Sat, 3 Jan 1998, Tony K. Olsen wrote:

> What is the best way to write the text area from the form into a text
> file while at the same time writing the rest of the data into the
> 'database'? 

Best in what way? But I'd use a print statement for each. Is that what you
needed to know, or something else? Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



------------------------------

Date: 3 Jan 1998 17:48:31 GMT
From: gabor@vinyl.quickweb.com (Gabor)
Subject: Re: word wrap routine
Message-Id: <slrn6asu3l.ahs.gabor@vinyl.quickweb.com>

In comp.lang.perl.misc, brian d foy <comdog@computerdog.com> wrote :
# part of the problem is the perception of the reader, although
# i was a bit miffed when i posted that message.  it gets really
# annoying to watch people post code that won't work, especially
# when they didn't take the time to test it.  this makes it harder
# to help others because they don't realize what's good and 
# what's bad.  some of us are here to help others, and watching 
# bad code lead people down the wrong path is very frustrating.

It was me who posted it.  I am sorry that you got miffed about it.  I
decided to write a different version of wrap, called block_wrap.  It
wraps as a block, first line is same indent as rest and allows you to
set right_align and right_fill as well as tab size.

# 
# in this case, the re-invention of Text::Wrap is a classic scenario
# since each new "inventor" seems to make the same mistakes and
# post the same unworkable code.

Tell me what you think.

package Wrap2;

# Gabor Egressy
# gabor@quickweb.com

require Exporter;
@ISA = (Exporter);
@EXPORT = qw(wrap block_wrap);

use strict;
use vars qw($VERSION $columns $tabs $right_fill $right_align);

$VERSION = 98.010201;

BEGIN {
    $columns = 72;
    # how many spaces a tab should represent
    $tabs = 8;
    # fill right side with spaces to width; for block_wrap
    $right_fill = 0;
    # right align paragraph; for block_wrap
    $right_align = 0;
}

sub max_len_word(@);

sub block_wrap($@)
{
    my ($white,@wrap) = @_;
    return undef if @wrap < 1;
    my $fill = "";
    my $tmp_width = $columns;
    $wrap[0] =~ s/^\s+//;
    my $tmp_white = $white;
    $tmp_white =~ s/\t/' ' x $tabs/eg;
    $tmp_width -= length $tmp_white;
    $white = $tmp_white if $right_align;

    my @words = split /\s+/,join '',@wrap;
    if($tmp_width < max_len_word @words) {
        return wantarray ? @_ : join '',@_;
    }

    my $tmp;
    @wrap = ();
    for (@words) {
        if(length($_) + length($tmp) <= $tmp_width) {
            $tmp .= ' ' . $_; 
        }
        else {
            $fill = " " x ($tmp_width - (length($tmp) - 1))
                if $right_fill && ! $right_align;
            $tmp = $white . substr($tmp,1) . $fill . "\n";
            substr($tmp,0,0) = " " x ($columns - (length($tmp) - 1))
                if $right_align && ! $right_fill;
            push @wrap,$tmp;
            $tmp = ' ' . $_; 
        }
    }
    $fill = " " x ($tmp_width - (length($tmp) - 1))
        if $right_fill && ! $right_align;
    $tmp = $white . substr($tmp,1) . $fill . "\n";
    substr($tmp,0,0) = " " x ($columns - (length($tmp) - 1))
        if $right_align && ! $right_fill;
    push @wrap,$tmp;

    wantarray ? @wrap : join '',@wrap;
}

# This does the same thing as Text::Wrap
sub wrap($$@)
{
    my ($first_lead,$rest_lead,@wrap) = @_;
    return undef if @_ < 1;
    my ($flead,$rlead) = ($first_lead,$rest_lead);
    $flead =~ s/\t/' ' x $tabs/eg;
    $rlead =~ s/\t/' ' x $tabs/eg;

    my @words = split /\s+/,join '',@wrap;
    shift @words if $words[0] eq '';
    if($columns < max_len_word(@words) + length $flead) {
        return wantarray ? @wrap : join '',@wrap;
    }

    my $tmp;
    @wrap = ();
    while ($_ = shift @words) {
        if(length($_) + length($tmp) <= $columns - length $flead) {
            $tmp .= ' ' . $_; 
        }
        else {
            last;
        }
    }
    $tmp = $first_lead . substr($tmp,1) . "\n";
    push @wrap,$tmp;
    unshift @words,$_ if defined $_;
    $tmp = '';
    for (@words) {
        if(length($_) + length($tmp) <= $columns - length $rlead) {
            $tmp .= ' ' . $_; 
        }
        else {
            $tmp = $rest_lead . substr($tmp,1) . "\n";
            push @wrap,$tmp;
            $tmp = ' ' . $_; 
        }
    }
    $tmp = $rest_lead . substr($tmp,1) . "\n";
    push @wrap,$tmp;

    wantarray ? @wrap : join '', @wrap;
}

# for internal use
sub max_len_word(@)
{
    my $max = 0;

    for (@_) {
        $max = length if length > $max;
    }
    $max;
}

1;

__END__

=head1 NAME

Wrap - line wrapping to form either block paragraphs or regular indented ones

=head1 SYNOPSIS

use Wrap;

print block_wrap($indent,@text);
$Wrap::columns = 72;
$Wrap::tabs = 8;
$Wrap::right_fill = 0;
$Wrap::right_align = 0;

print wrap($first_line_indent,$rest_lines_indent,@text);
$Wrap::columns = 72;
$Wrap::tabs = 8;

=head1 DESCRIPTION

not yet done

=cut


gabor.
--
    The road to hell is paved with melting snowballs.
        -- Larry Wall in  <1992Jul2.222039.26476@netlabs.com>


------------------------------

Date: Sat, 3 Jan 1998 12:28:45 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Kuntal Daftary <daftary@_remove_to_send_email_.cisco.com>
Subject: Re: word wrap routine
Message-Id: <Pine.GSO.3.96.980103120018.3188J-100000@user2.teleport.com>

On Fri, 2 Jan 1998, Kuntal Daftary wrote:

> Tom Phoenix wrote:
> 
> > > # why does everyone want to try to re-invent Text::Wrap?
> > >
> > > It was a 'quick and dirty solution'.  It wasn't really meant to work
> > > perfect but just give an idea to the poster.
> > 
> > Compared to posting buggy code, it would have been better to give the
> > poster the idea of using a module, don't you agree?
> 
> yes. but sometimes not everyone is aware that a "module" exists for some
> particular task.

Ignorance may be a reason, but not a good excuse. 

Anyone who chooses to answer questions on Usenet should be allowed to make
mistakes, of course. We're only human, after all. But the person answering
a question must also be aware of the newsgroup's frequent questions and
answers - which this one certainly is. It only takes a moment's searching
on CPAN, in the FAQ, on Alta Vista or Deja News, or even in the various
docs supplied with Perl to find out about Text::Wrap. We ask the people
who _ask_ the questions to do this research for themselves; it's not too
much to ask this also of those who _answer_. 

> besides, people like me (i m not aware if there any out there) who
> (presently) shirk from anything OOPS oriented might not want to use a
> module (just a psychological thing rather than anything else). 

Did somebody say that all modules are OO? Or that Text::Wrap is? Not so.
And even if you don't understand OO programming, you may still be able to
use ready-made objects from a module.

And even if you're somehow allergic to using modules directly, you can
still get the module, cut out the code, and go to town with it. 

> finally, these are jsut opinions. isnt it better that the questioner
> gets multiple opinions: sureshot modules as well as QND snippets and
> himself figures out what best suites his situation? 

No. I'm in favor of the questioner himself deciding what's best, but let's
never use that as an excuse to say "anything goes". 

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



------------------------------

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 1575
**************************************

home help back first fref pref prev next nref lref last post