[19101] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1296 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 13 03:05:37 2001

Date: Fri, 13 Jul 2001 00:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <995007912-v10-i1296@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 13 Jul 2001     Volume: 10 Number: 1296

Today's topics:
        about fcntl <lijinzhi@263.net>
    Re: Another flock question (Eric Audet)
    Re: Another flock question (Tad McClellan)
    Re: argument in regular expression <ren@tivoli.com>
    Re: Causing a slow page delivery (on purpose) <dbe@wgn.net>
    Re: Deleting a line, when an string is matched; possibl <hafner-usenet@ze.tu-muenchen.de>
        dynamically loading perl variables <smarx@i2000.com>
    Re: dynamically loading perl variables <gtoomey@usa.net>
    Re: Efficiency hit of $1 in Regexps? <mnemotronic@mind\no-spam/spring.com>
    Re: Efficiency hit of $1 in Regexps? <pne-news-20010713@newton.digitalspace.net>
    Re: Error in Image::Magick (Martien Verbruggen)
        FAQ: What mailing lists are there for Perl? <faq@denver.pm.org>
    Re: hash table <e0ad02j5d7@worldnet.att.net>
    Re: hash table (Tad McClellan)
    Re: inline average <bigrich318@yahoo.com>
        my <alex82p@svs.ru>
    Re: my (E.Chang)
    Re: one billion seconds for the "time" function :) and  (Tim Hammerquist)
        OT: Re: searching google <prarie dawn   @hotmail.com>
    Re: Q about fork and kill <bwalton@rochester.rr.com>
    Re: Q about fork and kill (Logan Shaw)
    Re: rand confusion (Philip Lees)
    Re: rand confusion (Logan Shaw)
        script already running <hans@salience.nl>
        searching google <citykid@nospam.com>
    Re: searching google <tony_curtis32@yahoo.com>
    Re: searching google (Randal L. Schwartz)
    Re: sendmail limitations? <ayamanita.nospam@bigfoot.com>
        Successful compile of Perl 5.6 on NCR MP-RAS 3.0 (the_rev_dharma_roadkill)
    Re: Using a variable in a regular expression <pne-news-20010713@newton.digitalspace.net>
    Re: Very good regex question? <wyzelli@yahoo.com>
    Re: Very good regex question? (Logan Shaw)
    Re: Very good regex question? <wyzelli@yahoo.com>
        what use is the folder <gaultalan@hotmail.com>
    Re: what use is the folder <gtoomey@usa.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 13 Jul 2001 10:15:32 -0500
From: "sarah" <lijinzhi@263.net>
Subject: about fcntl
Message-Id: <9illgt$ag$1@crchh14.us.nortel.com>

I use perl 5.0 in Solaris.
And I think the third parameter of fcntl(FILEH,F_SETLK,?) should not be a
simple variable,but I don't know what to fill in, maybe a hash or a array.
There is no
function prototype in perl,which is different from C.

But if I wrtite:

    use Fcntl;
    my ($ret_1, $ret_2, %lockret);
    if (open(FILEH,">t2"))
    {
        %lockret=(type=>F_UNLCK,whence=>SEEK_SET,start=>0, len=>0);
        $ret_1=fcntl(FILEH, F_GETLK, %lockret);
        %lockret=(type=>F_WRLCK,whence=>SEEK_SET,start=>0, len=>0);
        $ret_2=fcntl(FILEH, F_SETLK, %lockret);
      }
The value of ret_1 and ret_2 are still undefined, why?

Thanks!








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

Date: 12 Jul 2001 18:14:29 -0700
From: eaudet@solution123.com (Eric Audet)
Subject: Re: Another flock question
Message-Id: <9e41e06.0107121714.6331396b@posting.google.com>

> And what is the problem with solution 1 then?
> 
> 
> Looks OK to me with regard to deleting the lock file.

I didn't know I could unlink a file before to CLOSE the handle....

What happen to the lock? Is it removed once I unlink the file? (I
guess so ... stupid question)

Eric


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

Date: Fri, 13 Jul 2001 00:58:26 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Another flock question
Message-Id: <slrn9ksvvi.la0.tadmc@tadmc26.august.net>

Eric Audet <eaudet@solution123.com> wrote:
>> And what is the problem with solution 1 then?
>> 
>> 
>> Looks OK to me with regard to deleting the lock file.
>
>I didn't know I could unlink a file before to CLOSE the handle....


This is all file-system stuff so it kinda depends on the OS involved.
I'll assume a usual *nix fs.


>What happen to the lock? 


Nothing happens to the lock when you unlink() it, only when you 
close() it.


>Is it removed once I unlink the file? (I
>guess so ... stupid question)


It is both stupid AND valuable though. Thanks for asking it.

Stupid 'cause I wouldn't have said it looked OK if unlink()
made you lose the lock.   :-)

Valuable 'cause we've found something you don't know about.


The fs does a kind of "reference counting" on files (inodes).
When you got the filehandle, it noted that there are now 2
references to the file, one from your filehandle, and one
from the file's "name" (and even more than 2 if there are
links).

unlink() removes the "name" reference, but the fs doesn't
reclaim the space yet because the ref count is not zero
due to your filehandle. When the filehandle is close()d,
_then_ the ref count will become zero and the space reclaimed.

(this is, infact, why it is named "unlink" instead of "remove")


So "solution 1" seems just fine.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 12 Jul 2001 20:15:16 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: argument in regular expression
Message-Id: <m3vgkxvdcr.fsf@dhcp9-161.support.tivoli.com>

On Thu, 12 Jul 2001, leclerc.fabrice@wanadoo.fr wrote:

> I just realized that it doesn't do exactly what I want. There are
> some particular cases where the pattern /position:<number>-/ appears
> twice or more in the same paragraph. Everytime it occurs, only the
> first pattern is identified and the following ones are omitted. For
> example, if I have two patterns: /position:200-/ and
> /position:2000-/ in this order in the same paragraph:
> 
> the perl command:
> perl -ne '$/ = "\n\n"; print if /position:(\d+)-/ and $1 >= 200 and $1 
> <= 250;' 
> gives the paragraph which contains both patterns (/position:200-/ and 
> /position:2000-/) 
> 
> the perl command:
> perl -ne '$/ = "\n\n"; print if /position:(\d+)-/ and $1 >= 2000 and $1 
> <= 2500;' 
> does not give any hit.
> 
> Is there any way to fix this problem.

perl -n000e 'print if /position:(\d+)(?(?{ $1 >= 2000 && $1 <= 2500 })|(?!))/'

which can be simplified slightly by inversion:

perl -n000e 'print if /position:(\d+)(?(?{ $1 < 2000 || $1 > 2500})(?!))/'

The point is to make the match fail if the number is out of range so
that it can backtrack and try to match a different place in the
paragraph.

See perlrun(1) for the -0 option to replace setting $/.  This does
assume that you are OK with paragraph slurping, which is slightly
different from what you were doing (the way it handles extra blank
lines differs).

-- 
Ren Maddox
ren@tivoli.com


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

Date: Thu, 12 Jul 2001 18:33:44 -0700
From: "$Bill Luebkert" <dbe@wgn.net>
Subject: Re: Causing a slow page delivery (on purpose)
Message-Id: <3B4E4FF8.84D31068@wgn.net>

Scott Porter wrote:
> 
> On Wed, 11 Jul 2001 17:39:59 -0400, Benjamin Goldberg <goldbb2@earthlink.net> wrote:
> 
> >Scott Porter wrote:
> >>
> >> I'm using the apache server on Linux; my goal is to delivery a page
> >> incrementally to the browser, so it can delivery constantly changing
> >> data as a "stream". While this works fine with a java app, bypassing
> >> apache, it doesn't give the required results under apache. The page
> >> shows no data until the perl script exits. Is it possible to send
> >> content that forces apache to flush whatever the perl script has
> >> passed on to the browser, or is it impossible?
> >>
> >> The reason for having to serve via apache is because my web host
> >> doesn't allow java servlets, or "persistant" scripts (which kind of
> >> rules out writing a daemon!)
> >
> >There are a number of possible reasons.
> > * Consider is $|, which controlls buffering.  Turn it off if you want
> >to avoid buffering.
> > * If you are ending lines with \n, and the browser is reading lines
> >split on \r\n, it will not display until it either sees a \r\n or an
> >EOF.
> > * If you have some piece of html which your browser can't display until
> >it's recieved all of it.  Tables are one of the most common sources of
> >this problem -- to fix it, you need a COL or COLGROUP tag.  Images are
> >similar -- add a width and a height.
> > * A proxy may be present, possibly doing some buffering itself.  How to
> >turn off buffering there depends on the proxy.
> 
> Still no joy... There's no proxy in the way, as I'm testing via a linux server on my
> home network. I just tried viewing the page using lynx (for anyone unfamiliar, it's a
> text-mode web browser that runs from a shell prompt), and I can see the page IS being
> delivered to the browser slowly; lynx shows bytes received as they come through; but
> even lynx waits until it's all delivered before displaying the page! So it appears I
> have to send out something else?
> 
> Here's my test script, as you can see, I'm adding full headers before the content.
> I've also tried "Connection: close", sending a zero byte after every line, and
> setting the content length to 2:
> 
> #!/usr/bin/perl -w
> 
> use strict;
> 
> $| = 1;
> my $crlf = "\015\012"; # \r\n
> print "Content-Length: 90000\n";
> print "Connection: open\n";
> print "Content-type: text/plain", $crlf x 2;
> for( 1..5 ) {
>         print "x" . "\012";

Have you tried forcing your output buffer to overflow with something like:

          print ' ' x 4096;

Which won't take up any screen space but will fill any buffering along the 
way.

>         sleep 1;
>         print "y" . $crlf;
>         sleep 1;
> }
> 
> Any other thoughts? :-)
> 
> Anyone? :-))


-- 
  ,-/-  __      _  _         $Bill Luebkert   ICQ=14439852
 (_/   /  )    // //       DBE Collectibles   Mailto:dbe@todbe.com 
  / ) /--<  o // //      http://dbecoll.webjump.com/ (Free Perl site)
-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic http://www.todbe.com/


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

Date: 13 Jul 2001 08:21:55 +0200
From: Walter Hafner <hafner-usenet@ze.tu-muenchen.de>
Subject: Re: Deleting a line, when an string is matched; possible?
Message-Id: <srjg0c1mjr0.fsf@w3proj1.ze.tu-muenchen.de>

Ronald Blaschke <TGVCDPVNTLMI@spammotel.com> writes:

> How about
>      perl -ni.backup -e'print unless /word2/'
> 
> 
> Nick wrote:
> 
> > Guru's,
> > 
> > Problem is thus. Have a file that is something like this:
> > 
> > line1 word1 word2 word3 word4
> > line2  word10 word20 word30 word40
> > line3 word11 word21 word31 word41
> > line4 word1a word2a word3a word4a
> > 
> > well, actually, I have several hundred files like this, all in different
> > directories, but anyway,
> > what I want to do, is to find a string, for example 'word2' and when that is
> > found in this file,
> > delete the line it is found on.
> > 
> > perl -pi.backup -e 's|word2||' would find it, and delete the 'word2'. but
> > how do I delete then entire line???

That would kill all lines with "word21", "myword2" etc in it, too.

Check for word boundaries with \b

-Walter


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

Date: Thu, 12 Jul 2001 23:35:35 -0400
From: "Steve" <smarx@i2000.com>
Subject: dynamically loading perl variables
Message-Id: <Z1u37.605$4k1.6577@newsreader.i-2000.net>

if i have a text file witha tag called $tagx where tagx = string then i can
readily scan this text file and easily isolate the string.

given that the tags are called $tagx, in the text file, is there a simple
method to load a perl variable of the same name, i.e. $tagx, with the string
? that is, without the use of lots of if statements.

steve marx




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

Date: Fri, 13 Jul 2001 14:28:20 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: dynamically loading perl variables
Message-Id: <dzu37.236$a04.1028@newsfeeds.bigpond.com>


"Steve" <smarx@i2000.com> wrote in message
news:Z1u37.605$4k1.6577@newsreader.i-2000.net...
> if i have a text file witha tag called $tagx where tagx = string then i
can
> readily scan this text file and easily isolate the string.
>
> given that the tags are called $tagx, in the text file, is there a simple
> method to load a perl variable of the same name, i.e. $tagx, with the
string
> ? that is, without the use of lots of if statements.
>
> steve marx
>
>

A list of hashes may be more what you need.

Have a look at the example below
(Note file format is  LEAD=fred FRIEND=barney)

http://www.cpan.org/doc/FMTEYEWTK/pdsc/pdsc-3.html

G. Toomey






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

Date: Thu, 12 Jul 2001 21:42:20 -0600
From: pt <mnemotronic@mind\no-spam/spring.com>
Subject: Re: Efficiency hit of $1 in Regexps?
Message-Id: <3B4E6E1C.68113D3E@mindspring.com>



Tad McClellan wrote:

> Jonathan Stephen Yurek <jyurek@WPI.EDU> wrote:
>
> >I know that the addition of capturing into one
> >regexp means that perl has to include capturing for all of them
>
> You need to unknow that, because it is not true  :-)
>
> There is no program-wide penalty associated with using the
> dollar-digit variables. Go ahead and use them when you need them.
>
> You are no doubt thinking of some other issue. Mentioning $', $`
> or $& (maybe) slows things down.
>

    Now I'm cornfuzed .... This is from perlre:

WARNING: Once Perl sees that you need one of $&, $`, or $' anywhere in
the program, it has to provide them for every pattern match. This may
substantially slow your program. Perl uses the same mechanism to produce
$1, $2, etc, so you also pay a price for each pattern that contains
capturing parentheses.

    It's that part that says " .... pay a price for each pattern that
contains capturing ..." that has me confused.  Would 'capturing' which
generates the $n variables be included in that??  Reading this leads me
to believe (perhaps incorrectly) that the EFFECT of using $& $` and $'
is the same as that of using $1, $2, etc ("perl uses the same
mechanism...").
    Documentation continues......

(To avoid this cost while retaining the grouping behavior, use the
extended regular expression (?: ... ) instead.) But if you never use $&,
$` or $', then patterns without capturing parentheses will not be
penalized. So avoid $&, $', and $` if you can, but if you can't (and
some algorithms really appreciate them), once you've used them once, use
them at will, because you've already paid the price. As of 5.005, $& is
not so costly as the other two.

    Now this seems to indicate that the implementation of $& is
different from $` and $'.  I might be tempted to surmise that, based on
the similarity of $& to $1, $2 etc (vs $& to $` and $'), that perhaps
these are all handled differently.  But then I'm always following
surmises into bad neighborhoods.





>
> Mentioning $1 only slows down the pattern match that it appears in.
> Other pattern matches are unaffected.
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas


Remove the obvious anti-spam to reply.


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

Date: Fri, 13 Jul 2001 07:05:49 +0200
From: Philip Newton <pne-news-20010713@newton.digitalspace.net>
Subject: Re: Efficiency hit of $1 in Regexps?
Message-Id: <cevsktktbpag4vfc8d4lljc9kafslpqq50@4ax.com>

On Thu, 12 Jul 2001 21:42:20 -0600, pt
<mnemotronic@mind\no-spam/spring.com> wrote:

> WARNING: Once Perl sees that you need one of $&, $`, or $' anywhere in
> the program, it has to provide them for every pattern match. This may
> substantially slow your program. Perl uses the same mechanism to produce
> $1, $2, etc, so you also pay a price for each pattern that contains
> capturing parentheses.
> 
>     It's that part that says " .... pay a price for each pattern that
> contains capturing ..." that has me confused.  Would 'capturing' which
> generates the $n variables be included in that??

It means exactly that. That's what capturing parentheses are -- the ones
that update $1, $2, etc.

> Reading this leads me to believe (perhaps incorrectly) that the EFFECT
> of using $& $` and $' is the same as that of using $1, $2, etc ("perl
> uses the same mechanism...").

Not quite. Note the difference between "for every pattern match" and
"for each pattern that contains capturing parentheses".

While the mechanism for gathering the data is the same, using $& $` $'
will affect every pattern match in the program, while capturing
parentheses (even if you don't use $1 et al.!) only affect the pattern
match containing them.

The difference is, I suppose, that the capturing parentheses are
themselves part of the regular expression, so Perl knows they are
confined to that regular expression. If you use $1 etc. without having a
previous regular expression with capturing parens, you don't incur a
penalty. With $& and friends, however, Perl can't match them up to any
particular expression (since they apply to the last *successful* pattern
match, which could, at run-time, be any of them). So it has to provide
$& $` $' support for every pattern match in the program.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Fri, 13 Jul 2001 02:47:56 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Error in Image::Magick
Message-Id: <slrn9ksoas.4ot.mgjv@verbruggen.comdyn.com.au>

On Fri, 13 Jul 2001 00:05:04 +0900,
	Batara Kesuma <bkesuma@REMOVE.CAPITALS.yahoo.com> wrote:
> 
> [root@hades PerlMagick-5.34]# make
> 
> What happened? How can I fix it? Oh yes, and my ImageMagick.rpm is:
> ImageMagick-5.2.2-5

You can't use two different versions of ImageMagick. If you want to
use the 5.2.2 binaries, you'll have to use the 5.2.2 Perlmagick.

The best thing to do is to get the source distribution of ImageMagick,
uninstall the RPM, and compile it yourself. The source distribution
also has PerlMagick.

I've always had most success with a configure without Perl, then a
make and an install. After it's installed, I cd to the Perlmagick
directory and install that.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | 42.6% of statistics is made up on the
Commercial Dynamics Pty. Ltd.   | spot.
NSW, Australia                  | 


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

Date: Fri, 13 Jul 2001 06:17:02 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: What mailing lists are there for Perl?
Message-Id: <ynw37.83$T3.192946688@news.frii.net>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.

+
  What mailing lists are there for Perl?

    Most of the major modules (Tk, CGI, libwww-perl) have their own mailing
    lists. Consult the documentation that came with the module for
    subscription information.

            http://lists.cpan.org/  

- 

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to

    news:news.answers

or to the many thousands of other useful Usenet news groups.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-1999 Tom Christiansen and Nathan
    Torkington.  All rights reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.

                                                           02.14
-- 
    This space intentionally left blank


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

Date: Fri, 13 Jul 2001 01:25:34 GMT
From: "sinbad" <e0ad02j5d7@worldnet.att.net>
Subject: Re: hash table
Message-Id: <i6s37.2551$gj1.141084@bgtnsc05-news.ops.worldnet.att.net>

John W. Krahn Wrote:
>
> while ( my $line = <IN> ) {
>     my ( $key, @line_arr ) = split /\t/, $line;
>     $my_hash{ $key } = [ @line_arr ];
>     }
>
>
>
> John
> --
> use Perl;
> program
> fulfillment

What John suggested is the best, read section "COMMON MISTAKES" on
http://www.perldoc.com/perl5.6/pod/perldsc.html to learn more.

/Sindbad.




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

Date: Fri, 13 Jul 2001 01:06:42 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: hash table
Message-Id: <slrn9kt0f2.la0.tadmc@tadmc26.august.net>

sinbad <e0ad02j5d7@worldnet.att.net> wrote:
>John W. Krahn Wrote:
>>
>> while ( my $line = <IN> ) {
>>     my ( $key, @line_arr ) = split /\t/, $line;
>>     $my_hash{ $key } = [ @line_arr ];
>>     }

>What John suggested is the best, 
                        ^^^^^^^^

What John suggested will work, and that is the ultimate test.

I do not think it is the "best" though...


>read section "COMMON MISTAKES" on
>http://www.perldoc.com/perl5.6/pod/perldsc.html to learn more.


I guess I like the "dangerous-looking construct" approach then  :-)


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 12 Jul 2001 23:47:33 -0500
From: "Rich" <bigrich318@yahoo.com>
Subject: Re: inline average
Message-Id: <tksvdm2lub0043@corp.supernews.com>


"Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message news:3B4CBAB6.D05F2E6D@earthlink.net...
<snip>
> Or possibly:
> tie $values{average}, "Average", \%values;
>
> This gives all the benefits of a tied scalar, without having to create
> another variable for it... and it's only one value that's tied, not the
> whole hash.

You mean like in the example I gave on 7/1/01?

####################
"Rich" <bigrich318@yahoo.com> wrote in message news:tju1btnbp33b17@corp.supernews.com...
>
> "David Frauzel" <nogard@gnosrehtaew.ten> wrote in message
> news:9hm1cs$2h15$1@news.aros.net...
> > This is perhaps esoteric, but I'm curious.
> <snip, see previous posts>
>
> You could tie the scalar variable $values{average}.
>
> #!/usr/bin/perl -w
>
> package Average;
>
> sub TIESCALAR {
>  my ($class, $hashref) = @_;
>  return bless $hashref, $class;
> }
>
> sub STORE {
>  #called when value assigned to tied variable
>  #not sure what you'd do here in this case
>  return;
> }
>
> sub FETCH {
>  my $self = shift;
>  my $total = 0;
>  my $colors = 0; #number of valid color values to average
>  foreach my $color (keys %$self) {
>  if ($color ne "average"
>           &&
>           # Don't use value of  $values{$color} unless it's a number
>           $$self{$color} =~ /^-?(?:(?:\d+\.?\d*)|(?:\d*\.\d+))$/) {
>             $total += $$self{$color};
>             $colors++;
>     }
>   }
>   return sprintf("%.2f", $total /= $colors);
> }
>
>
> package main;
>
>
> my %values = (
>   red => 5.0,
>   orange => 4.0,
>   yellow => 5.5,
> );
>
> tie ($values{average}, "Average", \%values);
<snip>
#############################################


Just curious.


Rich




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

Date: Thu, 12 Jul 2001 11:05:59 +0400
From: "Alex" <alex82p@svs.ru>
Subject: my
Message-Id: <9ilps5$gfj$1@josh.sovintel.ru>

What the statement "my" means?





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

Date: Fri, 13 Jul 2001 04:06:26 GMT
From: echang@netstorm.net (E.Chang)
Subject: Re: my
Message-Id: <Xns90DD1B47A9F7echangnetstormnet@207.106.92.86>

"Alex" <alex82p@svs.ru> wrote in <9ilps5$gfj$1@josh.sovintel.ru>:

> What the statement "my" means?
> 

From the documentation

    A my declares the listed variables to be local (lexically) to the 
enclosing block, file, or eval. If more than one value is listed, the 
list must be placed in parentheses.

For a good discussion of my,see "Coping with Scoping" at 
http://perl.plover.com/FAQs/Namespaces.html

-- 
EBC


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

Date: Fri, 13 Jul 2001 01:07:44 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: Re: one billion seconds for the "time" function :) and a question about time
Message-Id: <slrn9ksj5u.5f6.tim@vegeta.ath.cx>

Me parece que B <Orbitguy@concentric.net> dijo:
> Playing around with the "time" and "gmtime" functions, I noticed that
> the value returned by "time" will hit 1,000,000,000 seconds( a billion
> US, a thousand million in UK, I think) 
> on Sunday. Sept. 9, GMT 01:46:40  2001 ...
> sounds like as good an excuse as any for a party :)

Check out http://web.stonehenge.com/merlyn/
Section labeled 'More important, the countdown to U1e9'

Enjoy! =)
-- 
-Tim Hammerquist <timmy@cpan.org>

Of course, that's just my opinion.  I could be wrong.
    -- Dennis Miller


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

Date: Fri, 13 Jul 2001 05:09:50 GMT
From: "Prarie Dawn" <prarie dawn   @hotmail.com>
Subject: OT: Re: searching google
Message-Id: <995000990.382157@atlas.corp.au.home.com>

> Beep beep!  Out of my way, I'm a motorist!

Hehe, that's so true.

Is that a quote from Wind In The Willows?






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

Date: Fri, 13 Jul 2001 03:11:15 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Q about fork and kill
Message-Id: <3B4E66FC.FAC639AA@rochester.rr.com>

gene wrote:
> 
> I'm playing around with fork, following the code in the cookbook:
> 
>    1: #!/usr/bin/perl
>    2:
>    3: print "start: $pid\n";
>    4:
>    5: FORK: {
>    6:   if ($pid = fork) {
>    7:       print "forking\n";
>    8:           while (kill 0 => $pid) {
>    9:                   print "still going\n";
>   10:                   sleep(1);
>   11:           }
>   12:   } elsif (defined $pid) {
>   13:       print "inside child\n";
>   14:   }
>   15: }
>   16: print "ending: $pid\n";
> 
> This works on one machine (Mac OS X), but on another machine (SunOS)
> the kill statement on line 8 never registers that the child is dead.
> Since this is perl, I'm sure there are many ways to do this.  What do
> people recommend?
> 
> Also, I have a general fork question. I'm having some trouble
> following the program flow through the code above.  Using print
> statements, the first place that I can see the child running is at
> line 13.  I had thought that the child would start over at the top,
> but it never hits the print statement at line 3.  How exactly does
> this work?

 From perldoc -f fork:

"Does a fork(2) system call to create a new process running the same
program at the same point. It returns the child pid to the parent
process, 0 to the child process, or undef if the fork is unsuccessful."

The key phrase being "at the same point".  I don't know about your
problem with SunOS.  Not sure why you are using kill.  Maybe wait or
waitpid would be better?
-- 
Bob Walton


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

Date: 12 Jul 2001 23:58:01 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Q about fork and kill
Message-Id: <9ilv4p$t55$1@charity.cs.utexas.edu>

In article <9a95c0dd.0107121634.1e2b376b@posting.google.com>,
gene <usenet@smalltime.com> wrote:
>I'm playing around with fork, following the code in the cookbook:
>
>   1: #!/usr/bin/perl
>   2: 
>   3: print "start: $pid\n";
>   4: 
>   5: FORK: {
>   6: 	if ($pid = fork) {
>   7: 	    print "forking\n";
>   8: 		while (kill 0 => $pid) {
>   9: 			print "still going\n";
>  10: 			sleep(1);
>  11: 		}
>  12: 	} elsif (defined $pid) {
>  13: 	    print "inside child\n";
>  14: 	}
>  15: }
>  16: print "ending: $pid\n";
>
>This works on one machine (Mac OS X), but on another machine (SunOS)
>the kill statement on line 8 never registers that the child is dead.

I believe this example is using the old "kill with signal
zero to test if it exists" trick.  This has never been a
standard feature on all versions of Unix, so it's not
surprising it works on one but not another.  The best
plan, in my opinion, is to just not use that technique.

>Since this is perl, I'm sure there are many ways to do this.  What do
>people recommend?

I recommend using "waitpid" to have the parent either
wait for the child to exit or check whether it has.

>Also, I have a general fork question. I'm having some trouble
>following the program flow through the code above.  Using print
>statements, the first place that I can see the child running is at
>line 13.  I had thought that the child would start over at the top,

No, the child and the parent are pretty much identical in *every*
way, with just a few exceptions.  One is that they have a different
process id.  Another is that the return value from fork() is
different.  But other than that and a few other really minor
things, it is like there was an accident with the transporter on
Star Trek and two copies of your process got beamed back from the
surface of the planet.  Both of them think they're the original,
except there are a few clues as to which one is and isn't.

By the way, the "start over at the top" concept isn't completely
ridiculous.  In addition to fork(), there is the exec() system call.
This takes the current process and loads a different executable in
place of it.  In the past, some systems have combined fork() and
exec() into one step.  That is, if you asked the operating system for
a new process, you had to give it an executable to start in that
process.  But that's not the way Unix works, and since Perl is very
Unixy, that's basically not the way it works in Perl either.

  - Logan
-- 
my  your   his  her   our   their   _its_
I'm you're he's she's we're they're _it's_


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

Date: Fri, 13 Jul 2001 06:16:31 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: rand confusion
Message-Id: <3b4e8f0f.61535393@news.grnet.gr>

On Thu, 12 Jul 2001 15:20:08 +0100, Paul Boardman
<peb@bms.umist.ac.uk> wrote:

>Philip Lees wrote:
>
>> What I didn't understand was how the <> operator could be an
>> argument for rand? According to the docs the argument should be a
>> positive number.
>
>for(0..10){
>        print rand <DATA>, "\n";
>}
>
>So you see, you can read in the positive number from a filehandle.

Fair enough. It doesn't seem very DWIMish, though. Wouldn't it be more
usual to write your example like this:

while (<DATA>){
	print rand $_,"\n";
}

Perl is usually so smart I was surprised it got confused by a simple
condition.

Phil
-- 
Philip Lees
ICS-FORTH, Heraklion, Crete, Greece
Ignore coming events if you wish to send me e-mail
'The aim of high technology should be to simplify, not complicate' - Hans Christian von Baeyer


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

Date: 13 Jul 2001 01:46:43 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: rand confusion
Message-Id: <9im5gj$90v$1@charity.cs.utexas.edu>

In article <3b4e8f0f.61535393@news.grnet.gr>,
Philip Lees <pjlees@ics.forthcomingevents.gr> wrote:
>On Thu, 12 Jul 2001 15:20:08 +0100, Paul Boardman
><peb@bms.umist.ac.uk> wrote:
>
>>Philip Lees wrote:
>>
>>> What I didn't understand was how the <> operator could be an
>>> argument for rand? According to the docs the argument should be a
>>> positive number.

>>So you see, you can read in the positive number from a filehandle.

>Perl is usually so smart I was surprised it got confused by a simple
>condition.

It didn't get confused by a simple condition.  It got confused by a
stream of bytes that would make sense either as a simple condition or
as a read from a filehandle being an argument to a function that
happens to be able to take an argument.

I would say "Perl may be smart but it can't resolve fundamental
syntactic ambiguities", but I won't because sometimes Perl can,
or at least sorta can through the use of heuristics.  It does
seem a little obscure to put a special case in for, though.

You can always adopt LISP-ish parentheses placement (as opposed to
formatting) if you want:

	if ( (rand) < 0.5 )
	{
		# whatever
	}

It may not be for everybody, but sometimes putting the parentheses
around the function name and arguments (not just arguments) makes
sense.

  - Logan
-- 
my  your   his  her   our   their   _its_
I'm you're he's she's we're they're _it's_


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

Date: Fri, 13 Jul 2001 08:47:27 +0200
From: "Hans Scholte" <hans@salience.nl>
Subject: script already running
Message-Id: <3b4e99b3$0$996$4d4ebb8e@news.nl.uu.net>

Hi all,

I have a script and i want to know when starting it if it is already running
and then subsequently die.
Does anybody know if there is a way in Perl to check this (on a windows
platform)?

Thanks,

Hans





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

Date: Thu, 12 Jul 2001 18:48:06 -0700
From: Les Ander <citykid@nospam.com>
Subject: searching google
Message-Id: <Pine.LNX.4.33.0107121820200.8056-100000@schewanella.stanford.edu>

hi I am a beginner at perl and wanted some help regarding the following
problem. I would like to write a script that searches google with
the key words i give it at the command lines and the result should be
the urls and titles of the top 10 hits.

thanks




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

Date: 12 Jul 2001 20:52:41 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: searching google
Message-Id: <87pub561ee.fsf@limey.hpcc.uh.edu>

>> On Thu, 12 Jul 2001 18:48:06 -0700,
>> Les Ander <citykid@nospam.com> said:

> hi I am a beginner at perl and wanted some help
> regarding the following problem. I would like to write a
> script that searches google with the key words i give it
> at the command lines and the result should be the urls
> and titles of the top 10 hits.

These 2 should point you in the right direction:

    perldoc lwpcook
    perldoc HTML::Parser

hth
t
-- 
Beep beep!  Out of my way, I'm a motorist!


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

Date: 12 Jul 2001 19:39:49 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: searching google
Message-Id: <m1ae297dsa.fsf@halfdome.holdit.com>

>>>>> "Tony" == Tony Curtis <tony_curtis32@yahoo.com> writes:

>>> On Thu, 12 Jul 2001 18:48:06 -0700,
>>> Les Ander <citykid@nospam.com> said:

>> hi I am a beginner at perl and wanted some help
>> regarding the following problem. I would like to write a
>> script that searches google with the key words i give it
>> at the command lines and the result should be the urls
>> and titles of the top 10 hits.

Tony> These 2 should point you in the right direction:

Tony>     perldoc lwpcook
Tony>     perldoc HTML::Parser

And this is even closer in the right direction:

        perldoc WWW::Search::Google

You might need to visit the CPAN for it, but it's worth it.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Fri, 13 Jul 2001 03:52:31 GMT
From: Akira Yamanita <ayamanita.nospam@bigfoot.com>
Subject: Re: sendmail limitations?
Message-Id: <3B4E7076.43DBD3CD@bigfoot.com>

Mike Ragsdale wrote:
> 
> > >    open(MAIL,"|$mailprog -t");            # When this section
> > >    print MAIL "To: $row[0]\n";            # is commented out,
> > >    print MAIL "From: *******\n";          # the script finishes
> > >    print MAIL "Subject: $emailsubj\n";    # and gives me a total
> >                                     ^^^
> > Headers not terminated.  You need a blank line.
> 
> Again, this does not affect the emails.  The subject exists and the body
> exists.  The emails are going out.  Just not all of them.

Sendmail happens to be forgiving but it should be there anyway.

> > >    print MAIL "Dear $row[1],\n\n";        # of 7674 recipients
> > >    print MAIL "$emailtext\n";             # without the comments
> >
> > *Always* check the success of open() and close() (the
> > latter especially when dealing with pipes).
> 
> Yes, I noticed that when I was copying this excerpt and have added
> "....or die....." to them.  But, this does not fix nor address the
> problem of the limitations.  Any ideas for that?

Maybe you should try putting a period on the last line by itself
so sendmail closes itself properly. Just a guess.


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

Date: 12 Jul 2001 18:50:54 -0700
From: doug.hendricks@tnzi.com (the_rev_dharma_roadkill)
Subject: Successful compile of Perl 5.6 on NCR MP-RAS 3.0
Message-Id: <fb91dbec.0107121750.19697759@posting.google.com>

Andy Dougherty and I figured this out a while ago but lately I've been
getting requests from people on how to compile Perl 5.6 on NCR MP-RAS
unix boxes.  Andy and I worked on perl 5.6.0 but I hear that 5.6.1 may
have the same issue.  This is a snip from a letter summarising our
findings.

****begin snip...

After wiping the directory with rm -rf  and restarting, I can now get,
with two minor edits, within one single test of total victory, which
may be good enough for me.

I set LD_LIBRARY_PATH but this may not be required.

My (almost) winning sequence is:

untar the stuff
edit ext/POSIX/Makefile.PL to add -lmw to end of lib list
(there appears to be no Configure option to do this)
 ./Configure -de
edit config.sh to change optimize='-O' to optimize='-g'
I do it this way to keep -DDEBUGGING out of the picture.
 ./Configure -S
make depend
make
make test

and the only error is:

lib/bigfltpm.........FAILED at test 351 

which I'll have a quick look at but don't really care about.

******end of snip

lib/bigfltpm is for "big floats" which most people don't use.

The problem appears to be a bug in the NCR C/C++ compiler.

Good luck, and best wishes from beautiful New Zealand.

The Reverend Dharma Roadkill
"That does it.  I'm waking up."  -- Buffy


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

Date: Fri, 13 Jul 2001 06:25:55 +0200
From: Philip Newton <pne-news-20010713@newton.digitalspace.net>
Subject: Re: Using a variable in a regular expression
Message-Id: <55tskt4pag0tupfuhsits7tk77me6ejhjp@4ax.com>

On Thu, 12 Jul 2001 14:58:30 -0400, tadmc@augustmail.com (Tad McClellan)
wrote:

> gnari <gnarinn@hotmail.com> wrote:
> 
> >  $pskformat = "(\\d\\d[A-Z][A-Z]\\d\\d\\d\\d\)" ;
> 
> Yuck!
> 
>    $pskformat = '(\d\d[A-Z][A-Z]\d\d\d\d\)' ;

Or

    $pskformat = qr/(\d\d[A-Z][A-Z]\d\d\d\d\)/ ;
    if ( $psk =~ /$pskformat/ ) { ... }

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Fri, 13 Jul 2001 13:49:00 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Very good regex question?
Message-Id: <nzu37.4$Fn4.566@vic.nntp.telstra.net>

"Philip Lees" <pjlees@ics.forthcomingevents.gr> wrote in message
news:3b4d3f0d.62346098@news.grnet.gr...
> On Wed, 11 Jul 2001 16:52:55 +0930, "Wyzelli" <wyzelli@yahoo.com>
> wrote:
>
> >s/'((\w')?[\w]+)('s)?'/$1/;
>
> This and your other one liner both convert 'doesn't' to doesnt'. Also,
> I'm assuming that the OP only wanted to trim a trailing 's, not '\w.

Since "doesn't " isn't a possessive, I wouldn't be too concerned.  In this
case "doesn't" is bad data, and my regex merely modifies possesives (as per
the spec).

Still, it is always good to think outside the box for other potential traps,
because as soon as you make something foolproof, along comes a better fool.

> The following works for all the OP's examples, without having the
> 'doesn't' problem:
>
> my @strings = qw( foobar foobar's 'foobar's' O'Reilly O'Reilly's
> 'O'Reilly' 'O'Reilly's' doesn't 'doesn't' );
>
> foreach ( @strings ){
> s/^'*(.+?)'*s*'*$/$1/;
> print "$_\n";
> }

Wyzelli
--
@x='074117115116032097110111116104101114032080101114108032104097099107101114
'=~/(...)/g;
print chr for @x;




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

Date: 13 Jul 2001 00:02:17 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Very good regex question?
Message-Id: <9ilvcp$88$1@charity.cs.utexas.edu>

In article <nzu37.4$Fn4.566@vic.nntp.telstra.net>,
Wyzelli <wyzelli@yahoo.com> wrote:
>"Philip Lees" <pjlees@ics.forthcomingevents.gr> wrote in message
>news:3b4d3f0d.62346098@news.grnet.gr...
>> On Wed, 11 Jul 2001 16:52:55 +0930, "Wyzelli" <wyzelli@yahoo.com>
>> wrote:
>>
>> >s/'((\w')?[\w]+)('s)?'/$1/;
>>
>> This and your other one liner both convert 'doesn't' to doesnt'. Also,
>> I'm assuming that the OP only wanted to trim a trailing 's, not '\w.
>
>Since "doesn't " isn't a possessive, I wouldn't be too concerned.  In this
>case "doesn't" is bad data, and my regex merely modifies possesives (as per
>the spec).

Not exactly.  "it's" is a contraction (and never a posessive), and your
regular expression would change "'it's'" to "it".

Good sigmonster.  Oh wait, that's not a sigmonster, it's always that
way.

  - Logan
-- 
my  your   his  her   our   their   _its_
I'm you're he's she's we're they're _it's_


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

Date: Fri, 13 Jul 2001 14:46:13 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Very good regex question?
Message-Id: <%ov37.5$Fn4.321@vic.nntp.telstra.net>

"Logan Shaw" <logan@cs.utexas.edu> wrote in message
news:9ilvcp$88$1@charity.cs.utexas.edu...
> In article <nzu37.4$Fn4.566@vic.nntp.telstra.net>,
> Wyzelli <wyzelli@yahoo.com> wrote:
> >
> >Since "doesn't " isn't a possessive, I wouldn't be too concerned.  In
this
> >case "doesn't" is bad data, and my regex merely modifies possesives (as
per
> >the spec).
>
> Not exactly.  "it's" is a contraction (and never a posessive), and your
> regular expression would change "'it's'" to "it".

My point is that I was only interested in posessives, because the OP
specified posessives, ie the list of strings for conversion is a list of
names. it's, doesn't, can't etc are not names and therefore not posessives,
and should not be in the expected data.  However, please note my other
comments about 'better fools' by which I was implying that is is not wise to
assume that you will never get a 'non-name' in the data presented to that
regex.
>
> Good sigmonster.  Oh wait, that's not a sigmonster, it's always that
> way.

que?

Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass it
around');
$d='$_$a$s$b$w';$e='$_$a$s$b';sub d{$h=shift;$h=~s/\$(\w+)/${$1}/g;return$h}
sub
e{return(shift!=1)?'s':''}for(reverse(1..100)){$s=e($_);$f=d($d);$g=d($e);
$c.="$f\n$g\n$t\n";$_--;$s=e($_);$e=d($d);$c.="$e\n\n";}print"$c*hic*";





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

Date: Fri, 13 Jul 2001 05:12:08 +0100
From: "Alan" <gaultalan@hotmail.com>
Subject: what use is the folder
Message-Id: <ewu37.24630$WS4.3716007@news6-win.server.ntlworld.com>

i am new to perl.My web host has given me 3 folders
the root folder and cgi-bin folder and a folder called bin.

The root and cgi-bin i can see the point of.

The bin folder with permissions of 111 i cant see no use for probably cus im
new to this-Can somebody shed some light on this for me.
Should i just delete the thing?




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

Date: Fri, 13 Jul 2001 14:23:43 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: what use is the folder
Message-Id: <Tuu37.235$a04.1065@newsfeeds.bigpond.com>

"Alan" <gaultalan@hotmail.com> wrote in message
news:ewu37.24630$WS4.3716007@news6-win.server.ntlworld.com...
> i am new to perl.My web host has given me 3 folders
> the root folder and cgi-bin folder and a folder called bin.
>
> The root and cgi-bin i can see the point of.
>
> The bin folder with permissions of 111 i cant see no use for probably cus
im
> new to this-Can somebody shed some light on this for me.
> Should i just delete the thing?
>
Hello Alan.

Your cgi-bin is obviously for cgi programs for the web.
The bin is probably for your own private programming. I suspect you can
delete it without any ill effects.

Now start Perl programming!

G. Toomey




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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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.

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 V10 Issue 1296
***************************************


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