[8294] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1911 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 16 21:27:26 1998

Date: Mon, 16 Feb 98 18:01:55 -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, 16 Feb 1998     Volume: 8 Number: 1911

Today's topics:
    Re: Passing values into a subroutine from an array... <chris@ixlabs.com>
    Re: Passing values into a subroutine from an array... (Abigail)
        perl connect to postgresql or mysql (Vanselow)
        Perl training in the UK <tony@furness.co.uk>
        Perl-to-"C" converter? <crb@netunlimited.net>
    Re: Perl-to-"C" converter? (Martien Verbruggen)
    Re: PGP - Perl puzzle <iggiebee@rhpworld.org>
    Re: Printing $query->param in a here-doc? <ajh@rtk.com>
    Re: Regex & locales. (Ilya Zakharevich)
    Re: regexp: /^[800|888]/ vs. /^8[0{2}|8{2}]/ (Craig Berry)
        Remove files in a PERL sript <ptbs@mail.dma.be>
    Re: Replace in HTML files (Martien Verbruggen)
    Re: Replace in HTML files (Craig Berry)
    Re: RFC about "Matt's Script Archive" <rjk@coos.dartmouth.edu>
    Re: RFC about "Matt's Script Archive" (Frank)
    Re: RFC about "Matt's Script Archive" (Nathan V. Patwardhan)
    Re: RFC about "Matt's Script Archive" (Nathan V. Patwardhan)
    Re: RFC about "Matt's Script Archive" <merlyn@stonehenge.com>
    Re: Running Perl (Martin Vorlaender)
    Re: Sending mail from perl (was Re: Newbie question) (Martien Verbruggen)
        signals in Perl, should I use C instead? (Gabor)
        sockets to webservers <dev@sgi.net>
    Re: Sorting some text in Perl (steve)
    Re: Sorting some text in Perl (Craig Berry)
    Re: Sorting Strings With Delimited Characters - Advice  <ldanna@hotmail.com>
    Re: Sorting Strings With Delimited Characters - Advice  <peter.edlund@capgemini.se>
    Re: System function to variable <rra@stanford.edu>
    Re: Testing integer <joseph@5sigma.com>
    Re: The 'study' function (Ian Kallen)
    Re: The Young Man and the Beach <rra@stanford.edu>
    Re: The Young Man and the Beach (brian moore)
    Re: what is exaclty the "_" Variable ?!?! (Jonathan Feinberg)
    Re: Why is Tom Christiansen so rude? <shimpei+this+address+is+NOT+munged+.mil+.gov@socrates.caltech.edu>
    Re: Win32::EventLog (Martien Verbruggen)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sun, 15 Feb 1998 16:23:37 -0800
From: Chris Schoenfeld <chris@ixlabs.com>
To: chris@ixlabs.com
Subject: Re: Passing values into a subroutine from an array...
Message-Id: <34E78709.342F569C@ixlabs.com>

Oops - the name of the subroutine should be changed to printargs, of
course!

Sorry,
Chris

Chris Schoenfeld wrote:
> 
> You do not need to predeclare your arguments (but you can).
> 
> All arguments passed to the sub are in the magic array @_, which is the
> default LIST argument to the shift() operator, which returns @_[0] and
> removes it from the array, shifting remaining elements left.
> 
> printargs('one',2);
> 
> sub result{
>         # @_ contains 'one',2
> 
>         my $arg1=shift; # @_ now contains 2
>         my $arg2=shift; # @_ is now empty
> 
>         print "my arguments were $arg1 and $arg2\n";
> }
> 
> You can. of course, simply reference the @_ elements directly if you
> want as well, i.e. @_[1]...
> 
> Premgith Vidyanandan wrote:
> >
> > I call this subroutine in the following manner,
> >   @val[0] = &result(@array[0]);
> >
> > sub result{
> >   $value = grep "who" @array[$i];
> >   return $value;
> >  }
> > This does not work because $i is not defined. if I assingn a value of $i
> > with 0 then it works but it does not work when I call the same function
> > and change the value of $i.
> >
> > The question I have is how can I pass the values from the call to the
> > subroutine for different values of the array, for instance how can I call
> > the same subroutine with @array[1];@array[2] .... and so on and make it
> > return different values.
> > . Is there a better way to do this....
> >  In c you can just declare the arguments in the beginning and then just
> > pass the values in to the function, I need the equivalent of the same
> > process in perl...
> >
> > Thanks...
> >
> > Premgith Vidyanandan
> > Tel -: Res (517) 333-4201
> >        Off (517) 355-4500 ext(193)
> > E-mail - vidyanan@pilot.msu.edu
> 
> --
> ---
> Chris Schoenfeld
> IX Development Laboratories
> Santa Rosa, California

-- 
---
Chris Schoenfeld
IX Development Laboratories
Santa Rosa, California


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

Date: 15 Feb 1998 23:45:32 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Passing values into a subroutine from an array...
Message-Id: <6c7ums$npv$10@client2.news.psi.net>

Chris Schoenfeld (chris@ixlabs.com) wrote on 1629 September 1993 in
<URL: news:34E76FAE.785D14C2@ixlabs.com>:
++ 
++ You can. of course, simply reference the @_ elements directly if you
++ want as well, i.e. @_[1]...

I think you want $_[1] there.


Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


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

Date: Sun, 15 Feb 1998 21:41:49 GMT
From: vanselow@hotmail.com (Vanselow)
Subject: perl connect to postgresql or mysql
Message-Id: <34e75f9a.5247096@news.s-direktnet.de>

Hi

I would like to programm a perlscript (sql),
which use the database postgresql or mysql .
Is there a perl-script-example on the net,
so that I can see, how it works.
I would learn it best in that way.
I use Linux on which postgresql already is installed.

Thank you in advance.
bye
m. vanselow


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

Date: Mon, 16 Feb 1998 22:01:49 -0000
From: "Tony Kenny" <tony@furness.co.uk>
Subject: Perl training in the UK
Message-Id: <6cadg5$c1e$1@svr-c-01.core.theplanet.net>

We are looking into conducting Perl training in the UK, with a top UK based
computer training agency or with an instructor from Stonhenge
Consulting, oregon http://www.perltraining.com

We have not found any other places in the UK fro training.

If anyone would be interest in such training please contact me at
anthonykenny@hotmail.com or tony@furness.co.uk so I can get a ballpark
figure on how many people to expect to be interested.


Tony Kenny
Furness Internet Limited
+44 (0)1229 588588





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

Date: Sun, 15 Feb 1998 19:19:31 -0500
From: Craig Busko <crb@netunlimited.net>
Subject: Perl-to-"C" converter?
Message-Id: <34E78613.E79D4D2F@netunlimited.net>

Hi,

Anyone know if a perl-to-"c" coneverter exists?  If so, where I can get
one?
I have searched the web and didn't find one.  Help is appreciated!

Regards,
Craig   (C programmer learning perl :)



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

Date: 16 Feb 1998 01:31:23 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl-to-"C" converter?
Message-Id: <6c84tb$s9e$1@comdyn.comdyn.com.au>

In article <34E78613.E79D4D2F@netunlimited.net>,
	Craig Busko <crb@netunlimited.net> writes:
> Anyone know if a perl-to-"c" coneverter exists?  If so, where I can get
> one?

perldoc perlfaq3
/How can I compile my Perl program into byte code or C?

> I have searched the web and didn't find one.  Help is appreciated!

You should start with the faq :) It's more efficient. Then search
clpm (on dejanews or so), visit www.perl.com, and when all that
fails, search the web.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | You can't have everything, where would
Commercial Dynamics Pty. Ltd.       | you put it?
NSW, Australia                      | 


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

Date: Mon, 16 Feb 1998 18:08:40 -0500
From: Ignacio Bustamante <iggiebee@rhpworld.org>
Subject: Re: PGP - Perl puzzle
Message-Id: <6cah7l$8l3@bgtnsc03.worldnet.att.net>

Salve,

First, given my barbaric omission, thanks for the suggestions, and for
not flaming me badly as it would be usual on a purists newsgroup such as
this one.

However, I have used all the methods, you explained to no avail, since
there are no errors produced.

It's just that the generated encrypted file comes out empty. I usually
can hack my way around a script, and after some tweaking, solve almost
any given problem, but I am totally at loss with this one.

I suspect that PGP for some reason is treating the text file to be
encrypted as binary when executed from within a perl script, but have
not been able to verify this either.

Regards, and again repeating my pleas for help.

Ignacio

Salve J Nilsen wrote:
> 
> And then, Ignacio suddenly uttered...
> > Hi,
> 
> # Deletia grande
> 
> > Any help, ideas?
> 
> 1. #!/somewhere/bin/perl -w  ... to catch those silly mistakes
> 2. use strict;
> 3. use diagnostics;  ... if you need more feedback.
> 4. open(FOO,"|bar baz) || die 'could not open: '.$!;  ... Always!
> 
> HTH,
> 
> Salve Nilsen
> 
> --
> Argh, no .sig!


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

Date: Sun, 15 Feb 1998 14:19:32 -0800
From: "Aaron Harsh" <ajh@rtk.com>
Subject: Re: Printing $query->param in a here-doc?
Message-Id: <6c7pjg$sbm$1@brokaw.wa.com>

Mark666769 wrote in message
<19980213223500.RAA05828@ladder02.news.aol.com>...
>Hi,
>
>Is it possible to print the results of a CGI.pm
>function call in a here-doc, as follows:
>
>use CGI;
>$query = new CGI;
>print <<ZZZ;
>help me $query->param("WHO") please
>ZZZ

Try this:

  print <<ZZZ;
  help me @{[$query->param('WHO')]} please
  ZZZ

You can find an explanation of why this works if you look for the word
'interpolate' in the perlref podpage (of all places).


Aaron Harsh
ajh@rtk.com




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

Date: 16 Feb 1998 04:25:56 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Regex & locales.
Message-Id: <6c8f4k$rvh$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Eli the Bearded 
<*@qz.to>],
who wrote in article <qz$9802152244@qz.little-neck.ny.us>:
> Abigail <abigail@fnx.com> wrote:
> > In a regex, how does one match an uppercase letter in the current locale?
> 
> As far as I know, one doesn't. \w and \W are the only locale-sensitive
> bits of regular expressions as of 5.004

Nope.  There is much more.  But the generic message is correct.  And
(?{}) is so primitive yet that it will not help either :-(.

>, and both of those are case
> insensitive. You can make the complicated effort of grep()ing the \w
> characters out of the set of all characters, removing the numbers and
> _, then removing the duplicates after uc()ing the whole thing, finally
> put that in a variable and use it in a character class, but that is a
> lot of work.

One may be interested that
    /[[:upper:]]/
will give a message like
    /[[:upper:]]/: POSIX classes not implemented yet at ...
starting from 5.004_59 or somesuch ;-).

Ilya


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

Date: 15 Feb 1998 21:08:42 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: regexp: /^[800|888]/ vs. /^8[0{2}|8{2}]/
Message-Id: <6c7lgq$8q2$3@marina.cinenet.net>

Francois Trousset (trs@eerie.fr) wrote:
: 	I think the good solution is /^800|888/

Watch that alternation grouping!  Your regex above means "800 at the 
beginning of the string, or 888 *anywhere* in the string.  Personally, 
I'd use /^8([08])\1/ just for job security. :)  More seriously, a good 
combination of clarity and correctness could be achieved by any of

  /^800|^888/
  /^(800|888)/
  /^8(00|88)/

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Mon, 16 Feb 1998 14:33:41 +0100
From: PTBS <ptbs@mail.dma.be>
Subject: Remove files in a PERL sript
Message-Id: <34E84034.5FB9F2F0@mail.dma.be>

I've made a script that generates little files.  After a while I copy
the contents of these little files in a large file.  Then I want to
remove the files from my /temp directory.  But how can I do that?  I'm
running the script on a UNIX server.
I think I have to use the rm command, but how do I use it in Perl?

Wouter Van Beneden



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

Date: 16 Feb 1998 22:28:47 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Replace in HTML files
Message-Id: <6caeiv$4g2$5@comdyn.comdyn.com.au>

In article <34e91603.261457425@news.solomon.com.sg>,
	oleg@solomon.com.sg (Oleg Melnikov) writes:

> 1. I have a site with ~1000 HTML files with toolbars at top/bottom
> Now I need to remove this toolbars from all files. Tolbar is a table.
> So what I have to do is to remove table description from HTML file
> i.e. open file and copy from this file to output file until

Run over all the directories and all the files (You could use
File::Find for that) Open each file, and parse the HTML (you could use
HTML::Parser for that). Write out the corrected document.

> 2. I need to insert Javascript in each file (replacement):

This would fall in the last step, mentioned above.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Inside every anarchy lurks an old boy
Commercial Dynamics Pty. Ltd.       | network - Mitchell Kapor
NSW, Australia                      | 


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

Date: 16 Feb 1998 23:28:55 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Replace in HTML files
Message-Id: <6cai3n$5sl$3@marina.cinenet.net>

Martien Verbruggen (mgjv@comdyn.com.au) wrote:
: In article <34e91603.261457425@news.solomon.com.sg>,
: 	oleg@solomon.com.sg (Oleg Melnikov) writes:
: 
: > 1. I have a site with ~1000 HTML files with toolbars at top/bottom
: > Now I need to remove this toolbars from all files. Tolbar is a table.
: > So what I have to do is to remove table description from HTML file
: > i.e. open file and copy from this file to output file until
: 
: Run over all the directories and all the files (You could use
: File::Find for that) Open each file, and parse the HTML (you could use
: HTML::Parser for that). Write out the corrected document.

And, to save yourself the hassle of doing this next time the toolbar 
or other boilerplate needs to change, consider using an HTML preprocessor 
(or writing one of your own) to expand markers like [[toolbar]] (or 
whatever) in your 'source' pages into whatever HTML is appropriate.  
Then, when you want to change common stuff across all 1000 pages, you 
just change the marker -> HTML mapping and 'recompile' the pages.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Mon, 16 Feb 1998 02:35:09 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: RFC about "Matt's Script Archive"
Message-Id: <34E7EC31.C07D180B@coos.dartmouth.edu>

Mark Kramer wrote:
> 
> Admit it; if it was someone besides Tom who was complaining that a free
> piece of software wasn't written the way he liked code to be written,
> would you you be supporting him or telling him to write his own if he
> didn't like the free stuff?

If I give you a free bucket of sh*t, it's still a bucket of sh*t.

;-)

Chipmunk


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

Date: Sun, 15 Feb 1998 18:56:21 GMT
From: FHeasley@chemistry.com (Frank)
Subject: Re: RFC about "Matt's Script Archive"
Message-Id: <34e73862.9800178@news.halcyon.com>

On Sun, 15 Feb 1998 15:24:10 GMT, bart.mediamind@tornado.be (Bart
Lateur) wrote:

>Eli the Bearded <*@qz.to> wrote:
>
>>Hell I've complained about free perl code that was written terribly,
>>and my typical solution has been to patch or rewrite it and release
>>my version.
>
>Yes! That's the spirit! 
>
>Isn't it just a bit remarkable that many Perl guru's on this newgroup
>just complain about the state of Matt's scripts, and nobody volunteers
>to make a better version?
>
>BTW. I will not easily volunteer to donate MY Perl code to the world. I
>won't risk it. I wouldn't want to be in Matt's shoes.
>
Which neatly sums up the problem.

>From the earliest days, there is a pervasive philosophy that
everything on the net should be "FREE".

According to this philosophy, all of the guys who are really good at
perl should live in monasteries and donate their time to writing good
code and correcting bad code from other people, while perl continues
to be the main programming language that drives commerce on the world
wide web.

Get real, guys.

Nobody can live on air, and I'm sensing that a number of folks on this
ng are getting frustrated at handing out freebies for other people to
use commercially.

Why should the perl wizards here pass out free programs while everyone
else is making money on them?  Why shouldn't people who understand the
pitfalls complain about the bad code that's being passed around?

My only "complaint" is actually a suggestion:  the guys who know how
to do it right should make it very clear that they are offering to do
it in return for fair compensation.

Frank



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

Date: 15 Feb 1998 23:36:08 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: RFC about "Matt's Script Archive"
Message-Id: <6c7u58$6a@fridge.shore.net>

Bart Lateur (bart.mediamind@tornado.be) wrote:

: I didn't actually mean you, Tom. In fact, I would by far prefer it (for
: example; I won't force you) if you would write some more articles in the
: "far more than you ever wanted to know" series. That might have been the

So who did you mean, then?  There are many computer professionals in
this group who don't have time to do things gratis, particularly
things that will require a lot of time.  I'd be happy to rewrite
Matt's scripts ... when I have time to do so.  :-)

--
Nathan V. Patwardhan
please don't send spam to president@whitehouse.gov


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

Date: 16 Feb 1998 03:24:34 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: RFC about "Matt's Script Archive"
Message-Id: <6c8bhi$dpi@fridge.shore.net>

Leslie Mikesell (les@MCS.COM) wrote:

: There appear to be a lot of people with time to post critical comments
: but if anyone bothered to include useful content I must have missed
: it.  What bad things will happen to someone with FormMail.pl running
: on their site?

There are a number of things that I'll detail shortly, but the things
to watch out for (with Matt's scripts and others) include:
1) Ill-advised use of (shell) commands that would result in bad things
like someone grabbing a hold of your password file (on Unix).
2) Scripts are very Perl4-esque.
3) Scripts needlessly reinvent the wheel.  There's a certain example
related to searching files where Matt completely reinvents (and to a
certain extent butchers) File::Find.  I don't know if he's changed
this, but it was this way the last time I looked at the code.
4) Scripts don't tend to check input very well (reference: Randal,
HTML tags and Barney gif).
5) Scripts use SSIs (server-side includes) for no particularly good
reason.  There's no reason (or at least none that I can think of at
the moment) why these should be used in CGI programming since you can
generate everything dynamically.
6) He doesn't seem to like CPAN; i.e. - he doesn't seem to use any
modules like CGI.pm, and employs a certain degree of brute force to
get the job done.
7) Last time I checked, he wasn't using flock() in any of the apps
that allowed the world to write files.

More later.

--
Nathan V. Patwardhan



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

Date: 15 Feb 1998 19:31:23 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: RFC about "Matt's Script Archive"
Message-Id: <8cn2fs2sck.fsf@gadget.cscaper.com>

>>>>> "Bart" == Bart Lateur <bart.mediamind@tornado.be> writes:

Bart> But I have noticed quite a few slamming posts about Matt's
Bart> scripts in this newsgroup in the last few weeks alone. Now if
Bart> only some of these people would actually (A) contact Matt about
Bart> it (I'm pretty convinced he doesn't read this newsgroup), and/or
Bart> (B) spend the time and energy into patching the code instead of
Bart> just writing nasty newsgroup articles about it, this would have
Bart> been fixed a long time ago.

Because, plain and simple, they aren't worth patching.

You don't patch a go-cart to make it a real car.  You start over.
Sure, you learn that a steering wheel linkage is good, but you don't
take the go-cart steering wheel linkage to put it into a car.

MSA programs are cute toys.  Not real code.  The people that confuse
them for real code get, uh, confused. :-)

I'm happy for Matt that he was able to put his hobby programs on the
net, and that people liked them.  But no serious web hacker should
*ever* just take them for a real production site!

Besides, most of them can be written in about 15 lines of code once
you permit Perl5 and LWP and CGI.pm.  There's just not a lot of meat
there.  Perl4 is dead.  And there are no plans to make Perl4 Y2K
compliant (be afraid, be very afraid).

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 197 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@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: Mon, 16 Feb 1998 02:47:16 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: Running Perl
Message-Id: <34e79aa4.524144494f47414741@radiogaga.harz.de>

Eric Umehara (momiji@slip.net) wrote:
: I can't figure out how to test my perl script. Can you help?

: I downloaded a perl interpeter PW32i315 and ran the uncopresser and then
: ran the batch file with no problems. I then wrote a small Hello World perl
: script saved it in the bin directory and even after I tried typing the name
: including the extension .pl it woudn't run. I used the dos PERL program in
: the C:\Perl\bin directory and copied the script it into that. It didn't
: work I then tried some BASIC commands such as run. How do I test my
: script??

As always with Perl, TMTOWTDI ("There's More Than One Way To Do It"):

- C:\> c:\perl\bin\perl.exe yourscript.pl

- C:\> perl yourscript.pl  (assuming you put c:\perl\bin into the PATH)

- C:\> yourscript.pl (assuming you put c:\perl\bin into the PATH and
                      .pl into the CMDPATH [or so - didn't try that yet...])

Anyway:

Please have a look at the Perl documentation, probably installed in
c:\perl\lib\pod or so. perl.pod is a good starting point. There you'll
find a reference to the perlrun POD ("Perl execution and options").

It would also be a good idea to buy a book. "Learning Perl" comes to mind.

cu,
  Martin
--
                          | Martin Vorlaender | VMS & WNT programmer
 Ceterum censeo           | work: mv@pdv-systeme.de
 Redmondem delendam esse. |       http://www.pdv-systeme.de/users/martinv/
                          | home: martin@radiogaga.harz.de


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

Date: 16 Feb 1998 22:39:04 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Sending mail from perl (was Re: Newbie question)
Message-Id: <6caf68$4g2$8@comdyn.comdyn.com.au>

In article <6c9vpp$lho@mailgate.lexis-nexis.com>,
	jhunterj@lexis-nexis.com (Hunter Johnson) writes:

>> I need to know how to use perl to send email.  Can the perl script
>> do the emailing, or would it be easier to have perl invoke a UNIX
>> command or something?
> 
> The latter.

Wrong. The perl script can handle the mailing, and should handle it.
Minimise the number of system calls you make. 

>> I've got a UNIX script pinging about 20 computers in a network and
>> saving the results to a file.  I use a really short perl script to
>> sort through that file to find the nonresponsive computers.  This is
>> where I need help: I want the script to email my beeper the "no
>> answer from blah.blah.blah".  I've got everything set to work off a
>> cron job so it'll be running continuously throughout the day.
> 
> open (MAIL, "| mail mybeeper@mybeeperhost.com") or die "some message";

Yikes! Especially minimise the numbers of pipes you open.

See the perl FAQ, section 9, 'How do I send/read mail?'

perldoc perlfaq9

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Advertising:  The science of arresting
Commercial Dynamics Pty. Ltd.       | the human intelligence long enough to
NSW, Australia                      | get money from it.


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

Date: 16 Feb 1998 15:24:48 GMT
From: gabor@vmunix.com (Gabor)
Subject: signals in Perl, should I use C instead?
Message-Id: <slrn6egme5.57m.gabor@vnode.vmunix.com>

Hi,

I have a question related to the recent discussion of signals in Perl.

I have to write a server that will be a gateway to a database.
Clients will connect and make requests for information.  The requests
will not be actual SQL statments.  That is so the client cannot go and
alter the database.  Now the server would fork off a new child for
every connection and insure that no more than 50 connections are
active at any time.  Connections time out after 5 minutes of
inactivity.
Here is the problem.  I need to maintain a hash of logins and pids so
that no client can login twice, and that when the child exits, the
client can login again.  This means that when I reap the children I
need to remove the logins from the login hash.  There are actually two
hashes, one indexed by pid and the other by login.

$SIG{CHLD} = sub {
    my $pid = wait;
    delete $logins{$pids{$pid}};
    delete $pids{$pid};
};

Will I get a core dump because of malloc, or whatever while in the
signal handler?  If there is any chance of that then I need to rethink
this, and write it in C, which I don't want to do.

gabor.
--
    Your csh still thinks true is false.  Write to your vendor today
    and tell them that next year Configure ought to "rm /bin/csh"
    unless they fix their blasted shell. :-)
        -- Larry Wall in Configure from the perl distribution


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

Date: Mon, 16 Feb 1998 22:25:23 GMT
From: "Devin P. Anderson" <dev@sgi.net>
Subject: sockets to webservers
Message-Id: <34E8BDCB.1C36@sgi.net>

What socket options should one use to connect to a webserver? I've done
socket programming before, but when I try to read from the socket to
this webserver, it just hangs. Heres the code.

socket(SOCK,PF_INET,SOCK_STREAM,$proto);
connect(SOCK,$paddr);

And I know that the paddr is fine. I'm stumped!

later-
 
---                                                                 				
Devin P. Anderson 	
Webmaster, Systems Administrator
Stargate Industries, Inc.
http://www.sgi.net/
Phone: 412.930.STAR (7827) ext. 241
F a x: 412.930.7110

"I want an internet. Can I have one of these?"
        Spice Girl MEL B. (Scary Spice) pointing to a computer 
        during an AOL press conference

-----PGP PUBLIC KEY AVAILABLE-----


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

Date: Sun, 15 Feb 1998 21:59:08 GMT
From: steveh@cent.com (steve)
Subject: Re: Sorting some text in Perl
Message-Id: <34f56513.20867475@news.cent.com>


@NEW = sort {$b <=> $a} @TEXT;







On Mon, 09 Feb 1998 18:57:31 +0100, Johan Larsson <jola@acc.umu.se>
wrote:

>Hi All,
>
>
>How can I sort a @text list in Perl containing strings like "9801"
>"9802" etc? (dates - oh yes!)
>
>
>Regards,
>Johan Larsson
>jola@acc.umu.se <--- Please carbon copy!
>



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

Date: 15 Feb 1998 23:30:58 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Sorting some text in Perl
Message-Id: <6c7tri$ob4$2@marina.cinenet.net>

steve (steveh@cent.com) wrote:
: On Mon, 09 Feb 1998 18:57:31 +0100, Johan Larsson <jola@acc.umu.se>
: wrote:
: >How can I sort a @text list in Perl containing strings like "9801"
: >"9802" etc? (dates - oh yes!)
: 
: @NEW = sort {$b <=> $a} @TEXT;

Actually, for YYMM dates like this, lexical sorting (the sort default) 
works equally well...

  @sorted_dates = sort @text;

 ...or equally poorly, as I noted in my previous Y2K-warning post on this 
thread.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Sun, 15 Feb 1998 17:19:56 -0500
From: Larry D'Anna <ldanna@hotmail.com>
To: "Tony K. Olsen" <tkolsen@btinternet.com>
Subject: Re: Sorting Strings With Delimited Characters - Advice Sought
Message-Id: <34E76A0C.1CC0FBD0@hotmail.com>

[copy cc'd to Tony K. Olsen]

Tony K. Olsen wrote:
> 
> Hi Everyone,
> 
>         After having tried numerous things like cmp and <=> etc. I am
> looking for a little advice on a sort problem I am having with a
> delimited text file using two colons (::).
> 
>         Running perl, version 5.003_07 on Windows 98
> 
> Text file begins:
> 
> 1::1997::
> 23::1998::
> 2::1998::
> 14::1998::
> 2::1997::
> 3::1998::
> 
>         When I sort the file with the code below I get:
> 
> 14::1998::
> 1::1997::
> 23::1998::
> 2::1997::
> 2::1998::
> 3::1998::
> 
>         I understand why it is doing what it is doing (14 is < 1:) but not
> quite sure the best method for implementing without a lot of coding.
> 
>         What I want is:
> 
> 1::1997::
> 2::1997::
> 2::1998::
> 3::1998::
> 14::1998::
> 23::1998::
> 

#/perl/bin/perl -w

sub LexicalCmp {
  my (@a) = split /::/, $a;
  my (@b) = split /::/, $b;
  my ($ca, $cb);
  while (1) {
    if (!@a && !@b) 
      { return 0; }
    else {
      if (!@a)
	{ return -1; }
      if (!@b)
	{ return 1; }
    }
    ($ca, $cb) = ((shift @a), (shift @b));
    if ($ca <=> $cb) 
      { return $ca <=> $cb; }
  }
}

print sort LexicalCmp <>;

Hope this helps

---------------------------------------
|Democracy is the worst system of government. --
|Except for all the others
|               -Winston Churchill
---------------------------------------------------
Larry D'Anna                   "eschew obfuscation"


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

Date: Sun, 15 Feb 1998 22:28:56 +0100
From: Peter Edlund <peter.edlund@capgemini.se>
Subject: Re: Sorting Strings With Delimited Characters - Advice Sought
Message-Id: <34E75E18.A449AFB6@capgemini.se>

Tony K. Olsen wrote:
>         What I want is:
> 
> 1::1997::
> 2::1997::
> 2::1998::
> 3::1998::
> 14::1998::
> 23::1998::

Well there could be two different things you want here:

first thing, if you just want it sorted with the number without the
colons:

@unsorted = ('1::1997::',2::1997'... etc );
@sorted = sort { (($_ = $a)=~s/://g) <=> (($_ = $b)=~s/://g) }
@unsorted;

this will just sort on the input numerically with the colons stripped.

But, since it's years (I suppose) you might want it 'doubly' sorted,
that is sorted first on year and then on the number to the left you
could do something like this:

@unsorted = ('1::1997::',2::1997'... etc );
@sorted = sort sort_some_foos @unsorted;

sub sort_some_foos {
  ($c,$d) = split (/::/, $a);
  ($e,$f) = split (/::/, $b);
  ($d . $c) <=> ($f . $e);
}

This will swap places of them numbers so you'll sort on '19971',199813'
etc.

hope this helps
//peter.

-- 
---------------------------------
Peter Edlund
UNIX developement consultant
Cap Gemini Sweden
peter.edlund@capgemini.se


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

Date: 15 Feb 1998 20:35:29 -0800
From: Russ Allbery <rra@stanford.edu>
To: michael@datahost.com
Subject: Re: System function to variable
Message-Id: <m3d8gokvzi.fsf@windlord.Stanford.EDU>

[ Posted and mailed. ]

Michael Stearns <michael@datahost.com> writes:

> I am trying to get the current date and stick it in a variable.

use POSIX qw(strftime);
$date = strftime ('%A %B %e, %Y', localtime time);

Don't fork off a date command unless you have to.  (Besides, if you're
running under SunOS, it doesn't have the %Y escape.  Neither do some older
versions of GNU utilities, IIRC.)

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Mon, 16 Feb 1998 03:18:39 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: Testing integer
Message-Id: <34E81254.9E6A33FA@5sigma.com>

Oops.  I guess I didn't read his question too carefully.  Probably
he would like:

  print "integer" if $a =~ /^\d+$/;

or something to that effect.  There is the slightly more elaborate
technique of (barring typos):

  print "integer" if ($a & ~$a) eq '0' and $a == int $a;

This distinguishes between $a = "123" and $a = 123, which may or may
not be what he wants.  ("Not" is my guess.)

	-joseph

Craig Berry wrote:
> 
> Joseph N. Hall (joseph@5sigma.com) wrote:
> : int($a) == $a, perhaps
> 
> Tests true for $a = 'I am not an integer.'

-- 
Joseph N. Hall, prop., 5 Sigma Productions       mailto:joseph@5sigma.com
Author, Effective Perl Programming . . . . . http://www.effectiveperl.com
Perl Training  . . . . . . . . . . . . . . .  http://www.perltraining.com


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

Date: 16 Feb 1998 21:38:39 GMT
From: spidaman@well.com (Ian Kallen)
Subject: Re: The 'study' function
Message-Id: <6cabkv$s15$1@was.hooked.net>


Ugh! No takers?  Somebody must have something that is demonstrative of
study being useful!  Find this person, release the hounds! :)
-Ian

Ian Kallen (spidaman@well.com) wrote:
: Any code examples of using 'study' to accelerate  pattern matches would be 
: appreciated!  

--
--
Ian Kallen <spidaman@well.com>
"Like so many Americans, she was trying to construct a life that made
sense from things she found in gift shops."
                -- Kurt Vonnegut, Jr.


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

Date: 15 Feb 1998 20:29:18 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: The Young Man and the Beach
Message-Id: <m3g1lkkw9s.fsf@windlord.Stanford.EDU>

John Bollenbacher <jhb@cts.com> writes:

> I think that long-time participants in internet and computing in general
> forget how daunting it can all be to the neophyte.  Try to cast your
> mind back to your first exposure to this all.  Try imagining yourself as
> a university (or high school?) freshman who has just heard of the
> incredible information to be found in newsgroups.  Without any other
> assistance, you discovered how to get your browser to show you the
> contents of comp.lang.perl.misc and you have never seen the letters FAQ
> before.

I posted a horribly miswrapped message the first time I posted, three days
after I started posting.  I immediately realized my mistake, lurked a
while longer, and started posting comments about things I thought I knew a
little bit about.  I listened to other people.  I tried not to make the
same mistake twice.  When I saw my first FAQ, I read the entire thing all
the way through, and then I knew what the letters stood for.

A month later, I was astonished to find people complimeneting me on how
fast I learned.  I didn't, and still don't, think that I learned
particularly fast.  I just demonstrated some basic respect of other
people's places, listened to people who knew more than I do, and tried to
act in a manner that made other people want to listen to what I said.

Basic politeness is not difficult.  It simply requires desire and some
time invested into learning the community.

Of course, Usenet wasn't nearly as widespread when I started, and I didn't
post until I was a junior in college.  Perhaps that made a difference.
But it doesn't have to.  There are several posters to a newsgroup I
moderate who are 14-16 years old, and while they make some dumb mistakes
from time to time, they've proven more than capable of handling the
responsibility of posting to a world-wide network.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 16 Feb 1998 23:13:29 GMT
From: bem@news.cmc.net (brian moore)
Subject: Re: The Young Man and the Beach
Message-Id: <6cah6p$poa$1@news.cmc.net>

In article <34E8478E.E80EB738@ti.com>,
	Graham Barr <gbarr@ti.com> writes:
> I can assure you that there are *very* few people in this group
> who would agree that Tom's purpose of reading this group is for
> anything other than to help.

I'll disagree and even be so presumptuous as to attempt to read Tom's
motives.

I don't think he posts because he wants to help: he posts because he
thinks Perl is the coolest thing since slice(@bread) and wants others
to enjoy it as much as he does.

To do that, yes, he will help people.  He will show them fun tricks with
perl; he will post Perl problems for people to ponder; he will dictate
diatribes about the Y2K hoax; he will denounce the Demon Program Launcher
for what it is (you can't really enjoy Perl as much on a non-Unix platform:
there are too many Unixisms that fit too well with Perl that you lose
on a Windows platform).

His primary motivation is to share the really-cool-toy that perl is
with everyone else, though.  Helping is just a part of what he does.

(See his glossary posted here the other day about toys....)



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

Date: Mon, 16 Feb 1998 10:10:18 -0500
From: jdf@pobox.com (Jonathan Feinberg)
Subject: Re: what is exaclty the "_" Variable ?!?!
Message-Id: <MPG.f5220e46920cdf99896de@news.concentric.net>

  [courtesy cc of this posting sent to cited author via email]

vlierd@uni-oldenburg.de said...
: I did not find in Larry Wall's "Programming Perl" - book
:   (O'Reilly , second edition , September 1996) a precise
:  definition of this (at least for me ..) strange Variable "_" .

Did you read the detailed discussion of that variable (also known as $ARG) on 
page 131?

:  It seems to me , extracting form his examples , that every
:  operator which produces a value in the "LIST"-context automatically
:  does "$_ = <the list of the items the operator returns>" .

No, a scalar variable cannot contain a list value.

My heartfelt advice to you: put down the Camel book, and purchase the Llama 
book, "Learning Perl," by Randal Schwartz.  This will gently give you the 
foundation you need to make sense of the Camel.

:  much riddles --  maybe I am too  stupid for "PERL" (and maybe not).

That's for nobody but you to decide.

-- 
#!/usr/bin/perl -w -- Just another Perl hacker,
 (open 0),$_=<0>,s,^.*-+ ,,,,chop;for(split?/*?){($$_++or$y=$_,y,
 y \,y,<STDIN>,,eval"sub $_ {print '$y'}"),y,0 \,},>STDOUT},,&$_}
# Jonathan Feinberg    jdf@pobox.com    Sunny Brooklyn, NY


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

Date: 15 Feb 1998 23:22:38 GMT
From: Shimpei Yamashita <shimpei+this+address+is+NOT+munged+.mil+.gov@socrates.caltech.edu>
Subject: Re: Why is Tom Christiansen so rude?
Message-Id: <6c7tbu$rng@gap.cco.caltech.edu>

Rich Grise  <lovegod@earthling.net> writes:
>Jonathan Stowe wrote:
>> In article <6bv95t$ira$1@csnews.cs.colorado.edu>, tchrist@mox.perl.com
>> says...
>> >For this, Ken invented grep.
>> This probably is not why Bill G. "invented" the happless find though ;-{
>I've heard, "There are two notable things that have come from Berkely in
>this century. LSD and Unix. We do not believe this to be a coincidence."

Almost.
s/Berkely/Berkeley/
s/Unix/BSD/

-- 
Shimpei Yamashita               <http://www.patnet.caltech.edu/%7Eshimpei/>
The address I have listed in the headers is a working address. It just
looks like it's an invalid address in order to fool spammers collecting
addresses from newsgroups.


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

Date: 16 Feb 1998 22:05:12 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Win32::EventLog
Message-Id: <6cad6o$4g2$3@comdyn.comdyn.com.au>

In article <34e84424.19106403@news.uni-augsburg.de>,
	eichner@gmx.de (eichner) writes:

> The package I want to use: Win32::EventLog.
> 
> The aim is to read the eventLog entries.

Well. That module seems a logical choice then.

[snip]

> Whats the correct call of Win32::ReadEventLog.
> A small example would be very helpfull.

Have you tried the documentation of the module? Any well written perl
module should come with documentation in pod format. After
installation of the module, the documentation should be available with
perldoc:

perldoc Win32::EventLog
perldoc perl
perldoc perldoc
perldoc -f open
perldoc perlfaq

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | I'm just very selective about what I
Commercial Dynamics Pty. Ltd.       | accept as reality - Calvin
NSW, Australia                      | 


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

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 1911
**************************************

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