[8622] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2239 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 3 03:17:34 1998

Date: Fri, 3 Apr 98 00:00:54 -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           Fri, 3 Apr 1998     Volume: 8 Number: 2239

Today's topics:
    Re: "Unsupported function alarm function..."??? <grg@philol.msu.ru>
        ampersand in replacement (David Grove)
    Re: ampersand in replacement (Abigail)
    Re: eval with text files (Andre L.)
    Re: eval with text files (Craig Berry)
    Re: Fetching SSL pages <aas@sn.no>
    Re: How do I strip newlines from a var <rjk@coos.dartmouth.edu>
    Re: How to timeout TCP connect? (Andre L.)
    Re: Looking for ANY Suggestions on parsing this line!! (Craig Berry)
    Re: Looking for ANY Suggestions on parsing this line!! (Andre L.)
        memory usage of DBM vs hashes <otis@POPULUS.net>
    Re: memory usage of DBM vs hashes <andrew@erlenstar.demon.co.uk>
    Re: Multidimensional hashes <rjk@coos.dartmouth.edu>
    Re: Multidimensional hashes <rjk@coos.dartmouth.edu>
    Re: Munging addresses (was: Re: Perl Cgi Questions) (Peter Caffin)
    Re: Munging addresses (was: Re: Perl Cgi Questions) <rjk@coos.dartmouth.edu>
    Re: need help with regexp alternation problem <rjk@coos.dartmouth.edu>
    Re: perl Socket module (Peter Caffin)
    Re: PID numbers with forground and background nums not  <barmar@bbnplanet.com>
    Re: Ping <flaviovs@centroin.com.br-ZZZ->
    Re: processing big file (Jason Gloudon)
    Re: random picture for web page <Rosie@dozyrosy.demon.co.uk>
        Subscribing to a list without duplicates (remove)@dial.pipex.com (Rod Borland)
    Re: Sysadmin struggeling with PERL/Sed and etc... <roland@consol.de>
    Re: Trouble with shebang line ... (Marcus P Hertlein)
    Re: using &say("something"); <rjk@coos.dartmouth.edu>
    Re: using &say("something"); (Martien Verbruggen)
    Re: using &say("something"); (Craig Berry)
        Using Pack "Creatively" ivanovic@cs.monash.edu.au
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 03 Apr 1998 09:02:42 +0400
From: Grigoriy Strokin <grg@philol.msu.ru>
Subject: Re: "Unsupported function alarm function..."???
Message-Id: <35246D72.F5BBDA50@philol.msu.ru>

1) The best port (and the newest) of perl to DOS/Windows is one from
DJGPP.
2) In order to always have the LATEST perl version, get rid of Windows 
   and install UNIX.

Chris Brown wrote:
> 
> I am getting the following message when using the 'pingecho' command
> from the Net::Ping module:
> "The Unsupported function alarm function is unimplemented at
> C:\Perl\lib/Net/Ping.pm line 51, <CONFFILE> chunk 64."
> 
> I have tried Perl verision 5.004_02 and ActiveWare's port of Perl for
> Win32 Build 316.  Both versions produce the same error.
> 
> I'm just trying to determine if a machine is available from a perl
> script before processing is attempted on that machine.
> 
> Any ideas?
> 
> Chris Brown (cbrown@erols.com)


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

Date: Fri, 03 Apr 1998 04:41:43 GMT
From: pete@dave-world.net (David Grove)
Subject: ampersand in replacement
Message-Id: <352467eb.38585995@news.dave-world.net>

Which is correct?

s/</&lt;/g

or

s/</\&lt;/g

They both seem to work under Win32, but I don't know which is SUPPOSED
to work. Does the ampersand have to be escaped here?


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

Date: 3 Apr 1998 05:19:30 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: ampersand in replacement
Message-Id: <6g1rh2$3rf$1@client2.news.psi.net>

David Grove (pete@dave-world.net) wrote on MDCLXXVI September MCMXCIII in
<URL: news:352467eb.38585995@news.dave-world.net>:
++ 
++ They both seem to work under Win32, but I don't know which is SUPPOSED
++ to work. Does the ampersand have to be escaped here?


What does your manual say about it?



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'


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

Date: Thu, 02 Apr 1998 23:55:24 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: eval with text files
Message-Id: <alecler-0204982355240001@dialup-63.hip.cam.org>

In article <6g0s0l$cgn$1@marina.cinenet.net>, cberry@cinenet.net (Craig
Berry) wrote:

> Andre L. (alecler@cam.org) wrote:
> : In article <wb7opEAIZ8I1EwKx@iotp.demon.co.uk>, Soccerweb
> : <soccerweb@iotp.demon.co.uk> wrote:
> : 
> : > Hello, I'm writing a Perl CGI script that enables the webmaster to
> : > automatically send various e-mails for administration purposes. All the
> : > e-mail content are stored as text files, however the e-mail content
> : > states thing like "as researcher for $country" or "Hello $name,". I want
> : > to be able to convert the variables in the text file and then attach the
> : > headers etc. to the e-mail and post. But, I can't manage to change
> : > $country to Spain when $country eq "Spain". So the posted e-mail's still
> : > state "as researcher for $country", I've tried eval but it doesn't work,
> : > any suggestions?
> : 
> : Use these on the file's text:
> : 
> : s/\$country/$country/ge;
> : s/\$name/$name/ge;
> : 
> : Those will evaluate $country and $name to their current values.
> 
> No need for the e qualifier on those.

You're right. I humbly stand corrected. I have to study regexps more
before venturing into helping others. Sorry.

> As a generic version, you can do
> 
>   s/(\$[A-Za-z]\w*)/$1/gee;
> 
> to convert everything that looks like a scalar and starts with a letter into 
> that scalar's value.  The 'starts with a letter' constraint allows dollar 
> values (e.g., $4.95) to pass through unmodified.

I like that! Thanks.

A.L.


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

Date: 3 Apr 1998 05:16:13 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: eval with text files
Message-Id: <6g1rat$ce4$3@marina.cinenet.net>

Andre L. (alecler@cam.org) wrote:
: In article <6g0s0l$cgn$1@marina.cinenet.net>, cberry@cinenet.net (Craig
: Berry) wrote:
: > Andre L. (alecler@cam.org) wrote:
: >
: > : s/\$country/$country/ge;
: > : s/\$name/$name/ge;
: > : 
: > : Those will evaluate $country and $name to their current values.
: > 
: > No need for the e qualifier on those.
: 
: You're right. I humbly stand corrected. I have to study regexps more
: before venturing into helping others. Sorry.

Well, the e's are harmless in this case, so don't feel too bad.  For a 
straight variable substitution, one level of e processing acts just like 
zero -- and I'm still not entirely clear on why that is.

: > As a generic version, you can do
: > 
: >   s/(\$[A-Za-z]\w*)/$1/gee;
: > 
: > to convert everything that looks like a scalar and starts with a letter into 
: > that scalar's value.  The 'starts with a letter' constraint allows dollar 
: > values (e.g., $4.95) to pass through unmodified.
: 
: I like that! Thanks.

You're quite welcome!

---------------------------------------------------------------------
   |   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: 03 Apr 1998 00:35:32 +0200
From: Gisle Aas <aas@sn.no>
Subject: Re: Fetching SSL pages
Message-Id: <m3hg4bc0nf.fsf@furu.g.aas.no>

chenw@dime.com writes:

> I'm managing an intranet site.  To make my life easiler, I usually have a
> perl program go out and fetch other website and put them on our intranet site
> as if coming from our intranet server.  Now things are getting more challenge
> when i need to fetch SSL pages which are using https header. I want to know
> if there are any way to using perl or any method to fetch web pages from SSL
> sites???

LWP/Crypt::SSLeay works.

-- 
Gisle Aas


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

Date: Thu, 02 Apr 1998 23:29:47 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: How do I strip newlines from a var
Message-Id: <352465C1.CB9D1F37@coos.dartmouth.edu>

Kevin Reid wrote:
> 
> Bryan Sapot <bsapot@office1.gundaker.com> wrote:
> 
> > how can i strip new lines out at var.
> 
> $var =~ s/\n//g;

tr is more efficient here.

$var =~ tr/\n//d;

> If you want to replace the newlines with a space: $var =~ s/\n/ /g;

Here too.

$var =~ tr/\n/ /;

> (I am posting this message partly to reduce the unhelpful atmosphere of
> c.l.p.m)

clpm helps those who help themselves.

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Thu, 02 Apr 1998 23:32:12 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: How to timeout TCP connect?
Message-Id: <alecler-0204982332120001@dialup-63.hip.cam.org>

In article <35240FFB.D1C6CB0F@ral1.zko.dec.com>, jc@eddie.mit.edu signed:

> Q: How does Bill Gates change a light bulb?
> A: He doesn't; he declares darkness the new industry standard,
>     and users everywhere stop turning on their lights.

LOL (not list of lists, but laughing out loud).

Q. How does Bill Gates make a light bulb?
A. He steals the concept from Apple and calls it "LightBulb 95".

A.L.


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

Date: 3 Apr 1998 04:56:59 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Looking for ANY Suggestions on parsing this line!!
Message-Id: <6g1q6r$ce4$1@marina.cinenet.net>

Oops, a couple of thinkos in my earlier post -- though the core 
suggestion remains valid...

Craig Berry (cberry@cinenet.net) wrote:
[snip]
: Exactly what to do depends on whether or not you want to preserve the 
: comma in the split fields -- that is, leave (for example) '$1,860.65' 
: in the first line as that, or change it to '1860.65'.  Assume the current 
                                             ^$ inserted here

: line is in $_; here is how to keep the commas:
: 
:   s/(\d),(\d{3})/$1\cA$2/g;        # Turn thousands commas into ctrl-As...
:   @fields = split /,/;             # ...split on remaining commas...

Duh...make that a full-up CSV field-splitter, per Freidl or the like.

:   foreach (@fields) { s/\cA/,/g; } # ...then turn them back to commas.
: 
: If you're willing to irreversibly ditch the thousands commas, then you 
: can use this simpler version:
: 
:   s/(\d),(\d{3})/$1$2/g;
:   @fields = split /,/;

Again, make this a real CSV splitter.

---------------------------------------------------------------------
   |   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: Fri, 03 Apr 1998 02:39:26 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Looking for ANY Suggestions on parsing this line!!
Message-Id: <alecler-0304980239260001@dialup-63.hip.cam.org>

In article <6g0u85$jbe$1@nnrp1.dejanews.com>, paries@advicom.net wrote:

(...)
> the problem is that the program that does the export(that I do not have
> control over) does not put quotes around word 2 and word 8. Even though it is
> suppose to be a csv, they put comma's in the values if over 1000. ARG!@!
> 
> does anyone have any ideas of how to parse this line into words. The values of
> course will be of the same type but different values.
> 
> "MGORDON",$1,860.65,"STAR","$539.35","$1,139.35","$1,739.35",0,$1,860.65
> "LE GRAVES",$1,822.43,"STAR","$577.57","$1,177.57","$1,777.57",0,$822.43


Assuming the line is in $_ ,
assuming that the next-to-last field is always one character, 
and assuming fields 1 and 7 always begin with a $, this appears to work, at least with the two lines above. 

@data = ();
s/"(.*?)",/push(@data,$1),''/ge; # get the quoted fields

# at this point, $_ contains: $1,860.65,0,$1,860.65

s/,(.),/push(@data,$1),'|'/e;    # get the single char field
push(@data,split(/\|/));         # get the last two


The fields in @data are in this order:

MGORDON    -- was field 0
STAR       -- was field 2
$539.35    -- was field 3
$1,139.35  -- was field 4
$1,739.35  -- was field 5
0          -- was field 6
$1,860.65  -- was field 1
$1,860.65  -- was field 7

FWIW,
A.L.

Be gentle with me, I'm just a newbie.


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

Date: Thu, 2 Apr 1998 23:22:38 -0500
From: "Otis Gospodnetic" <otis@POPULUS.net>
Subject: memory usage of DBM vs hashes
Message-Id: <6g1oe4$kfo1@tortola.acunet.net>

Hello,

I was told, and always thought, that if I use some kind of a DBM to store
data my perl script will not use so much RAM since the data will not be held
in memory (RAM) but rather stored on the disk (yes, slower access to data,
but requires less RAM, at least I thought)

But when I run the script like this one below, I get perl to use up to 26 MB
of RAM (more than I can afford)

Furthermore, when I look at the directory when I am running this script I
don't see the .dir and .pag files which looks weird to me (shouldn't they be
stored on the disk??)

Can anyone help me understand the mystery of such high RAM usage when using
DBM files, as well as possible reasons for .dir and .pag files not being on
the disk?

Thanks!

Otis

#!/usr/local/bin/perl

use NDBM_File;

$dbToFetch = tie %ToFetch,  "NDBM_File", "ToFetch", O_RDWR|O_CREAT, 0640;

foreach $n (1 .. 50000) {
    print "$n\n";
    $dbToFetch{$n} = "jdshfjshdfj shdf jsdh fjsdh fjdhsfj shdjfhsd
fjhsdfhsdjf hsjdfhsdjf sjdfh";
}

sleep(10);

foreach $n (50000 .. 1) {
    print "$n\n";
    delete $dbToFetch{$n};
}
__END__




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

Date: 03 Apr 1998 07:55:20 +0100
From: Andrew Gierth <andrew@erlenstar.demon.co.uk>
Subject: Re: memory usage of DBM vs hashes
Message-Id: <87lntniecn.fsf@erlenstar.demon.co.uk>

>>>>> "Otis" == Otis Gospodnetic <otis@POPULUS.net> writes:

 Otis> But when I run the script like this one below, I get perl to
 Otis> use up to 26 MB of RAM (more than I can afford)

 Otis> Furthermore, when I look at the directory when I am running
 Otis> this script I don't see the .dir and .pag files which looks
 Otis> weird to me (shouldn't they be stored on the disk??)

 Otis> #!/usr/local/bin/perl

 Otis> use NDBM_File;

 Otis> $dbToFetch = tie %ToFetch,  "NDBM_File", "ToFetch", O_RDWR|O_CREAT, 0640;

 Otis> foreach $n (1 .. 50000) {
 Otis>     print "$n\n";
 Otis>     $dbToFetch{$n} = "jdshfjshdfj shdf jsdh fjsdh fjdhsfj shdjfhsd

This is modifying the hash %dbToFetch, which is nothing at all to do
with either the tied hash %ToFetch, or the scalar variable $dbToFetch
(which holds a reference to an object that implements the tied hash).

See the example in the documentation of tie().

-- 
Andrew.


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

Date: Thu, 02 Apr 1998 23:05:44 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: Multidimensional hashes
Message-Id: <3524601D.C5F861C5@coos.dartmouth.edu>

webmaster@dataplusnet.com wrote:
> 
> I'm using perl5.002 and need to know how to handle a multidimensional
> associative array.
> I'm using:
> $hash{$foo}{$bar} = $answer;
> and the error occurs:
> syntax error in file ./stats.cgi at line 253, next 2 tokens "}{"

Works for me:

~> perl
$hash{$foo}{$bar} = $answer;
~> 

~> perl -v

This is perl, version 5.002 with DEBUGGING

[...]

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Thu, 02 Apr 1998 23:06:41 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: Multidimensional hashes
Message-Id: <35246055.BF1A3806@coos.dartmouth.edu>

webmaster@dataplusnet.com wrote:
> 
> Both of these lines of code generate the error. These are the exact lines
> from the script.
> Remarking these lines allows the program to operate normally.
> 
> $multi_d_lastcode{"$line_1"}{"$i"} = $code_count;
> $recent_last = $multi_d_lastcode{$pm_block}{$pm_c};

These work for me too.  Could you post more of the surrounding code, along
with the exact error messages you're getting?

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Thu, 02 Apr 1998 01:55:58 GMT
From: UCE-trap_synic@omen.net.au (Peter Caffin)
Subject: Re: Munging addresses (was: Re: Perl Cgi Questions)
Message-Id: <3525efd7.7422021@news.omen.net.au>

Ronald J Kimball <rjk@coos.dartmouth.edu> did cunningly address to
comp.lang.perl.misc..
:Peter Caffin wrote:
:> 
:> [More pointless discussion about munging addresses]
 
I think you'll find I've been using this thread to talk about Perl with NNTP
connections. WRT munging, it's a tedious topic.

--:     _         ___  _    _ _ 
 _oo__ |_|_ |__  _ |  |  _ |_|_' _   synic at omen dot net dot a u
//`'\_ | (/_|(/_| .|. |_(_|| | || |  http://www.omen.net.au/~synic
/              PO Box 869, Hillarys WA 6923, AUSTRALIA


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

Date: Thu, 02 Apr 1998 23:49:05 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: Munging addresses (was: Re: Perl Cgi Questions)
Message-Id: <35246A42.1114A076@coos.dartmouth.edu>

Peter Caffin wrote:
> 
> Ronald J Kimball <rjk@coos.dartmouth.edu> did cunningly address to
> comp.lang.perl.misc..
> :Peter Caffin wrote:
> :>
> :> [More pointless discussion about munging addresses]
> 
> I think you'll find I've been using this thread to talk about Perl with NNTP
> connections. WRT munging, it's a tedious topic.

Woops, my bad.  The bulk of Peter's message was indeed about Perl with NNTP
connections.  It was only at the end of his message where he mentioned
munging, and it was simply to say that it was a boring topic.  He was not
adding to the mind-numbing debate about munging addresses.

I apologize for the error, but stand by my comments on the munging topic in general.

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Thu, 02 Apr 1998 23:27:43 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
To: Rebecca Ideus <becca@emrtc.nmt.edu>
Subject: Re: need help with regexp alternation problem
Message-Id: <35246545.1B2F4286@coos.dartmouth.edu>

[posted and mailed]

Rebecca Ideus wrote:
> 
> However, when I want to match 1/5/98 - 3/27/98, it builds:
> 
> /(Jan\s{1,2}([5-9]|[1-2][0-9]|[3][0-1]).{12}98|
> (Feb)\s{1,2}([1-9]|[1-2][0-9]|[3][0-1]).{12}98|
> Mar\s{1,2}([1-9]|[1][0-9]|[2][0-7]).{12}98)/
> 
> and it doesn't match anything.

Could you be a little more explicit about your problem?  The above regex
succesfully matches the following lines:

Mar  8............98
Feb 18............98
Jan 28............98

Note that you should reorder those inner alternatives, so that the longer
ones come first:  ([3][0-1]|[1-2][0-9]|[1-9])
Otherwise, there is some ambiguity over whether '18' should be matched by
[1] or [1-2][0-9], for example.  (The ambiguity is resolved by the .{12}98
in this case, but it's inefficient and could cause problems in other
situations.)

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Thu, 02 Apr 1998 01:47:45 GMT
From: UCE-trap_synic@omen.net.au (Peter Caffin)
Subject: Re: perl Socket module
Message-Id: <3524ea90.6070581@news.omen.net.au>

gbacon@cs.uah.edu (Greg Bacon) did cunningly address to comp.lang.perl.misc..
:In article <tciEqs91u.7vI@netcom.com>,
:tci@netcom.com (John Tolson) writes:
:: I am trying to run a spam filter from my shell account, the filter is
:: a perl script.  It uses Socket to mail out.  I get an error on the:
:
:Why?  Don't reinvent the wheel.  Open a pipe to sendmail and let it do
:the unfun work for you.

Greg's 100% correct here. It's a more effective way to do things (assuming of
course your script's on a Unix box).

However, to answer to your question about the Socket problem, I must admit
that I also received an error while using "Use Socket;" on my old Slackware
home machine which runs Perl v5.001 patchlevel 1m.

>From everything I've read (particularly the Pelican Book), it's likely it
either wasn't included or had a buggy implementation. Someone a bit closer to
the development side might confirm/deny this for us, depending on whether or
not they consider it a FAQ.

The Pelican Book was written with v5.003 as used version. Myself, I'm still
plodding along with the old version, but, all my Sockets scripts are on my
ISP's machine (Perl v5.003). Whatever the problem is, anyway, your best bet is
to get an updated version of Perl from http://www.perl.org/ which carries
Socket as an integral part.

All the best.

[posted & mailed to John]
--:     _         ___  _    _ _ 
 _oo__ |_|_ |__  _ |  |  _ |_|_' _   synic at omen dot net dot a u
//`'\_ | (/_|(/_| .|. |_(_|| | || |  http://www.omen.net.au/~synic
/              PO Box 869, Hillarys WA 6923, AUSTRALIA


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

Date: Fri, 03 Apr 1998 05:22:18 GMT
From: Barry Margolin <barmar@bbnplanet.com>
Subject: Re: PID numbers with forground and background nums not matching
Message-Id: <em_U.2$R91.12@cam-news-reader1.bbnplanet.com>

In article <mshavel-0204982205000001@130.9.16.207>,
Michael Shavel <mshavel@erols.com> wrote:
>$pid =open RUN, "| $c . &" ;
 ...
>However, if I run the sqr statment in the background (as I do in the code
>above) I get a PID number that is one (1) off. 
>Example:  perl tells me the PID number is 27312 but ps -ef tells me the
>pid number is 27313. 

When the statement includes shell special characters, like '&', Perl
executes a shell to execute the command, instead of executing the command
directly itself.  So $pid is the PID of the shell, which then runs the
command in a subprocess.

If you're lucky and there's nothing else running on the system that spawns
child processes, your $pid+1 will work.  But there's nothing guaranteeing
it.

If you really need to know the PID of the process executing sqr, you should
fork and exec yourself.

-- 
Barry Margolin, barmar@bbnplanet.com
GTE Internetworking, Powered by BBN, Cambridge, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.


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

Date: Fri, 3 Apr 1998 04:23:42 -0300
From: Flavio Veloso <flaviovs@centroin.com.br-ZZZ->
To: Ryan Day <r.day@mbox.unicc.org>
Subject: Re: Ping
Message-Id: <Pine.BSI.3.96.980403041951.20424B-100000@trex.centroin.com.br>

On Mon, 30 Mar 1998, Ryan Day wrote:

> > Is it possible to do a "ping" to a host using only perl and not the
> > system=B4s ping-command?
> > I want to watch some (1300) servers in the net and only need toknow  if
> > they are pingable. My current
> > solution uses the os ping-command and is far to slow.
> >
> > Please reply via email.
> > --
> > Tim Richter
> > Tim.Richter@Dresdner-Bank.com
>=20
>   Try Net::Ping.  It doesn't use the system's ping.

But it uses the TCP echo port which isn't the *real* ping. And since
many (most?) sysadmin disable this service in their host for security
reason (I strongly recommend anyone to do this), Net::Ping is almost
unusable.

At least the module name is incorrect, IMHO. When you say "ping"
you're talking about ICMP echo request/reply (doesn't you?), not TCP
echo.

- Flavio



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

Date: Fri, 03 Apr 1998 04:24:00 GMT
From: jgloudon@hyssop.bbn.com.bbn.com (Jason Gloudon)
Subject: Re: processing big file
Message-Id: <slrn6i8p4n.5t.jgloudon@hyssop.bbn.com>

sekchye <sekchye@singnet.com.sg> wrote:
 .
>I have a perl script to process a system log file.  This log file can be
>quite huge, say 5-10 MB.  I am using the perl open() function to read in
>the file for processing and I am running into some problem.  The program
>complains out of memory and did not process the log file correctly.  My
>question is:

What version of perl are you using ? There are known memory leaks in many
versions of perl5.

>1.  Is there a limit in the size of the file open() can read in line by
>line?

Yes, but 5-10 megabytes is much lower than the limit on most systems.
You have not said what your code is doing or posted any of it so all I can
do is guess :

Does it build arrays or associative arrays or use objects ?
Are you certain that you are emptying arrays at the appropriate time ?
Do you create objects that contain references to themselves ?

>2.  For huge file (5-10 MB), are there more other efficient functions I
>can use to read in line by line?

Efficient in terms of Memory ? No.

--
Jason Gloudon


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

Date: Thu, 2 Apr 1998 19:46:01 +0100
From: Rosemary I H Powell <Rosie@dozyrosy.demon.co.uk>
Subject: Re: random picture for web page
Message-Id: <pnDWDBApz9I1Ewbh@dozyrosy.demon.co.uk>

In article <stanz.1.00086595@en.com>, stan zylowski <stanz@en.com>
writes
>hello,
>i am new to perl. but i would like to know if there are any random picture 
>scripts or random quote scripts.  i am familiar with javascript but
>want to offer random functions to all browsers
>
>thank you.
>stan

One of Randal's Web Techniques columns covers random thingies in great
detail, but there are also a number of simple random scripts to be
found.

Here is an example, from Shishir Gundavaram's CGI Programming on the WWW
book, which you might use as a starting point. It can easily  be
modified to select random images/quotes instead of URLS, and you could
also read in your random thingies from a file....

#!/usr/local/bin/perl

@URL = ("http://www.ora.com",
        "http://www.digital.com",
        "http://www.ibm.com",
        "http://www.radius.com");

srand (time | $$);

$number_of_URL = $#URL;
$random = int (rand ($number_of_URL));

$random_URL = $URL[$random];

print "Content-type: text/html", "\n\n";
print qq|<A HREF="$random_URL">Click here for a random Web site!</A>|,
"\n";

exit (0);

Rosemary
PS I wouldn't dare mention Matts Script Archives in the same breath as
mentioning Randal  :-) 
-------------------------------------------------------------------
| Rosemary I.H.Powell  EMail: Home: rosie@dozyrosy.demon.co.uk    |
|                             Work: r.i.h.powell@rl.ac.uk         |
|                       http://www.netlink.co.uk/users/dozyrosy/  |
|                       http://www.dozyrosy.demon.co.uk/          |
|                       http://www.CavalierKingCharles.com/       |
-------------------------------------------------------------------


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

Date: Fri, 03 Apr 1998 06:53:04 GMT
From: rodb(remove)@dial.pipex.com (Rod Borland)
Subject: Subscribing to a list without duplicates
Message-Id: <35248032.2505914@news.saix.net>

Can anyone help me? I am using perl to create a list of subscribers
and the program I downloaded to do it allows people to subscribe
multiple times which is a real pain - like this:

if ($FORM{'action'} eq 'Subscribed') {

  open (FILE,">>$basedir/$subscribe");
  print FILE "$FORM{'email'}\n";
  close(FILE);
  $ok = "Y";
}

I tried this mod which is a variation on the unsubscribe function but
does not work: 


$checksub = "false"

if ($FORM{'action'} eq 'Subscribed') {

  open (FILE,"$basedir/$subscribe");
  @email=<FILE>;
  close(FILE);

  open (FILE,">>$basedir/$subscribe");
  foreach $email (@email) {
    if ($email = $FORM{'email'}) {
      $checksub = "true";
      $ok = "Y";
    }
   if ($checksub = "false") {
      open (FILE,">>$basedir/$subscribe");
      print FILE "$FORM{'email'}\n";
      close(FILE);
      $ok = "Y";
   }  
}

I do have access to the server logs so am programming blind and I do
not get any error messages back.

Rod Borland
rodb(remove)@dial.pipex.com
http://www.ten.org/
http://www.wildnetafrica.com/


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

Date: 03 Apr 1998 08:26:57 +0200
From: Roland Huss <roland@consol.de>
Subject: Re: Sysadmin struggeling with PERL/Sed and etc...
Message-Id: <55ra3fpgi6.fsf@rom.supportpartner.munich.sgi.com>

Ronald J Kimball <rjk@coos.dartmouth.edu> writes:

> <> magically assigns to $_ *only* when it is alone in the conditional of a
> while or for loop.  Your code reads in a line from IN1 or IN2, throws it away,
> and prints the value of $_.  You need to add an explicit assignment to $_.

oops, you are absolutely right, of course. 'still wondering how easily
I can step into silly traps, when it's to early in the morning ;-). 
sorry....

-- 
								...roland 



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

Date: Fri, 03 Apr 1998 07:40:57 GMT
From: hertlein@umich.edu (Marcus P Hertlein)
Subject: Re: Trouble with shebang line ...
Message-Id: <do0V.671$3C1.2834866@news.itd.umich.edu>

I have a life, and I can prove it! (jefpin@bergen.org) wrote:
: >	% perlscript.pl
: >
: >i get perlscript.pl: Command not found.  Yes, the file is executable,
: >and Yes,  i have the correct path for the interpreter.  If anyone has
: >any suggestions as to what it might be that i am over-looking, they
: >would be appreciated.  

: Try this:
: 	% ./perlscript.pl

: Chances are your path is set up NOT to include ., which is your current
: directory... it is often overlooked, and is the cause of this error (most
: likely).



Maybe it's this problem (from 'man perlrun') ? :

     Because many operating systems silently chop off kernel
     interpretation of the #! line after 32 characters, some
     switches may be passed in on the command line, and some may
     not; you could even get a "-" without its letter, if you're
     not careful.  You probably want to make sure that all your
     switches fall either before or after that 32 character
     boundary.  Most switches don't actually care if they're
     processed redundantly, but getting a - instead of a complete
     switch could cause Perl to try to execute standard input
     instead of your script.  And a partial -I switch could also
     cause odd results.
 
Is the number of characters after the !# in your file less than 32?


--- Marc
{hertlein(at)umich[dot]edu[nothing]}


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

Date: Thu, 02 Apr 1998 23:33:25 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
To: mhanson@arrowweb.com
Subject: Re: using &say("something");
Message-Id: <3524669C.C8BA36B9@coos.dartmouth.edu>

[posted and mailed]

Mike wrote:
> 
> Whats wrong with this? How come it doesn't print Hello Mike How are you?
> What do you have to do so it will?
> 
> &say("Hello Mike How are you");
> sub say {
> print ("Content-type: text/html\n\n");
> print <<"html";
> ...
> $_
  ^^
> ...

The arguments to a subroutine passed via @_, not $_.

Check out the documentation for perlvar for more information on these variables.

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 3 Apr 1998 04:32:35 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: using &say("something");
Message-Id: <6g1op3$886$1@comdyn.comdyn.com.au>

In article <3524440A.7D70@arrowweb.com>,
	Mike <mhanson@arrowweb.com> writes:
> Whats wrong with this? How come it doesn't print Hello Mike How are you?

Because you didn't ask it to do that.

> What do you have to do so it will?

Refer to the right variable.

> #!/usr/local/bin/perl

Where is the -w flag? No use strict?

> &say("Hello Mike How are you");

> sub say {
> print ("Content-type: text/html\n\n");

Why do you use a separate print statement for this, immediately
followed by

> print <<"html";

this here-document construct?

> <HTML>
> <HEAD>
> <TITLE>Admin</TITLE>
> </HEAD>
> <BODY bgcolor=ffffff>

<HTML remark>
Do you really expect this colour to work correctly?
</HTML remark>

> $_

Ah, this is empty here. Nothing filled $_. You probably want $_[0],
the first element of @_.

> </BODY>
> </HTML>
> html
> exit;

An exit inside of a sub? Ugly. Bad. Bad. Bad.
Besides, it doesn't do a thing.

> }

perldoc perlvar

look for $_ and @_.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Little girls, like butterflies, need no
Commercial Dynamics Pty. Ltd.       | excuse - Lazarus Long
NSW, Australia                      | 


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

Date: 3 Apr 1998 05:04:41 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: using &say("something");
Message-Id: <6g1ql9$ce4$2@marina.cinenet.net>

Mike (mhanson@arrowweb.com) wrote:
: Whats wrong with this? How come it doesn't print Hello Mike How are you?
: What do you have to do so it will?
: 
: #!/usr/local/bin/perl
: &say("Hello Mike How are you");
: sub say {
: print ("Content-type: text/html\n\n");
: print <<"html";
[snip]
: $_
[snip]
: html

Where did $_ ever get set?  On entry to say(), @_ contains the list 
("Hello Mike How are you"), but $_ is undefined.  If you were to add a 
line like

  $_ = shift @_;

or

  ($_) = @_;

at the top of the function block, you might have better luck.

: exit;

Why do an explicit exit, rather than just returning and letting the 
script die a natural death?  It's generally poor form to exit the app 
from within a subroutine (unless you have a very good reason to do so, or 
if you encounter a fatal error).

: }

HTH!

---------------------------------------------------------------------
   |   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: Thu, 02 Apr 1998 23:27:44 -0600
From: ivanovic@cs.monash.edu.au
Subject: Using Pack "Creatively"
Message-Id: <6g1s0g$l6r$1@nnrp1.dejanews.com>

This may be a dumb question, but does anyone out there know how to >simply
and easily< Pack/Unpack a numerical variable (e.g. the number 500) into an N
bit binary structure (e.g. 16 bits).

I do not want to use (i) pack "c", 500 (gives an 8 bit structure) nor do I
want to use (ii) pack "s", 500 (gives a 32 bit structure)... I want to use
pack and encode it into, say, a 16 bit structure, or more generally an N bit
structure.

By the way, (pack "c2", 500) does NOT work - I tried.

Likewise, and more importantly for my project, I have to decode some 16 bit
numbers.. and the best I can currently do is to unpack into a 16 character
bit string using (unpack "B16", $my_var), and then do a HAND (yawn!) decode
into decimal representation. Surely there's got to be an easier way!

MiloMan


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

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

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