[8925] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2544 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 8 19:07:50 1998

Date: Fri, 8 May 98 16:01:43 -0700
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, 8 May 1998     Volume: 8 Number: 2544

Today's topics:
        MODULE MANIA STRIKES (Was Re: What does this do?) <upsetter@shore.net>
        Newbie troubles <jwg@csulb.edu>
    Re: PErl Functions <kenner@xnet.com>
    Re: Perl in background <muinhos@iname.com>
    Re: Perl NT ssShopping cart <sowmaster@juicepigs.com>
    Re: perl scripts dealing with /etc/passwd <due@murray.fordham.edu>
    Re: QRe: == vs. eq (Greg Bacon)
    Re: QRe: == vs. eq (John Moreno)
        Question about regular expression in perl script <gnielson@charlotte.infi.net>
    Re: Question about regular expression in perl script (Greg Bacon)
    Re: Question about regular expression in perl script (Craig Berry)
        tip for Solaris in PERL <steves@wco.com>
    Re: Using split to return a @ without splitting on spac <rootbeer@teleport.com>
        What does this do? (J1T1W1)
    Re: What does this do? <lanier@shell6.ba.best.com>
    Re: What does this do? (Greg Bacon)
    Re: What does this do? (Craig Berry)
    Re: Win95 Perl scripts DONT WORK on UNIX (Ilya Zakharevich)
    Re: Win95 Perl scripts DONT WORK on UNIX <beadles@nortel.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 8 May 1998 22:38:46 GMT
From: Art Cohen <upsetter@shore.net>
Subject: MODULE MANIA STRIKES (Was Re: What does this do?)
Message-Id: <6j01hm$k98@fridge.shore.net>


Greg Bacon <gbacon@cs.uah.edu> wrote:
: :               read(STDIN, $buf, $ENV{'CONTENT_SIZE'});

: It fails to use the CGI.pm module!  Get thee to the CPAN:

:     <URL:http://www.perl.com/CPAN/modules/by-module/CGI/>

Caution: rant ahead!

This is a perfect example of module-mania run amok. There are plenty of
perfectly good reasons why someone might not want to use CGI.pm, yet the
immediate knee-jerk reaction is "Use CGI.pm". If you don't want to tell
him the answer, don't, but don't imply that using CGI.pm will make his
life easier.

Maybe he's a beginning perl programmer, and maybe he doesn't know anything
about modules, references or objects (believe it or not, it's possible to
write working perl code for many different tasks without knowledge of any
of these things). If he needs to write a cgi script, it makes infinitely
more sense to learn cgi (the interface) on its own, based on a simple
knowledge of perl, and then later -- iff he has complicated CGI
programming needs -- learn enough about modules, references and objects to
use CGI.pm. 

Or maybe -- imagine this -- he's been using CGI.pm for a long time, but
now he needs to write a script for a host that's running Perl 4. Not an
ideal situation to be in by any means, but hardly beyond the realm of
possibility. 

Maybe he's just reading the source code of cgi-lib.pl and trying to
analyze it. I've been writing perl for over two years and I've never used
"read" ever, except in cgi-lib.pl, so it's not unreasonable that he's
never seen this function before.

Of course, you might be justified in pointing out that there is plenty of
documentation available to explain how the read function works, and that
it's a little lazy and annoying to post a question like that to this ng
without consulting said documentation first, but to proclaim -- simply on
the basis of one line of code -- that he *should* be using CGI.pm (simply
because it exists) is kind of idiotic. 

End of rant.

--Art

National Ska/Reggae Calendar: www.ziplink.net/~upsetter/ska/calendar.html
        Boston Ska Home Page: www.ziplink.net/~upsetter/ska/index.html



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

Date: Fri, 08 May 1998 15:57:08 -0700
From: Jeff Giacomi <jwg@csulb.edu>
Subject: Newbie troubles
Message-Id: <35538DC4.92412929@csulb.edu>

Help.  I can get hello.pl to run from the command line but when I try to
access through http://servername/scripts/hello.pl I get HTTP/1.0 404
Object Not Found. Any ideas?  Thanks in advance.

-jeff



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

Date: Fri, 8 May 1998 16:52:04 -0500
From: "Kenner Estes" <kenner@xnet.com>
Subject: Re: PErl Functions
Message-Id: <6j01oq$3pa$1@flood.xnet.com>

What is obtuse and what are the arguments to it?




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

Date: Sat, 9 May 1998 00:43:02 +0200
From: "Manuel" <muinhos@iname.com>
Subject: Re: Perl in background
Message-Id: <6j01qj$3lc$1@talia.mad.ibernet.es>

Thanks for the solution. It works very well.
___________________________________________________________________________

Manuel Muiqos Pan
mailto:muinhos@iname.com  http://personal.redestb.es/muinhos/
___________________________________________________________________________

Tom Phoenix escribis en mensaje ...
>On Thu, 7 May 1998, Manuel wrote:
>
>> From a cgi written in Perl I want to send another program written in
>> Perl in background and back the control without hop that the program in
>> background finishes. I probe
>>
>> system ("program &")
>>
>> but it does not return the control to me until it finishes.
>
>That sounds as if your server is waiting until the three standard
>filehandles are closed before it goes on. Try closing them, at least in
>the child process. Hope this helps!
>
>--
>Tom Phoenix       Perl Training and Hacking       Esperanto
>Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
>




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

Date: Fri, 08 May 1998 18:42:18 -0400
From: Bob Trieger <sowmaster@juicepigs.com>
Subject: Re: Perl NT ssShopping cart
Message-Id: <35538A4A.165A@juicepigs.com>

Chris Gurney wrote:
> 
> There are a lot of Unix Shopping carts around..Can someone direct me to a
> script to suit NT.

This can be done using CGI.pm.

-- 
Bob Trieger               |  Titanic: big boat, bigger
sowmaster@juicepigs.com   |           iceberg, big deal


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

Date: 8 May 1998 22:14:45 GMT
From: "Allan M. Due" <due@murray.fordham.edu>
Subject: Re: perl scripts dealing with /etc/passwd
Message-Id: <6j004l$hvr$0@206.165.146.192>

Thanks Tom, I appreciate the additional info.  Off to sort it all out for
myself.

AmD








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

Date: 8 May 1998 21:38:05 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: QRe: == vs. eq
Message-Id: <6ivtvt$ifd$6@info.uah.edu>

In article <1d8psbn.8wyodk10e6mp2N@roxboro0-034.dyn.interpath.net>,
	phenix@interpath.com (John Moreno) writes:
: It doesn't pass (for one
: thing it doesn't always include a References header) but MS has been
: made aware of the results and have said they will address at least some
: of the issues in the next version of Mac OE

So does this mean that they're also aware of how shitty the quoting is
with their toy newsreaders or do they believe it's a feature?

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Fri, 08 May 1998 22:45:42 GMT
From: phenix@interpath.com (John Moreno)
Subject: Re: QRe: == vs. eq
Message-Id: <1d8q3sr.8cccxkclb2ilN@roxboro0-034.dyn.interpath.net>

Greg Bacon <gbacon@cs.uah.edu> wrote:

>   phenix@interpath.com (John Moreno) writes:
>
> : It doesn't pass (for one thing it doesn't always include a References
> : header) but MS has been made aware of the results and have said they
> : will address at least some of the issues in the next version of Mac OE
> 
> So does this mean that they're also aware of how shitty the quoting is
> with their toy newsreaders or do they believe it's a feature?

Yes, they are aware of it. Whether it will be fixed or not only they
know (private comments indicate that they probably will, but I don't
make any guarantees and neither did they).

-- 
John Moreno


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

Date: Fri, 08 May 1998 16:15:46 -0400
From: Gary Nielson <gnielson@charlotte.infi.net>
Subject: Question about regular expression in perl script
Message-Id: <355367F1.50903B7E@charlotte.infi.net>

Here's what I am trying to do:

In every html file, I need to replace any .htm in an A HREF statement to
 .x.htm. So if there is a line that is <a href="test.htm"> I need to
change it to <a href="test.x.htm">.  Long story, but I need to run this
on a directory repeatedly, so I need to avoid continuously adding an .x
so that I'd have test.x.x.x.x.htm after awhile.

On my first pass through, I ran this perl script that worked:

perl -p -i.bak -e 's/\.htm/\.x\.htm/' *.htm

but it wasn't sufficient to avoid adding an .x to an .htm file that
already had an .x infront of .htm.

This is what I tried subsequently:

perl -p -i.bak -e 's/[^x]\.htm/\.x\.htm/' *.htm

That definitely avoids adding a .x to any file that already has a .x
before .htm. But now it deletes the last character before the .x. So
test.htm becomes tes.x.htm. I am having trouble figuring out how to
correct this.

Any help much appreciated. Please email replies as well.

Gary
Charlotte NC



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

Date: 8 May 1998 20:44:10 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Question about regular expression in perl script
Message-Id: <6ivqqq$ifd$1@info.uah.edu>

In article <355367F1.50903B7E@charlotte.infi.net>,
	Gary Nielson <gnielson@charlotte.infi.net> writes:
: In every html file, I need to replace any .htm in an A HREF statement to
: .x.htm. So if there is a line that is <a href="test.htm"> I need to
: change it to <a href="test.x.htm">.  Long story, but I need to run this
: on a directory repeatedly, so I need to avoid continuously adding an .x
: so that I'd have test.x.x.x.x.htm after awhile.

Search the perlre manpage for `negative lookahead'.  That should help
you solve your problem.

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: 8 May 1998 20:38:03 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Question about regular expression in perl script
Message-Id: <6ivqfb$cel$1@marina.cinenet.net>

Gary Nielson (gnielson@charlotte.infi.net) wrote:
[snip]
: This is what I tried subsequently:
: 
: perl -p -i.bak -e 's/[^x]\.htm/\.x\.htm/' *.htm
: 
: That definitely avoids adding a .x to any file that already has a .x
: before .htm. But now it deletes the last character before the .x. So
: test.htm becomes tes.x.htm. I am having trouble figuring out how to
: correct this.

  perl -p -i.bak -e 's/([^x])\.htm/$1.x.htm/' *.htm

Note there's no need to escape . on the substitution side.

Oh, and I hope you don't have any files whose base part ends in x, like 
'fox.htm'.

Also, this will fail if there is more than one link on a single line.  
Add a g modifier to fix that, if this matters to you.

---------------------------------------------------------------------
   |   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, 08 May 1998 13:36:52 -0700
From: Steven Smith <steves@wco.com>
Subject: tip for Solaris in PERL
Message-Id: <35536CE4.DC07EC6F@wco.com>

Does anyone know of a version of tip written in perl??

Thanks
Steve Smith
DSC Communications
Petaluma, CA 95404



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

Date: Fri, 08 May 1998 20:26:54 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Matt Murdock <tech@BMEi.on.ca>
Subject: Re: Using split to return a @ without splitting on spaces
Message-Id: <Pine.GSO.3.96.980508131733.20271N-100000@user2.teleport.com>

On Fri, 8 May 1998, Matt Murdock wrote:

>         ($full_name, $blah) = split /,/, $pwent[6];
>         @gecos = split /,/, $pwent[6];

> If you print $full_name and $gecos[0], the result is NOT THE SAME! 
> $full_name will be the COMPLETE name, while $gecos[0] will be the FIRST
> NAME ONLY!. 

You don't need to SHOUT! :-)

Is this really true? Can you set @pwent (or $pwent[6]) to some known data,
run your code above, and get this to happen? I can't... 

    $pwent[6] = 'my full name, some other data, some more';
    ($full_name, $blah) = split /,/, $pwent[6];
    @gecos = split /,/, $pwent[6];
    print "\$full_name is '$full_name'.\n";
    print "\$gecos[0] is '$gecos[0]'.\n";

Of course, split is documented to work differently when splitting into a
literal list, but I don't think that's what you're seeing. Are you certain
that you are running the code you've given us? Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/





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

Date: 08 May 1998 20:55:30 GMT
From: j1t1w1@aol.com (J1T1W1)
Subject: What does this do?
Message-Id: <1998050820553100.QAA29329@ladder03.news.aol.com>

All,
  if someone could explain this line of code to me I would greatly appreciate
it.

              read(STDIN, $buf, $ENV{'CONTENT_SIZE'});

Pls help.TIA.

Jeff


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

Date: Fri, 8 May 1998 14:29:38 -0700
From: "matthew d. p. k. lanier" <lanier@shell6.ba.best.com>
Subject: Re: What does this do?
Message-Id: <Pine.BSF.3.96.980508142748.24927H-100000@shell6.ba.best.com>

yo-

look in the camel book, p 202.  here's the synopsis-

it reads $ENV{'CONTENT_SIZE'} number bytes from filehandle STDIN into the
scalar $buf.  let me guess, you're debugging a POST cgi?

matt lanier
matt@saturn5.com
matt@lanier.org

On 8 May 1998, J1T1W1 wrote:

> All,
>   if someone could explain this line of code to me I would greatly appreciate
> it.
> 
>               read(STDIN, $buf, $ENV{'CONTENT_SIZE'});
> 
> Pls help.TIA.
> 
> Jeff
> 
> 



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

Date: 8 May 1998 21:35:07 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: What does this do?
Message-Id: <6ivtqb$ifd$5@info.uah.edu>

In article <1998050820553100.QAA29329@ladder03.news.aol.com>,
	j1t1w1@aol.com (J1T1W1) writes:
:   if someone could explain this line of code to me I would greatly
: appreciate it.
: 
:               read(STDIN, $buf, $ENV{'CONTENT_SIZE'});

It fails to use the CGI.pm module!  Get thee to the CPAN:

    <URL:http://www.perl.com/CPAN/modules/by-module/CGI/>

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: 8 May 1998 21:58:33 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: What does this do?
Message-Id: <6ivv69$icf$1@marina.cinenet.net>

J1T1W1 (j1t1w1@aol.com) wrote:
: if someone could explain this line of code to me I would greatly appreciate
: it.
: 
:               read(STDIN, $buf, $ENV{'CONTENT_SIZE'});

It inspects the value of the environment variable CONTENT_SIZE, and reads 
that many bytes from the standard input stream into the scalar variable $buf.

This looks like the first step in a roll-your-own CGI input parser; if 
that's what you're trying to do, I'd highly recommend CGI.pm instead.

---------------------------------------------------------------------
   |   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: 8 May 1998 20:48:09 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Win95 Perl scripts DONT WORK on UNIX
Message-Id: <6ivr29$3js$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Ala Qumsieh 
<aqumsieh@matrox.com>],
who wrote in article <355319B4.8B7ECD05@matrox.com>:
> > >The reason is that Windows (or DOS) puts a
> > >character "^M" after a line, and UNIX perl
> > >does NOT understand this character.
> 
> Well, that's not Perl's problem!

This is a Perl problem.  It was not a Perl problem until 5.004, when
Chip added this ^M abomination.  It is a constant reason for
discussions here and on p5p.

I even issued a patch for this, do not know whether it made it to
5.004_05-tobe. 

Ilya


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

Date: Fri, 08 May 1998 17:02:26 -0500
From: John Beadles <beadles@nortel.com>
To: edepot <phlin@ix.netcom.com>
Subject: Re: Win95 Perl scripts DONT WORK on UNIX
Message-Id: <355380F2.C1E76D42@nortel.com>

edepot wrote:
> 
> Hello.  I found out that perl scripts written to run
> on Windows 95 Perl DOES NOT WORK
> on unix Perl.

snip... 
 
> My question is, HOW DO YOU STRIP THE
> "^M" character?  Is there a perl script that
> does this?  Is there a /usr/bin program that
> I can use to achieve this on many files?

Programmers File Editor is a freeware Windows
text editor available from:

http://www.lancaster.ac.uk/people/cpaap/pfe/default.htm

It has a unix output switch that allows you to
set this.  Works great, lasts long time.
-- 
------------------------------------------------
John T. Beadles            Nortel CDMA RF Design                       
Office: 972-685-7813           Fax: 972-684-3767 
Email (office):    beadles@nortel.removethis.com  
Any opinions are mine and to do not represent
             those of my employer
------------------------------------------------


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

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

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