[24896] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7148 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 16 18:06:43 2004

Date: Thu, 16 Sep 2004 15:05:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 16 Sep 2004     Volume: 10 Number: 7148

Today's topics:
    Re: $| (undocumented) magic? <bik.mido@tiscalinet.it>
    Re: $| (undocumented) magic? <bik.mido@tiscalinet.it>
    Re: $| (undocumented) magic? <bik.mido@tiscalinet.it>
    Re: $| (undocumented) magic? <bik.mido@tiscalinet.it>
    Re: $| (undocumented) magic? <emschwar@pobox.com>
        Can you break Google's secret? <adsense@whitehouse.com>
    Re: Closures with $_? <bik.mido@tiscalinet.it>
    Re: Help: joining 5 LARGE text files <Joe.Smith@inwap.com>
        http directive to exec perl develop@gistenson.com
    Re: http directive to exec perl <gifford@umich.edu>
    Re: http directive to exec perl <1usa@llenroc.ude.invalid>
    Re: http directive to exec perl <flavell@ph.gla.ac.uk>
    Re: hv_iterinit has side effects - who cares about PL t ctcgag@hotmail.com
    Re: hv_iterinit has side effects - who cares about PL t <joe+usenet@sunstarsys.com>
        installing perl modules and ports (W i l l)
    Re: installing perl modules and ports (Conrad J. Sabatier)
    Re: Is my algorithm wrong? <dwall@fastmail.fm>
    Re: Is my algorithm wrong? <adsense@whitehouse.com>
    Re: Is my algorithm wrong? <bik.mido@tiscalinet.it>
    Re: killing a "nobody's" process and its group <lawshouse.public@btconnect.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 16 Sep 2004 20:20:21 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: $| (undocumented) magic?
Message-Id: <d69hk012241tnegd47ku542s9c9642ogbk@4ax.com>

On 15 Sep 2004 08:08:47 -0700, jl_post@hotmail.com (J. Romano) wrote:

>   I'm not sure if your reply was meant to be taken as sarcasm, but
>either way... good for you!  It's always good to learn something new

Wasn't it clear enough? ;-)
No offence intended, of course!


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 16 Sep 2004 20:20:22 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: $| (undocumented) magic?
Message-Id: <kpbhk0pm4jc94a69d1i4rcij6jj8ginggs@4ax.com>

On Wed, 15 Sep 2004 16:25:05 GMT, Ala Qumsieh <notvalid@email.com>
wrote:

>No, but that doesn't mean that JAPHs and golf promote "bad" habits 
>(whatever the definition of "bad" might be). I have never spent too much 
>time on JAPHs, but have done so on perlgolf (over at perlgolf.org during 
>its earlier days). And, I must admit, I learnt lots of useful techniques 
>and discovered a lot of interesting properties of Perl's built-in vars 
>in the process of squeezing just one more character out of my code. As a 

Indeed! Personally I'm only a mediocre golfer, but I have an IMHO
enlightening example: in a contest at terje the goal was a program
that given any input string would output the *smallest* palindrome
obtained extending that string either on the left or on the right.

(I must say that I have tried my own hand at that contest, when
closed, and taking much time: had I actually took part to it I would
have classified at 4th place IIRC. The point is, anyway, that I chose
an approach similar to that of most other ones.)

The actual winner instead had taken a completely different path, and
as a result he did win not for a hole or two, but for something like
30 or more! Basically he was |'ing the given string with a reverse()d
copy of it "shifted left or right" an increasing amount of chars until
it matched the original string.

I remember I was amazed when I saw *that* solution: the algorithm was
conceptually the most simple of all. Then he did other "awful" things
in order to squeeze the very last byte off his script, like using
symrefs (and in a possibly obscure way!) et similia. Of course one
shouldn't/wouldn't do such things in "production code", but if for any
reason he had to realize that particular task, then an excellent
technique could be the one described above.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 16 Sep 2004 23:26:32 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: $| (undocumented) magic?
Message-Id: <ecvjk09um3jll6gi82pmnug1qegeuo2q23@4ax.com>

On 16 Sep 2004 09:16:49 -0700, krakle@visto.com (krakle) wrote:

>> > They're just jealous because they can't write any valid Python program 
                                                             ^^^^^^
                                                             ^^^^^^

>> > in just four lines (/me ducks and runs for cover).
>> Well we can't write _any_ valid program in four lines
>
>#!/usr/bin/perl -w
>print "What's your name?";
>my $name = <STDIN>;
>print "Hi $name I just wanted to show you a valid Perl program in 4
>lines. Isnt this valid?\n";

It seems you don't waste your time with JAPHs, because you only spend
your efforts in "productive code", but just at the same time this must
have caused you some comprehension problems e.g. with understanding
what the OP was talking about, i.e. *Python* programs, not *Perl*.

Oh, and BTW, since you only spend your time on "productive code", then
you surely know that (i) -w is somewhat obsolete since C<use warnings>
provides the same functionality in a better and more controlled way,
(ii) it is a bad habit to include literal newlines in strings unless
when writing a japh or when golfing, which is not your case, since you
don't do those things. Also (iii) it may be a deliberate choice, but
wouldn't it be better to chomp($name)?

I'd just write:


  #!/usr/bin/perl -l
  
  use strict;
  use warnings;
  
  print "What's your name?";
  chomp(my $name = <>);
  print <<"EOT";
  Hi $name I just wanted to show you a valid Perl program in 4
  lines. Isn't this valid?
  EOT
  
  __END__


Oh, but I was forgetting... you wanted to exhibit a valid program in 4
lines! I'm an idiot!! But then not only there are many *valid*
programs even in one line (and useful too!), but there is even *one*
(and there couldn't be more!) *valid* program in zero lines:

  # perl -e ''

And you know what? It' even warnings- and strict-safe:

  # perl -wMstrict -e ''


HTH,
Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 16 Sep 2004 23:26:34 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: $| (undocumented) magic?
Message-Id: <fksjk0pj0srub50a23gao5kemdekse1e4m@4ax.com>

On 16 Sep 2004 09:10:40 -0700, krakle@visto.com (krakle) wrote:

>> Fun?!? Fun, Fun and more Fun?
>
>If that's your idea of a fun time I feel bad for your
>wife/husband/girlfriend/children/friends/co-workers...

Well, I know it's hard to believe, but surprising as it may be, you'll
find that I do *not* spend all my time writing JAPHs, let alone most
of it or even a considerable part of it. And I don't think I've said
so, but if I have...


Michele


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

Date: Thu, 16 Sep 2004 15:47:54 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: $| (undocumented) magic?
Message-Id: <etooek5ga2d.fsf@wilson.emschwar>

Michele Dondi <bik.mido@tiscalinet.it> writes:
> It seems you don't waste your time with JAPHs, because you only spend
> your efforts in "productive code", but just at the same time this must
> have caused you some comprehension problems e.g. with understanding
> what the OP was talking about, i.e. *Python* programs, not *Perl*.

I believe the OP was simply pointing out that you can only write
*some* programs in four lines; you can't write *any* program in 4
lines, because some won't fit.

Of course, Perl and Ruby (and I think Python, though I'm not sure) let
you put multiple statements on a line, so I suppose technically you
could just join(';', split(/\n/, <FILE>)) and call that a 'line'. :)

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Thu, 16 Sep 2004 20:03:35 GMT
From: "Looking" <adsense@whitehouse.com>
Subject: Can you break Google's secret?
Message-Id: <rkm2d.3071$RTE1.746@news01.bloor.is.net.cable.rogers.com>

The most successful search engine's secret algorithm can be calculated from
a sandbox/blackbox detection. Assuming we already know the secret, can you
write the code with it?

Case 1, especially for news.google.com, Google compares two documents in
stripped text format, and see how much of them in common. If they share 90%
similar things, then they are talking about the same thing.

here is the algorithm A, break down each document into key phrases and
keywords, ignore the most common ones, then compare the array of keywords
from both documents.
algorithm B is simpler, compare two documents as whole. Currently I am
trying to study how to complete the algorithm and codes for B.

For B, here is a test case, can you write a perl code for that? Just
comparing two strings, rather than long documents. Sudocodes are welcomed
too. Here is the sample input string.



      Yahoo spends $160m to take on iTunes and co
      VNUNet.com, UK - 6 hours ago
      Yahoo is buying music software and services company Musicmatch for
$160m in cash as it prepares to make a splash in the digital music arena.
 ...

      Yahoo to buy Musicmatch for $160 million
      CNET News.com, United States - 18 hours ago
      Yahoo said Tuesday that it is acquiring digital music specialist
Musicmatch for $160 million in cash. The Sunnyvale, Calif.-based ...

      Yahoo Pays $160 Million for Online Music Store
      NPR (audio) - Sep 15, 2004
      Description: Yahoo joins the online music market by agreeing to buy
Musicmatch for $160 million. Analysts say Yahoo needs the deal ...

      Yahoo! Tunes In to Musicmatch
      Motley Fool - Sep 15, 2004
      By Dave Marino-Nachison September 15, 2004. Close watchers of the
online music business no doubt noted yesterday's announcement of ...

      Yahoo Plans to Purchase Online Music Seller
      NPR (audio) - Sep 15, 2004
      Description: Yahoo has agreed to buy the online music provider
Musicmatch for $160 million. Yahoo hopes to cash in on the expanding ...

      Yahoo to enter music fray
      San Francisco Chronicle, CA - Sep 15, 2004
      Yahoo Inc. became the latest technology titan to jump into the
Internet music market Tuesday with a $160 million deal to buy pioneering ...

      YAHOO: $160 million deal to add Musicmatch
      Chicago Tribune (subscription), IL - Sep 15, 2004
      SAN FRANCISCO -- Yahoo Inc. is buying online jukebox provider
Musicmatch Inc. for $160 million in a deal intended to broaden the ...

      Yahoo buying Musicmatch to expand in digital music
      Chicago Sun Times, IL - Sep 15, 2004
      BY MICHAEL LIEDTKE. SAN FRANCISCO -- Yahoo is buying online jukebox
provider Musicmatch for $160 million in a deal designed to broaden ...

      Yahoo boosts music portal
      San Jose Mercury News (subscription), CA - Sep 15, 2004
      By Dawn C. Chmielewski. Yahoo, seeking to add e-commerce to its
Internet music portal, will pay $160 million in cash to acquire Musicmatch
 ...

      Yahoo moves in on music scene
      News24 (subscription), South Africa - Sep 15, 2004
      San Francisco - Yahoo is buying online jukebox provider Musicmatch Inc
for $160m in a deal designed to broaden the internet giant's appeal with the
growing ...

     Yahoo! buys SD pioneer Musicmatch
      San Diego Union Tribune, CA - Sep 15, 2004
      By Kathryn Balint. Musicmatch, the San Diego online music pioneer that
was started in the homes of its three founders, was sold for ...

      Yahoo banks on digital music
      Miami Herald (subscription), FL - Sep 15, 2004
      Yahoo's $160 million purchase of Musicmatch will give the Internet
company an online music store and a software program that manages digital
music. ...

      Yahoo to Buy Online Jukebox Musicmatch
      Los Angeles Times (subscription), CA - Sep 15, 2004
      Yahoo Inc. agreed to buy online jukebox provider Musicmatch Inc. of
San Diego for $160 million in a deal designed to broaden the ...

      Yahoo! to acquire Musicmatch for USD 160 mln
      Telecom Paper (subscription), Netherlands - Sep 15, 2004
      Yahoo! and Musicmatch, a provider of personalized music software and
services, have signed a definitive agreement under which Yahoo! ...

      Portal eager to get in market for downloads
      Houston Chronicle, TX - Sep 14, 2004
      By MICHAEL LIEDTKE. SAN FRANCISCO - Yahoo is buying online jukebox
provider Musicmatch for $160 million in a deal designed to broaden ...

      Yahoo! and Musicmatch: A Hot Duet?
      BusinessWeek - Sep 14, 2004
      The $160 million deal signals that Semel & Co. will mount the biggest
challenge yet to Apple's dominance of online music. Since grabbing ...

      Yahoo! finds its MusicMatch: $160M purchase puts song in its heart
      Boston Herald, United States - Sep 14, 2004
      By Greg Gatlin. Yahoo! Inc. put its headphones on yesterday and danced
into the middle of a crowded music download arena with a $160 ...

      Yahoo to Buy Online Music Seller for $160 Million
      New York Times, NY - Sep 14, 2004
      By SAUL HANSELL. na move to expand its role in the online music
business, Yahoo announced yesterday that it would buy Musicmatch, a ...

      Yahoo Inc. makes a Musicmatch
      Minneapolis Star Tribune (subscription), MN - Sep 14, 2004
      In yet another sign that online music is a business with big
potential, Internet portal Yahoo Inc. has agreed to acquire online music
seller Musicmatch Inc. ...

      Yahoo enters the online music mix
      Red Herring - Sep 14, 2004
      The battle for online music audiences gained yet another heavyweight
competitor on Tuesday, as Internet giant Yahoo announced its acquisition of
MusicMatch, a ...

      Yahoo! expands in online music
      Guardian, UK - Sep 14, 2004
      Yahoo! yesterday became the latest big name to make its presence felt
in the burgeoning market for online music. The internet portal ...

      Yahoo buys online music outfit for US$160m
      Straits Times, Singapore - Sep 14, 2004
      SAN FRANCISCO - Yahoo is buying online jukebox provider Musicmatch for
US$160 million (S$271.55 million) in a deal designed to broaden the Internet
giant's ...

      Yahoo to buy Musicmatch
      Stuff.co.nz, New Zealand - Sep 14, 2004
      NEW YORK: Internet company Yahoo says it will buy privately held music
software company Musicmatch for about $US160 million in a bid to bolster its
online ...

      Tech Brief: Yahoo puts money into jukebox
      International Herald Tribune, France - Sep 14, 2004
      Yahoo is buying the online jukebox provider Musicmatch for $160
million in a deal designed to broaden the Internet giant's appeal to the
growing audience of ...

      Internet stocks nudge techs higher
      CNN/Money - Sep 14, 2004
      Yahoo! jumps into the music download biz while Ask Jeeves, Amazon
soar; Oracle beats after the bell. NEW YORK (CNN/Money) - Bucking ...

      Yahoo to Buy Musicmatch Web Service for $160 Million (Update6)
      Bloomberg - Sep 14, 2004
      Sept. 14 (Bloomberg) -- Yahoo! Inc., owner of the world's most-visited
Internet site, will buy Musicmatch Inc. for $160 million ...

      Yahoo to Buy Musicmatch for $160 Million
      ABC News, United States - Sep 14, 2004
      NEW YORK (Reuters) - Yahoo Inc. said on Tuesday it will buy music
software company Musicmatch Inc. for about $160 million in cash ...

      Yahoo to Buy Musicmatch for $160 Million
      ABC News, United States - Sep 14, 2004
      Sept. 14, 2004 ¡ª NEW YORK (Reuters) - Yahoo Inc. said on Tuesday it
will buy music software company Musicmatch Inc. for about ...

      Yahoo's long and winding music road
      ZDNet.com - Sep 14, 2004
      This fourth priority's main focus has been improving or obtaining CRM
and ERP software for the past year and a half. With Tuesday's ...

      Yahoo Plans To Acquire Musicmatch
      InternetWeek.com - Sep 14, 2004
      By Antone Gonsalves, TechWeb News. Yahoo Inc. on Tuesday said it has
agreed to acquire Musicmatch Inc. for about $160 million in ...






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

Date: Thu, 16 Sep 2004 23:26:35 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Closures with $_?
Message-Id: <fqsjk0h8gdpdekjm863nj3lieg06vhturn@4ax.com>

On 15 Sep 2004 20:31:18 GMT, ctcgag@hotmail.com wrote:

>>   # perl -le 'print map $_->(), map { sub { $_ } } qw/f o o/'
>>   CODE(0x8137f84)CODE(0x8137f84)CODE(0x8137f84)
>>
>> BTW: OTOH I do *not* understand *how* exactly it fails to work, i.e.
>> what I actually get.
>
>at the time of the outer map, $_ contains a code ref to a subroutine
>which returns $_.  So $_->() just returns the value of $_,
>which of course is a code ref and stringifies to look like that.

OK!!

>> Data::Dumper on
>>
>>   map { sub { $_ } } ...
>>
>> gives me
>>
>>   $VAR1 = sub { "DUMMY" };
>>   $VAR2 = $VAR1;
>>   $VAR3 = $VAR1;
>>
>> As a side note indeed this is *not* WIM...
>
>What about it is not what you meant?  The "DUMMY" thing is just
>there as an artifact of Data::Dumper (perldoc Data::Dumper, search

I *do* know that.

Sorry, I reread my post and I realize that definitely I wasn't clear.
More precisely I could have avoided this thing with Data::Dumper at
all: I was just trying to say in yet another way that it seems logical
to me one could expect three anonymous subs each represented by a line
like the first one above.

>>   map { my $t=$_; sub { $t } } qw/f o o/
>>
>> instead does exactly what I want, again as of the documentation.
>
>Did you run Data::Dumper on that as well?

You bet I did!

>> So I wonder wether, apart possible technical difficulties, there are
>> other issues against the possibility of having closures using $_.
>
>I don't understand what you include in "possible technical difficulties",
>and therefore don't know what issues there are other than the ones you
>already include.

I have not included any technical difficulty, just *evidence* that
closures are supported only as far as lexical variables are concerned.
But I don't know why, because I don't know perl internals. So in
"possible technical difficulties" I include *any* reason p5p's may
give for e.g.

  map { sub { $_ } } qw/f o o/;

not being equivalent to (the clumsier)

  map { my $t=$_; sub { $t } } qw/f o o/;


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 16 Sep 2004 20:06:01 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Help: joining 5 LARGE text files
Message-Id: <Jmm2d.202485$mD.181740@attbi_s02>

Chris Cole wrote:

> I don't understand why you've posted this here as this isn't a perl problem!

It is a Perl problem if the perl in question was not compiled with the right
flags.  This is what the compile-time flags should look like:

linux% perl -V | grep -i large
     useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
     cc='cc', ccflags ='-fno-strict-aliasing -I/usr/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
     cppflags='-fno-strict-aliasing -I/usr/include -I/usr/include/gdbm
-fno-strict-aliasing -I/usr/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
-I/usr/include/gdbm'
   Compile-time options: USE_LARGE_FILES

freebsd% perl -V | grep -i large
     useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
   Compile-time options: USE_LARGE_FILES

solaris% perl -V | grep -i large
     useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
     cc='gcc -B/usr/ccs/bin/', ccflags ='-fno-strict-aliasing
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
   Compile-time options: USE_LARGE_FILES




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

Date: Thu, 16 Sep 2004 19:02:45 +0000 (UTC)
From: develop@gistenson.com
Subject: http directive to exec perl
Message-Id: <cico0l$3h8$2@new7.xnet.com>

Hi,

At the beginning of each perl cgi script is the #! line. I'm assuming that 
this is an http directive that executes perl and indicates thedirectory in 
which perl is found.

I'm developing scripts for a client. The problem is that he is using a 
different web host than I am, and perl is found in different directories, 
so I need to use different #! directives at the beginning of the scripts.

I don't want to have to change the scripts when I move them from my host 
to the client's host. Is there a '#if' '#else' type of directive pair, and 
if there is, what is the syntax and what test could I use to have the 
script know whether it's running on my host or the client's host? 
(Possibly the environment, $ENV{'???'}.)

Is there another way to accomplish this?

Thanks,
Dan



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

Date: Thu, 16 Sep 2004 15:22:36 -0400
From: Scott W Gifford <gifford@umich.edu>
Subject: Re: http directive to exec perl
Message-Id: <qszllfahvcz.fsf@timepilot.gpcc.itd.umich.edu>

develop@gistenson.com writes:

> At the beginning of each perl cgi script is the #! line. I'm
> assuming that this is an http directive that executes perl and
> indicates thedirectory in which perl is found.

It's a directive to the underlying operating system.

> I'm developing scripts for a client. The problem is that he is using
> a different web host than I am, and perl is found in different
> directories, so I need to use different #! directives at the
> beginning of the scripts.

Can you just make a symlink on one server or the other, so there's
some path that will work on both?

If not, there's some tricks in the perlrun(1) manpage that may help:

     Parsing of the #! switches starts wherever "perl" is
     mentioned in the line.  The sequences "-*" and "- " are
     specifically ignored so that you could, if you were so
     inclined, say
 
         #!/bin/sh -- # -*- perl -*- -p
         eval 'exec perl -wS $0 ${1+"$@"}'
             if $running_under_some_shell;
 
     to let Perl see the -p switch.
 
     A similar trick involves the env program, if you have it.
 
         #!/usr/bin/env perl

Another possibility is to simply use another Perl script to
automatically fix the "shebang" line.

----ScottG.


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

Date: 16 Sep 2004 19:31:39 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: http directive to exec perl
Message-Id: <Xns95669DF434AB9asu1cornelledu@132.236.56.8>

develop@gistenson.com wrote in news:cico0l$3h8$2@new7.xnet.com:

> Hi,
> 
> At the beginning of each perl cgi script is the #! line. I'm assuming

Why assume? Any introductory resource on Perl explains what that line 
does. 

> that this is an http directive that executes perl 

No, it does not have anything to do with HTTP.

> I'm developing scripts for a client. The problem is that he is using a
> different web host than I am, and perl is found in different
> directories, so I need to use different #! directives at the beginning
> of the scripts. 
> 
> I don't want to have to change the scripts when I move them from my
> host to the client's host. Is there a '#if' '#else' type of directive
> pair, and if there is, what is the syntax and what test could I use to
> have the script know whether it's running on my host or the client's
> host? (Possibly the environment, $ENV{'???'}.)
> 
> Is there another way to accomplish this?

* Write an install script that actually writes the correct path to Perl 
in each script as part of the installation process.

* Modify your web server's configuration so as to use a specific 
interpreter rather than the one specified in the script.

This is all OS and server software specific, you might want to try a more 
relevant group.

Sinan


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

Date: Thu, 16 Sep 2004 21:32:50 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: http directive to exec perl
Message-Id: <Pine.LNX.4.61.0409162131030.9219@ppepc56.ph.gla.ac.uk>

On Thu, 16 Sep 2004, Scott W Gifford wrote:

> develop@gistenson.com writes:
> 
> > At the beginning of each perl cgi script is the #! line. I'm
> > assuming that this is an http directive that executes perl and
> > indicates thedirectory in which perl is found.
> 
> It's a directive to the underlying operating system.

Usually, yes.  But in the case of Windows Apache, the underlying OS 
wouldn't know the shebang line from a hole in the ground. So I 
think we might need a bit more context.

cheers


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

Date: 16 Sep 2004 18:08:39 GMT
From: ctcgag@hotmail.com
Subject: Re: hv_iterinit has side effects - who cares about PL theory
Message-Id: <20040916140839.955$ug@newsreader.com>

ozgune@gmail.com (Ozgun Erdogan) wrote:
> > In my book, things that "are supposed to do reads" generally don't end
> > in "init".
> >
> > Xho
>
> Thanks for backing me up Xho. That's what I was trying to say the
> whole thread. If I want to do a hash read from the beginning, why
> would I need to call init (change) the hash structure, right? Take
> init out of the picture in T1/T2, and you'd get completely
> non-deterministic behavior.

I didn't know I was backing you up!  It doesn't sound like you want to do
a simple hash read, it sounds like you want to do a hash iteration, which
is different.  It seems to me that you are insisting a hash iteration is
(or should be) a simple read, but obviously it is no such thing.  (As
evidenced by the fact that you need to call init in your pseudocode).

If you say "I want an iterator separate from the hash itself", well, I
can't disagree with that.  You want what you want.  Maybe you want to use
some other language.  That's also fine.  But you seem to be saying
"Everyone else should want that too."  Well, we don't.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: 16 Sep 2004 14:16:37 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: hv_iterinit has side effects - who cares about PL theory
Message-Id: <87vfee6pve.fsf@gemini.sunstarsys.com>

ozgune@gmail.com (Ozgun Erdogan) writes:

> If I want to do a hash read from the beginning, 
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*Boggle*

> Take init out of the picture in T1/T2, and you'd get completely
> non-deterministic behavior.

perl isn't threaded, so the relevance of T1/T2 escapes me.
Have you considered rewriting whatever it is you're doing 
around a breadth-first search instead of a depth-first one?

-- 
Joe Schaefer


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

Date: 16 Sep 2004 11:36:00 -0700
From: willis3140@yahoo.com (W i l l)
Subject: installing perl modules and ports
Message-Id: <c41c66e9.0409161036.e8c6d56@posting.google.com>

I installed some perl modules via CPANPLUS. Now whenever I install
anything via ports (or "pkg_add -r anything") I get warnings that look
like:

pkg_info: package bsdpan-CPANPLUS-0.049 has no origin recorded
pkg_info: package bsdpan-Date-Manip-5.42 has no origin recorded
pkg_info: package bsdpan-HTML-Parser-3.36 has no origin recorded
pkg_info: package bsdpan-HTML-Tagset-3.03 has no origin recorded
 ...

And ofcourse the list goes on and on -- at least for ever module I
installed outside of the portage system.

I even tried installing some modules via the portage system that I'd
already installed manually ( or by CPANPLUS ) and I still get the list
of errors ( as above ) when I install anything from "pkg_add -r xxx"
or "make install" from the /usr/ports dir.

ANY IDEAS?  TIA!

(-WW)

This message was posted in the following groups:
comp.unix.bsd.freebsd.misc
comp.lang.perl.modules
comp.lang.perl.misc


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

Date: Thu, 16 Sep 2004 20:10:46 GMT
From: conrads@cox.net (Conrad J. Sabatier)
Subject: Re: installing perl modules and ports
Message-Id: <arm2d.52378$wu.26675@okepread04>

In article <c41c66e9.0409161036.e8c6d56@posting.google.com>,
W i l l <willis3140@yahoo.com> wrote:
>
>
>I installed some perl modules via CPANPLUS. Now whenever I install
>anything via ports (or "pkg_add -r anything") I get warnings that look
>like:
>
>pkg_info: package bsdpan-CPANPLUS-0.049 has no origin recorded
>pkg_info: package bsdpan-Date-Manip-5.42 has no origin recorded
>pkg_info: package bsdpan-HTML-Parser-3.36 has no origin recorded
>pkg_info: package bsdpan-HTML-Tagset-3.03 has no origin recorded
>...
>
>And ofcourse the list goes on and on -- at least for ever module I
>installed outside of the portage system.
                      ^^^^^^^^^^^^^^^^^^

SLAP!!!  Where do you think you are, anyway, comp.os.linux.gentoo?

:-)

-- 
Conrad J. Sabatier <conrads@cox.net> -- "In Unix veritas"


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

Date: Thu, 16 Sep 2004 18:15:38 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: Is my algorithm wrong?
Message-Id: <Xns95669111023CFdkwwashere@216.168.3.30>

[Not a very descriptive Subject.]

Looking <adsense@whitehouse.com> wrote:

> Here is what I am trying to do:
> 
> For a given string, break it into two parts. The first part should
> be as long as possible but less than 25 characters. The SPLIT key
> is a whitespace. The second part is whatever left in the string;
> 
> My algorithm is to break the string to into many small parts the
> join them with space.
> 
> @parts= split (/\W/, $original);

\W means a non-word character, not whitespace. Maybe that's what you 
wanted, but it doesn't match the description above.

[snip rest of program]
 
Quick and dirty:

    my $string = 'something at least twenty-five characters long';
    my ($part1, $part2) = $string =~ /^(.{1,23}\S)\s(.*)/s;

Ideally you should check to see if the match succeeded.

I do hope this isn't homework.
 


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

Date: Thu, 16 Sep 2004 20:30:59 GMT
From: "Looking" <adsense@whitehouse.com>
Subject: Re: Is my algorithm wrong?
Message-Id: <7Km2d.19883$Q7D.6257@twister01.bloor.is.net.cable.rogers.com>


> Quick and dirty:
>
>     my $string = 'something at least twenty-five characters long';
>     my ($part1, $part2) = $string =~ /^(.{1,23}\S)\s(.*)/s;
>
> Ideally you should check to see if the match succeeded.
>
> I do hope this isn't homework.
>

it is not a homework. it is a feature i am adding to a site.

your works except in the case that there is no space in the first 25.
my codes have problems too.

thundergnat's solution works perfect. this is his
#my $original = 'This is a test string about 46 characters long';
my $original = 'ThisSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS is a test
string about 46 characters long';

my $end = $original;
my $start = substr($end,0,25,''); #cut them into 2
$start =~ s/\s+(\S+)$//; # remove the last none whitespaces following at
least 1 whitespace
$end = $1.$end if defined $1; # add it to the second part




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

Date: Thu, 16 Sep 2004 23:29:32 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Is my algorithm wrong?
Message-Id: <5d1kk0h1hq3949gmh129plvou8th83u3vq@4ax.com>

On Thu, 16 Sep 2004 15:43:20 GMT, in comp.lang.perl.misc you wrote:

>For a given string, break it into two parts. The first part should be as
>long as possible but less than 25 characters. The SPLIT key is a whitespace.
>The second part is whatever left in the string;
>
>My algorithm is to break the string to into many small parts the join them
>with space.

I'm not sure if I understand what you mean, but couldn't something
along these lines suit your needs?


  #!/usr/bin/perl -l
  
  use strict;
  use warnings;
  
  $_='foo bar baz ' x 5;
  
  my $pos;
  while (/ /g) {
      last if pos > 25;
      $pos=pos;
  }
  
  print for unpack 'A' . $pos . 'A*', $_;
  
  __END__


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 16 Sep 2004 21:24:34 +0100
From: Henry Law <lawshouse.public@btconnect.com>
Subject: Re: killing a "nobody's" process and its group
Message-Id: <vrsjk0tf8oeg9gq545seg7n8ibk4qrk740@4ax.com>

On 16 Sep 2004 13:01:13 GMT, "A. Sinan Unur"
<1usa@llenroc.ude.invalid> wrote:

>Henry Law <lawshouse.public@btconnect.com> wrote in
>news:k19dk0tuu9a5mr2m6qv13tedmidarbpotg@4ax.com: 
>

>You misquoted. The OP's original sentence was:

Copied directly from your post.  Our respective newsreaders have
folded the lines in different places.

>long as one sticks with simple structures. IMNSHO, choosing not to write 
>in not in fully formed sentences, dropping vowels, etc, are indicators of 
>lack of respect for the people one expects to receive help from.

This implies that not speaking adequate English is equivalent to
lacking respect for the English-speaking members of the newsgroup.   I
can't believe that's what you mean.   What if the text that the chap
wrote *is* the best he's capable of?   How about if he taught himself
English from reading, cigarette packets, say?   Could be a pretty
impressive achievement and worthy of our respect.   We just don't
know.

In any case we understood enough of what he wrote to work out that
he's asking in the wrong group.   That meets the initial requirement.

>
>> Does your position as an English-speaking über-mensch living in the 
>> land of the free give you the right to put him down like that?
>
>So, you mean, I cannot be an über-mensch unless my native language is 
>English. I am very disappointed. 

No, I didn't say that.  I understand that English is not your native
language (and I acknowledge your achievement in having got almost to
perfection: that is indeed a fine thing to have done).   Your post
suggested to me that you were placing yourself in the "über" position
because you have good command of English; that's not connected with
the way in which you learned it.   Perhaps because of your own
achievement you have less patience with others who haven't reached the
same standard?  I'm glad I'm not posting here in my humdrum German or
rusty French.

>
>> How hard would it have been to write
>> 
>>      "This is not a Perl problem.  Killing processes is done
>>      by the operating system so you should ask in the newsgroup
>>      for the operating system in which Apache is running"
>
>Feel free to write that if that is how you would like to spend your time. 

Same number of words as your post; communicated the same message;
didn't make the OP feel small.  I don't see your point.

>On the other hand, I do not remember the OP mentioning anything about 
>Apache.

Copied from the original post:
>thanks!
>Federico
>(I'm using Mac OsX with apache2 server)

Henry Law       <><     Manchester, England 


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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