[6476] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 102 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 12 12:27:17 1997

Date: Wed, 12 Mar 97 09:01:32 -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           Wed, 12 Mar 1997     Volume: 8 Number: 102

Today's topics:
     Re: Problem with grep function <tchrist@mox.perl.com>
     Re: RFC821Header Decoder <eryq@enteract.com>
     Re: Scripts to parse common server logs <tchrist@mox.perl.com>
     Re: Signal catching with alarm <tchrist@mox.perl.com>
     Re: system() question (a hand full of hair) (Matt Wartell)
     Re: Telnet scripting with perl (Paco Hope)
     We have taken the Hassles out of the net goextreme@hotmail.com
     Re: We have taken the Hassles out of the net (Nathan V. Patwardhan)
     Re: what's the advantage of a shared libperl.so?? <tchrist@mox.perl.com>
     Re: WWW, and grabbing input from a command <tchrist@mox.perl.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 12 Mar 1997 14:39:57 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Problem with grep function
Message-Id: <5g6f7t$1ro$2@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    Triantafyllos Marakis <ceetm@cee.hw.ac.uk> writes:
:I am trying to construct a function that will count the
:number of occurances of a string to a file.

    s/occurances/occurrences/

>From section 4 of the (new) FAQ:

=head2 How can I count the number of occurrences of a substring within a string?

There are a number of ways, with varying efficiency: If you want a
count of a certain single character (X) within a string, you can use the
C<tr///> function like so:

    $string = "ThisXlineXhasXsomeXx'sXinXit":
    $count = ($string =~ tr/X//);
    print "There are $count X charcters in the string";

This is fine if you are just looking for a single character.  However,
if you are trying to count multiple character substrings within a
larger string, C<tr///> won't work.  What you can do is wrap a while()
loop around a global pattern match.  For example, let's count negative
integers:

    $string = "-9 55 48 -2 23 -76 4 14 -44";
    while ($string =~ /-\d+/g) { $count++ }
    print "There are $count negative numbers in the string";

-- 
	Tom Christiansen	tchrist@jhereg.perl.com
When I was a boy I was told that anybody could become President.  Now
I'm beginning to believe it.
                --Clarence Darrow


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

Date: Wed, 12 Mar 1997 09:56:41 -0600
From: Eryq <eryq@enteract.com>
Subject: Re: RFC821Header Decoder
Message-Id: <3326D239.458B99ED@enteract.com>

Kevin Johnson wrote:
> 

> You are in luck.  One has already been written.
> (assuming you consider yourself lucky for not having to reinvent the wheel :-)
> 
> Check out the MailTools module in CPAN at:
>         http://www.perl.com/CPAN/modules/by-module/Mail/

Don't forget MIME-tools (subclasses of the MailTools classes): MIME::Head can decode 
RFC-1522-encoded mail headers.

         http://www.perl.com/CPAN/modules/by-module/MIME/

(Was that a shameless plug?  I hope not...)  :-) 
-- 
  ___  _ _ _   _  ___ _   Eryq (eryq@enteract.com)
 / _ \| '_| | | |/ _ ' /  Hughes STX, NASA/Goddard Space Flight Cntr.
|  __/| | | |_| | |_| |   http://www.enteract.com/~eryq
 \___||_|  \__, |\__, |___/\  Visit STREETWISE, Chicago's newspaper by/
           |___/    |______/ of the homeless: http://www.streetwise.org


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

Date: 12 Mar 1997 15:19:23 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Scripts to parse common server logs
Message-Id: <5g6hhr$3ic$3@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, webmaster@gmom.com writes:
:I also am looking for date conversion routines that might be able to
:take the dates from the common log format, and convert them into the
:integer format that is returned from time().

>From part 4 of the (new) FAQ:

    =head1 Data: Dates

    =head2 How can I compare two date strings?

    Use the Date::Manip or Date::DateCalc modules from CPAN.

    =head2 How can I take a string and turn it into epoch seconds?

    If it's a regular enough string that it always has the same format,
    you can split it up and pass the parts to timelocal in the standard
    Time::Local module.  Otherwise, you should look into one of the Date
    modules from CPAN.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com


    "One planet is all you get."


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

Date: 12 Mar 1997 15:38:12 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Signal catching with alarm
Message-Id: <5g6il4$3ic$5@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    "Rich Schramm" <schramm@one.net> writes:
:Enter the alarm function. I am running alarm (twice actually to print the
:return code to verify that the alarm is actually being set), but after the
:given period of time, nothing happens.  It appears that my signal catching
:code is not functioning.  I have used signal catching before with the CHLD
:sig, during fork operations with expected results.  Similar code used for
:the ALRM sig seems to have no effect.

What version of Perl?  What operating system?  Prior to 5.003 there
were problems with alarm and signals, at least on some systems.  Or
maybe LWP does its own alarms; it's not good to mix several sleeps
and alarms.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

/* This is the one truly awful dwimmer necessary to conflate C and sed. */
    --Larry Wall, from toke.c in the v5.0 perl distribution


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

Date: 12 Mar 1997 10:04:07 -0500
From: msw@fore.com (Matt Wartell)
Subject: Re: system() question (a hand full of hair)
Message-Id: <5g6gl7$43s@cheers.fore.com>

Thanks for the detailed explanation, it is clear that you have thought
about this.  I suspect that your external program "program1" is not
getting the proper environment when it starts under perl, but is fine
under the shell.  My guess is that you have left some file handles open
in perl which could affect the file table available to program1.

Make sure that you have a close() for each open() in your script.
Check to make sure that you haven't closed or redirected STDIN, STDOUT
or STDERR.  Check for modifications of %ENV in the perl script that
might be affecting the operation of program1.  Even changes to
%SIG in your perl program could affect the operation of a sufficiently
perverse program1.

By the way, you had the proper system() syntax with:

  system("program1 args");

you need not have gone through all the contortions that you did, and
using syscall() was just plain wrong (but I understand that you were
grasping at straws).

Finally, if you are going to use system() instead of exec(), you
might as well check its return value.

Mike Bartolone <bartolonem@med.ge.com> wrote:
>I have a perl script that creates some support files for
>another program and then is supposed to run that other program. 
>The support files are being created perfectly..we tested them
>by having the perl script create them, and then running the
>other program manually. Next step, is a mundane system call like
>this:
>
>system("program1 args");
>
>Then the program exits (we expect it to exit here..its not dieing)
>program1 seems to execute, but the output file it produces is
>empty. I have tried the following:
[...]
>and tried syscall() in place of system() in each of the above
>examples. I even tried this:
>
>open(CMD_FILE,">program1.sh");
>print CMD_FILE "#! /bin/sh\n";
>print CMD_FILE "program1 args\n";
>close(CMD_FILE);
>chmod(0777,"program1.sh");
>
[...]
-- 
Matt Wartell, Fore Systems, Inc., 3500 Corporate Drive, Pittsburgh PA 15237
+1 412 635 3388 Fax: +1 412 635 3600                           msw@fore.com


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

Date: Wed, 12 Mar 1997 16:30:46 GMT
From: bah6f@cs.virginia.edu (Paco Hope)
To: "Joonas Kekoni" <jkekoni@cc.hut.fi>
Subject: Re: Telnet scripting with perl
Message-Id: <5g6lnm$1ab@jazz.cs.Virginia.EDU>


"Joonas Kekoni" <jkekoni@cc.hut.fi> writes:
> So i think using the telnet program is not an option. I am not familiar
> with tcpip-programming, so i thought it could be easier to find a ready
> "telnet script" and
> then change it to fit my purpose.

If you're on a unix box, then the command you are looking for
is "rsh"  It is a "remote shell" command.

You can do one of two things:
- copy the script to the new machine (machine1.foo.com) and then
  run 'rsh machine1.foo.com script' or something similar.

- Or, if it's a couple short commands you can put them on the
  command line like this:
  rsh machine1.foo.com 'a command; another command; anothercommand'

  Use semi-colons to separate commands.

This isn't a Perl question necessarily.  Perhaps you want to try
comp.unix.shells?

Paco
-- 
Paco Hope                                         Computer Systems Engineer
paco@cs.virginia.edu                         Department of Computer Science
http://www.cs.virginia.edu/~bah6f/                   University of Virginia


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

Date: 12 Mar 97 13:58:53 GMT
From: goextreme@hotmail.com
Subject: We have taken the Hassles out of the net
Message-Id: <3326b69d.0@news1.betacom.net>




                                      WELCOME And Go To
                                      www.GoExtreme.com



                 The Premiere Site on the Internet for EXTREME NET TOOLZ,
                Internet Relay Chat (IRC) help, and Newsgroup help without
                                       the clutter!


                                           
                    A large group of irc operators and newsgroup gurus
                     have tested and evaluated the best internet toolz
                           and HERE are their choices to become
                                   an EXTREME Net user!

                                           

                              All of this software is FREE!!
                            It is either shareware or freeware!
                                          Enjoy!

                                                       

                Best newsgroup reader: Free Agent!...Freeware!!!
                Best chat software: mIRC 4.72!...Shareware!!!
                Become your own FTP site! WAR-FTP 1.55 ....Freeware!!!!
                Fastest jpeg\gif viewer ACDSEE!...Shareware!!!
                Best E-Mail Program Eudora Lite 3.01!...Freeware!!!
                Winzip 6.2 takes the chore out of these zip
                files!...Shareware!!!
                CuteFTP 1.8 makes "browsing" FTP sites a
                snap!...Shareware!!!
                Fastest Web Browser Netscape 3.01!...Shareware!!!

                   (/`7.(/`7.!!!BOSnet: Voted The MOST EXTREME Internet
                                  Provider!!!.74/).74/)
                                           

                   Great Page for Extreme Net Toolz! All listed software
                                           here!
                               Get Extreme `Net Toolz here!

                                          
                 Great Help Page for IRC!!! Fserve, Flood Protection, New
                                       IRC Servers!
                                      IRC Help here!

                                           
                Great Help Page for News Groups! How To Do It! Big List of
                                      Public Servers!
                                   Newsgroup Help here!

                                           
                  This information provided so that we may all enjoy the
                           Internet, IRC, and Newsgroups better!

                                 !!!We receive no money!!!

                                        Members of
                                       [freespeech]
                                         Campaign

                                           and

                              [AOL SUX Get a REAL ISP Campaign]
                                           


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

Date: 12 Mar 1997 16:20:56 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: We have taken the Hassles out of the net
Message-Id: <5g6l58$n4e@fridge-nf0.shore.net>

goextreme@hotmail.com wrote:


:                  The Premiere Site on the Internet for EXTREME NET TOOLZ,

I don't know about everyone else, but I'm hesitant to use something
called "TOOLZ."  :-)

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: 12 Mar 1997 15:26:31 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: what's the advantage of a shared libperl.so??
Message-Id: <5g6hv7$3ic$4@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    Marc Langheinrich <marclang@saxifrage.cs.washington.edu> writes:
:I hoped for the latter one, but it seems it makes no difference
:whether I compile Perl w/ or w/o shared libperl.so -- either way, my
:script uses the same amount of memory while running. So why would I
:want to do this -- only to enjoy an 11k small binary?!

The difference is that all programs linked to the shared library
are smaller, using less disk space, and on some systems, perhaps
even less memory.  For example, 

    perl: /usr/bin/perl
    embedded applications: nvi, apache
    compiled programs: various CGI etc programs

Of course, if the only thing on your system is /usr/bin/perl, well
yes, there's no great savings.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
        echo "Hmmm...you don't have Berkeley networking in libc.a..."
        echo "but the Wollongong group seems to have hacked it in."
            --Larry Wall in Configure from the perl distribution


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

Date: 12 Mar 1997 14:35:25 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: WWW, and grabbing input from a command
Message-Id: <5g6evd$1ro$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    paulf@scs.leeds.ac.uk (Paul Forsyth) writes:
:This seems to work fine using the command line but if I call it using my
:form it fails to. 

This is the #1 one most asked question about Perl -- and it's
not even a Perl question!!  It's also the first in the FAQ 
section on Networking (part 9):

    =head2 My CGI script runs from the command line but not the browser.
	   Can you help me fix it?

    Sure, but you probably can't afford our contracting rates :-)

    Seriously, if you can demonstrate that you've read the following
    FAQs and that your problem isn't something simple that can be easily
    answered, you'll probably receive a courteous and useful reply to
    your question if you post it on comp.infosystems.www.authoring.cgi
    (if it's something to do with HTTP, HTML, or the CGI protocols).
    Questions that appear to be Perl questions but are really CGI ones
    that are posted to comp.lang.perl.misc may not be so well received.

    The useful FAQs are:

	http://www.perl.com/perl/faq/idiots-guide.html
	http://www3.pair.com/webthing/docs/cgi/faqs/cgifaq.shtml
	http://www.perl.com/perl/faq/perl-cgi-faq.html
	http://www-genome.wi.mit.edu/WWW/faqs/www-security-faq.html
	http://www.boutell.com/faq/

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
    "To claim any more than that is to invite a religious war, which I ain't.
    Go thou and don't likewise."
    	--Larry Wall


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

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

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