[16823] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4235 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 6 11:05:28 2000

Date: Wed, 6 Sep 2000 08:05:11 -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: <968252710-v9-i4235@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 6 Sep 2000     Volume: 9 Number: 4235

Today's topics:
    Re: $LIST_SEPARATOR bug?? <iltzu@sci.invalid>
    Re: Adding the contents of multiple files. (David Wall)
    Re: CGI Script needed <mark@mark-spring.com>
    Re: Good companion book to Programming Perl? <christopher_j@uswest.net>
    Re: help with a hash? (Daniel Chetlin)
    Re: how to  encrypt source code? (Gwyn Judd)
        How to get the ARP cache on NT in PERL ? <dev-list@eicndhcpd.ch>
    Re: HTML::parse bug <gisle@ActiveState.com>
    Re: More JAPH (Was: Re: coderef to object method?) <iltzu@sci.invalid>
    Re: My Perl looks like C! <iltzu@sci.invalid>
    Re: Newbie Install Perl in windows95 <c4jgurney@my-deja.com>
    Re: newbie: redirect problem (B Gannon)
    Re: newbie: redirect problem <flavell@mail.cern.ch>
        perl giving full directory path when using pipes?? (d)
    Re: perl giving full directory path when using pipes?? <sariq@texas.net>
    Re: perl giving full directory path when using pipes?? <sariq@texas.net>
    Re: perl giving full directory path when using pipes?? (Gwyn Judd)
    Re: Perl/CGI Shell Commands <dev-list@eicndhcpd.ch>
    Re: Re-learn Perl (Daniel Chetlin)
    Re: Remove carriage returns from input <rga@io.com>
    Re: Remove carriage returns from input mexicanmeatballs@my-deja.com
    Re: Stable sorting <russ_jones@rac.ray.com>
    Re: Stable sorting (Abigail)
    Re: Stable sorting (Randal L. Schwartz)
    Re: Test if array which was returned as a reference has <brian+usenet@smithrenaud.com>
        The XY problem (was Re: CGI.pm: controlling Back & Relo (Randal L. Schwartz)
    Re: using the value of a variable for another varible's (Gwyn Judd)
    Re: using the value of a variable for another varible's <jerry@promo2.gte.net>
    Re: why does foreach iterate on an undef variable? <flavell@mail.cern.ch>
    Re: why does foreach iterate on an undef variable? <brian+usenet@smithrenaud.com>
    Re: why does foreach iterate on an undef variable? (Abigail)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 6 Sep 2000 14:20:56 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: $LIST_SEPARATOR bug??
Message-Id: <968249378.7007@itz.pp.sci.fi>

In article <rQUr5.6553$CW2.70444@news1.rdc1.ct.home.com>, Decklin Foster wrote:
 [attribution lost]
>> >   SM>        $""""   This is like "$," except that it applies to array
>
>Yuck, I've got this too, and I suspect that groff is messing up
>somewhere.

I'd say the bug is in the code generated by pod2man (see below).


>pod2man gives: (This is perl, version 5.005_03 built for i386-linux)
>
>    .Ip "$\*(T"" 8
>
>-Tlatin1 displays this as $"""". -TX100 displays $'' (two
>close-quotes, not two apostrophes).
>
>I don't know *roff very well. Can someone explain what the source is
>supposed to mean?

I don't know *roff either, but near the start of the output there is a
segment like this:

  '''   \*(M", \*(S", \*(N" and \*(T" are the equivalent of
  '''   \*(L" and \*(R", except that they are used on ".xx" lines,
  '''   such as .IP and .SH, which do another additional levels of
  '''   double-quote interpretation
  .ds M" """
  .ds S" """
  .ds N" """""
  .ds T" """""

It's inside a conditional which I assume makes it apply only when
generating ascii or latin1 output - otherwise the sequences are
defined to `` and '' which apparently generate opening and closing
double quotes respectively in printed output.

Now I have no idea what, if any, "additional levels of double-quote
interpretation" there are, but a simple s/"""+/""/ on those lines
fixes the problem.  Of course, I have no idea whether that introduces
subtle (or not) bugs elsewhere, but at least perlvar looks okay.

Anyone who does know *roff care to comment?

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla  | "By promoting postconditions to
and its pseudonyms -    |  preconditions, algorithms become
do not feed the troll.  |  remarkably simple."  -- Abigail



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

Date: 6 Sep 2000 11:01:22 -0400
From: darkon@one.net (David Wall)
Subject: Re: Adding the contents of multiple files.
Message-Id: <8FA771893darkononenet@206.112.192.118>

munch@fastnet.co.uk (Munch) wrote in <8p55n2$1j1$1@nnrp1.deja.com>:

>I wonder if someone could point me in the right direction here, as I'm
>just confusing myself.
>
>I have some text files (~300 of them) that I've crunched down so that
>they contain 4 colon-delimited fields.  The first field is an id number,
>the remaining 3 contain numeric data.  I need to come up with a total
>for each of these three data columns.  Obviously, the id number needs to
>stay unaffected.

It's unclear to me whether you want the sum of each field over all IDs, or 
the sum of each field for each ID.  In the first case I'd probably use an 
array to store the sums; in the second I'd probably use a hash of arrays, 
keyed on ID.  In either case you'll need to somehow get a list of the files 
and then loop over them, summing as you go.  

The second case seems more likely to me, so based on that, the inner loop 
(reading from a particular file), might look something like this:

while (<DATA>) {
   my ($id, $f1, $f2, $f3) = split /:/;
   $sums{$id}[0] += $f1;
   $sums{$id}[1] += $f2;
   $sums{$id}[2] += $f3;
}

%sums is a hash which should be declared (my %sums;) outside the loop over 
the file names.

If the values of a particular field can be fractions as well as numbers > 
1, then there are perhaps some considerations on the order in which you 
should sum them due to the way floating-point numbers are represented.  But 
I don't know if that will matter for you, and all I recall from the long-
ago numerical analysis class I took is that smaller numbers should be 
summed together first.

Does that help any?

-- 
David Wall
darkon@one.net


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

Date: Wed, 6 Sep 2000 16:52:28 +0200
From: "Mark Spring" <mark@mark-spring.com>
Subject: Re: CGI Script needed
Message-Id: <8p5ll6$o6h$1@blue.nl.gxn.net>



> Can anyone help?
> Many thanks

Um, .. like what are you paying ??
No seriously, this is pretty advanced in the sense that to write a secure
script (so that no one can exploit holes and the like) is a lot more than
just an evenings work.

Mark




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

Date: Wed, 6 Sep 2000 08:00:21 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: Good companion book to Programming Perl?
Message-Id: <2_st5.1671$Xq2.114107@news.uswest.net>


"David H. Adler" <dha@panix.com> wrote:
[snip: talk about perl for dummies]
> For a more detailed and less heated informed opinion on this book,
> please see http://www.plover.com/~mjd/perl/reviews/p54d.html

Oh...dear...god....

Is the book really that bad?!  I boggle at the sheer magnitude of
the idiocy.  To more accurately represent my state of boggle, I
present the following skit.


Scene: Me and Paul Hoffman (writer of Perl 5 for Dummies) in a room.

<Me> Hi, you wrote Perl 5 for Dummies eh?
<Paul Hoffman> Yes I did
<Me> So, you must have kept it pretty simple, down to Earth, so that
  the newcommers and non-pros can understand it easily right?
<Paul Hoffman> Oh yeah, I kept the first example program under 50
  lines, and I made sure not to talk about continue, redo, the
  caller function, the xor operator, etc. a\
<Me> at all?
<Paul Hoffman> No, a lot, I kept it to only a paragraph or two at
  the most.
<Me> Are you high on crack?!
<Paul Hoffman> Not at the moment, besides the cops took away my pipe.
<Me> What about the rest of the book?
<Paul Hoffman> Oh yeah, it was all very straightforward very simple,
  supremely elegant I would say.
<Me> Any examples you are particularly proud of?
<Paul Hoffman> Well, this one (pulls out book and points to...)

   ($Second, $Minute, $Hour, $DayOfMonth, $Month, $Year,
        $WeekDay, $DayofYear, $IsDST) = localtime(time);
   $RealMonth = $Month + 1;
   print "$RealMonth/$DayofMonth/$Year";

<Me> !!!!! That is butt ugly!  And why didn't you use '$Month++'?
<Paul Hoffman> Umm well the ++ operator actually results in
   inneficient object code, plus it's more difficult for new users
   to understand.  Anyway, I'm a super perl hacker so you should do
   it my way 'cause I know best.
<Me> OH MY FUCKING GOD MY BOGOMETER JUST *EXPLODED*!!

(Fade to black as Paul Hoffman collapses to the floor with a
huge crater in his skull created as fragments of the bogometer
hit his face when it exploded.)






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

Date: Wed, 06 Sep 2000 13:06:25 GMT
From: daniel@chetlin.com (Daniel Chetlin)
Subject: Re: help with a hash?
Message-Id: <ljrt5.61396$f65.1718251@news-west.usenetserver.com>

On Wed, 06 Sep 2000 02:31:07 GMT,
 ptomsic@my-deja.com <ptomsic@my-deja.com> wrote:
>I want to rip a string apart, finding the HREF and the Text that's
>associated w/ the HREF, and place this into a HASH, i.e.
>$link{this.html} = "Click Here";
>
>for all the links on a page.  How could I do this using a function call
>to return the HASH?
>
>So, I want to make a call to a function (getHREFS) and have it return
>a HASH, w/ Key's as HREFS and VALUES as the text.
>
>Could someone assist (with the function returning part) as I've got the
>HREF and the text part down using TokeParser.

I'm not sure exactly what you're looking for here, but functions can returns
hashes fairly easily. C<return %h>. Of course, that will push each of the keys
and values of the hash onto the stack, so it's not particularly efficient.
You're probably better off returning a reference to the hash.

But the real reason I'm following up here (since anyone can and will tell you
the above) is that if you're doing what you say you're doing with TokeParser,
you already have the hash built for you. Element 2 of any start tag token is a
reference to a hash with all the attributes of that tag as keys and their
values as values. You shouldn't need to do any ripping apart of strings.

(OK, that's not entirely true. For annoying things like <META> tags for cheesy
redirects that some sites use (see http://espn.go.com/nfl for an example)
you'll have a key/value pair in your attr hash that looks like:

  'content' => '0; url=http://football.espn.go.com/nfl/index'

This is a pain. There are other examples of things like this. If you're really
trying to find _all_ links on an arbitrary page, you have to be more clever.

But for general <a> and <img> tag stuff, TokeParser should be fine. And you
shouldn't have to do string manipulation.

-dlc




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

Date: Wed, 06 Sep 2000 14:22:51 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: how to  encrypt source code?
Message-Id: <slrn8rckpn.e12.tjla@thislove.dyndns.org>

I was shocked! How could Ilmari Karonen <iltzu@sci.invalid>
say such a terrible thing:
>In article <MPG.14192197ddf92e989682@news.cyberway.com.sg>, DT wrote:
>>how to  encrypt source code?  thanks!
>
>  perl -pey+a-zA-Z+n-za-mN-ZA-M+ <source_file >encrypted_file
>
>For even better encryption, repeat the process.

I prefer the ISO standard rot12:

perl -pey=a-zA-Z=m-za-lM-ZA-L=

It is backwards compatible with rot13. All you need to do is repeat 13
times. This also illustrates the most important factor in its security:
it is non-symmetric. Yes, to decrypt rot12 is 26 times as difficult as
it is to encrypt. I recommend everyone should upgrade their mission
critical systems to rot12 as soon as possible before the US DoD makes it
illegal to export. Tell your friends! You too can have military grade
encryption for a low, low price! rot12 saved my marriage! It slices! It
dices! rot12 is the best thing since Perl!! Visit our website at
www.rot12.com for amazing customer appraisals! rot12 is the best program
ever written in perl*! rot12 is probably y2k compliant! It compiled, we
shipped! You missed out on the internet craze, don't miss out on rot12!


* by me. Offer void where prohibited.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
To be sure of hitting the target, shoot first, and call whatever you
hit the target.
-Ashleigh Brilliant (contributed by Chris Johnston)


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

Date: Wed, 06 Sep 2000 16:24:24 +0200
From: Nils Reichen <dev-list@eicndhcpd.ch>
Subject: How to get the ARP cache on NT in PERL ?
Message-Id: <39B65398.C06EB312@eicndhcpd.ch>

Hi,

I'm searching a way to retreive the ARP cache on a NT workstation in
Perl
other than system('arp.exe -a').

Could someone help me... I'm searching for a while without any success

Thanks in advance

Nils

--
 .
 .                     \\  - -  //
 .                      (  @ @  )
 . /------------------oOOo-(_)-oOOo--------------------\
 .(_|                  Nils Reichen                    |
 .  |              EICNDHCPD developper                |
 .  |              dev-list@eicndhcpd.ch               |
 .  |                EICNDHCPD ORG                     |_
 .  |               www.eicndhcpd.ch                   | )
 .  \---------------------------Oooo--------------------/
 .                       oooO   (   )
 .                      (   )    ) /
 .                       \ (    (_/
 .                        \_)
 .




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

Date: 06 Sep 2000 15:23:11 +0200
From: Gisle Aas <gisle@ActiveState.com>
Subject: Re: HTML::parse bug
Message-Id: <m3n1hlac3k.fsf@eik.g.aas.no>

Tim Cockle <T.Cockle@staffs.ac.uk> writes:

> I don't use it directly there is a reference from HTML::TokeParser.
> 
> But I have looked at the TokeParser (get_token) and the failure occurs in the
> HTML::Parse code.

How does it crash?  Are you able to reduce it to a little test program
that you can share?

> jason wrote:
> 
> > Tim Cockle <T.Cockle@staffs.ac.uk> wrote ..
> > >I have found a bug somwwhere in HTML::parse. I have written a simple
> > >server wich works fine. However if I convert it into a forking server it
> > >crashes out.
> > >
> > >Does this sound fermular to anyone?
> > >
> > >If no one has seen this problem don't worry. I going to restart my
> > >investigation into the bug so will be able to proved a much better
> > >description shortly.
> >
> > before you start .. you should be aware that HTML::Parse is deprecated
> > .. you should be using HTML::Parser

-- 
Gisle Aas


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

Date: 6 Sep 2000 15:00:22 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: More JAPH (Was: Re: coderef to object method?)
Message-Id: <968250415.11209@itz.pp.sci.fi>

In article <slrn8r2nn5.8ac.abigail@alexandra.foad.org>, Abigail wrote:
>(Hmmm, "Just another Perl hacker,\n" is 26, which is as many letters
> as the alphabet)

 ..which makes this work one out nicely:

  print @{{split//,"buitdtcsxrprlrhognqlvkshjhweoekeuctafanPaJy,r m e z\n"}}{a..z}

I just recently posted that, though.  I think I should include
something new:

  print map $p^=$_^p,split//,":Ovw\$1\x7fqkl}g\"\0Egn<8yrx~g.V"

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla  | "By promoting postconditions to
and its pseudonyms -    |  preconditions, algorithms become
do not feed the troll.  |  remarkably simple."  -- Abigail



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

Date: 6 Sep 2000 13:14:46 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: My Perl looks like C!
Message-Id: <968244893.20669@itz.pp.sci.fi>

In article <Pine.LNX.4.21.0008312324100.28238-100000@hawk.ce.mediaone.net>, Andrew N. McGuire  wrote:
>efficient ways to do many things.  Hashes are a strong point with
>Perl, yes, but Perl is not the only language to implement hashes.

Indeed.  Java also has hashes, and I use them whenever they suit the
job.  But I don't use them nearly as much as in Perl, simply because
the syntax is a pain in the ass.  Perl hashes are not only efficient
but also extremely convenient.  _That's_ why they should be used.

Perl:  $hash{key}++;

Java:  Integer temp = (Integer) hash.get("key");
       if (temp == null) temp = new Integer (0);
       hash.put("key", new Integer(1 + temp.intValue()));

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla  | "By promoting postconditions to
and its pseudonyms -    |  preconditions, algorithms become
do not feed the troll.  |  remarkably simple."  -- Abigail



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

Date: Wed, 06 Sep 2000 14:39:38 GMT
From: Jeremy Gurney <c4jgurney@my-deja.com>
Subject: Re: Newbie Install Perl in windows95
Message-Id: <8p5kv5$irs$1@nnrp1.deja.com>

In article <8p5bfs$7h4$1@nnrp1.deja.com>,
  Hardy Merrill <hmerrill@my-deja.com> wrote:
> In article <39B60B70.DA9A0F0B@postoffice.pacbell.net>,
>   hpya78@pacbell.net wrote:
> > Hello everybody
> >
> > Can somwone tell me how to install perl in win95?
>
> Go to http://www.activestate.com and pick ActivePerl 617 - at least
617
> is the version I see there this morning.
>

I hope they've fixed this nasty little bug in the install package with
the new version.

http://bugs.activestate.com/ActivePerl/installation?id=243

It bit me, and caused a few moments of panic before I got things fixed.

Jeremy Gurney
SAS Systems Analyst  |  Protherics Molecular Design Ltd.
"When everything is coming your way, you're in the wrong lane."


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 6 Sep 2000 13:50:11 GMT
From: admin@kopnews.co.uk (B Gannon)
Subject: Re: newbie: redirect problem
Message-Id: <8p5i2j$fip$3@news.liv.ac.uk>


You could try:-

print "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0\; 
URL=http://www.somewhere.com\">";

Cheating a bit but should do the trick.

B Gannon
http://www.kopnews.co.uk
Home of the LFC Prediciton League.



In article a says...
>
>Can anyone please sort me out.
>
>I'm browsing a perl script which is served up by an IIS server.
>(http://site/my.pl)
>And from within the perl script I want to jump to another URL.
>
>I think what I need is a redirect -
>so I've tried the redirect syntax from CGI.pm :-
>$query->redirect(-uri=>'http://site/page.htm',     -nph=>1);
>But this just displays in the browser the following message :-
>"HTTP/1.0 302 Moved Status: 302 Moved Location: http://site/page.htm "
>
>Also the syntax from http://stein.cshl.org/~lstein/talks/marjorie/
>        print redirect('http://site/page.htm');
>But this does nothing
>
>Thanks in advance
>Harry
>



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

Date: Wed, 6 Sep 2000 16:21:07 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: newbie: redirect problem
Message-Id: <Pine.GHP.4.21.0009061615490.8800-100000@hpplus03.cern.ch>

On 6 Sep 2000, B Gannon wrote:

> You could try:-
> 
> print "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0\; 
> URL=http://www.somewhere.com\">";

You could also "try" putting your head in a bucket?

> Cheating a bit 

Why "cheat" when a properly-engineered solution is available?

> but should do the trick.

Including the various disadvantages that have been posted hundreds of
times already. 

> http://www.kopnews.co.uk

                                   spa
                            spacer text [INLINE]

                               Home [INLINE]
                                 Advertise

   [INLINE]

yeah, well.  And upside-down quoting too.

> Home of the LFC Prediciton League.
                  ^^^^^^^^^^

Is that some new sub-atomic particle?


[and another jeopardectomy and score-adjustment on the N.H.S]



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

Date: Wed, 06 Sep 2000 13:11:10 GMT
From: you@somehost.somedomain (d)
Subject: perl giving full directory path when using pipes??
Message-Id: <Onrt5.9356$B54.27039@newsfeed.slurp.net>

I am running perl5.004 on an HP 10.20.

When I use a pipe in a unix statement such as

$test=`cat $file | wc -l`;

It will return the full directory path that I am in and
the answer.  such as

/opt/ns-ftrack/docs/test
3

Please help.  This is blowing up all of my programs.  It
just started happening, and some of these programs have ran
fine for years.




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

Date: Wed, 06 Sep 2000 09:05:54 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: perl giving full directory path when using pipes??
Message-Id: <39B64F42.DBBA97CB@texas.net>

d wrote:
> 
> I am running perl5.004 on an HP 10.20.
> 
> When I use a pipe in a unix statement such as
> 
> $test=`cat $file | wc -l`;

Ah, another 'Useless Use of cat' award.

> It will return the full directory path that I am in and
> the answer.  such as
> 
> /opt/ns-ftrack/docs/test
> 3
> 
> Please help.  This is blowing up all of my programs.  It
> just started happening, and some of these programs have ran
> fine for years.

Then something changed.  You don't give us enough information.

- Tom


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

Date: Wed, 06 Sep 2000 09:19:09 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: perl giving full directory path when using pipes??
Message-Id: <39B6525D.182A382@texas.net>

Tom Briles wrote:
> 
> d wrote:
> >
> > I am running perl5.004 on an HP 10.20.
> >
> > When I use a pipe in a unix statement such as
> >
> > $test=`cat $file | wc -l`;
> 
> Ah, another 'Useless Use of cat' award.
> 
> > It will return the full directory path that I am in and
> > the answer.  such as
> >
> > /opt/ns-ftrack/docs/test
> > 3
> >
> > Please help.  This is blowing up all of my programs.  It
> > just started happening, and some of these programs have ran
> > fine for years.
> 
> Then something changed.  You don't give us enough information.

Ack.  I failed to include the relevant references to the FM:

man wc
perldoc -q 'lines.*file' # For alternatives, try a Usenet search.

- Tom


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

Date: Wed, 06 Sep 2000 14:34:11 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: perl giving full directory path when using pipes??
Message-Id: <slrn8rclf0.e12.tjla@thislove.dyndns.org>

I was shocked! How could d <you@somehost.somedomain>
say such a terrible thing:
>I am running perl5.004 on an HP 10.20.

You should upgrade. 5.004 is not history anymore, we're talking
archeology. It has known security issues and buffer overflows.

>When I use a pipe in a unix statement such as
>
>$test=`cat $file | wc -l`;
>
>It will return the full directory path that I am in and
>the answer.  such as
>
>/opt/ns-ftrack/docs/test
>3

What do you get when you type 'cat some_file | wc -l' at the command
line?

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
A writer is congenitally unable to tell the truth and that is why we
call what he writes fiction.
-William Faulkner


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

Date: Wed, 06 Sep 2000 16:27:30 +0200
From: Nils Reichen <dev-list@eicndhcpd.ch>
Subject: Re: Perl/CGI Shell Commands
Message-Id: <39B65452.D92E008B@eicndhcpd.ch>

Are you using IIS ? In this case you have to add a registry key
in W3SVC service like CreateProcessWithNewConsole in DWORD to 1.

Do a short search in the MS knowlegde base.

Under Apache, I don't know...

Nils



--
 .
 .                     \\  - -  //
 .                      (  @ @  )
 . /------------------oOOo-(_)-oOOo--------------------\
 .(_|                  Nils Reichen                    |
 .  |              EICNDHCPD developper                |
 .  |              dev-list@eicndhcpd.ch               |
 .  |                EICNDHCPD ORG                     |_
 .  |               www.eicndhcpd.ch                   | )
 .  \---------------------------Oooo--------------------/
 .                       oooO   (   )
 .                      (   )    ) /
 .                       \ (    (_/
 .                        \_)
 .


darlenewong@my-deja.com wrote:

> I need my CGI script to execute a series of Unix commands and return the
> output.  I can get
>
> `command1`;
>
> to execute fine by using backticks.  However, I need the first command's
> output redirected to the input of the second command, and so on:
>
> `command1 | command2 | command 3 | ...`
>
> I have four commands total.  For some reason, the redirection beyond the
> second command fails.  Any help would be much appreciated!
>
> Darlene
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.



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

Date: Wed, 06 Sep 2000 13:10:19 GMT
From: daniel@chetlin.com (Daniel Chetlin)
Subject: Re: Re-learn Perl
Message-Id: <%mrt5.61398$f65.1718251@news-west.usenetserver.com>

On Wed, 06 Sep 2000 12:43:14 +0200, P.Eftevik <haf@autra.noXX> wrote:
>I used to program perl (4.0), but it's some years ago now.
>And now it's time to code perl again, so I need to re-learn what I've
>spent 6-7 years to forget.
>
>In addition, the language has probably evolved significantly over
>this period.
>
>Question: where do I find a 'Quick reference Guide' and some brief
>code samples and other hints to freshen up my prior skill ?

First place I'd look is perldoc perltrap. Make sure you get the most recent
one, which is in 5.7.0 but not 5.6.0. I just freshened it about a month ago.

It won't give you everything you need, but it's a good glance at what has
changed since Perl 4 (though the document starts with stuff about awk, sed, C,
and shell, it's mostly about changes from Perl 4 to Perl 5 and what to watch
out for) and will probably do a good job of jogging your memory.

Beyond that, just take a ride through the rest of the documentation, and
experiment.

If you're looking for something you can buy, Johan Vromans' _Perl 5 Pocket
Reference_ is well worth the $9 it will cost. It's printed by O'Reilly.

-dlc




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

Date: Wed, 6 Sep 2000 09:00:07 -0500
From: "RGA" <rga@io.com>
Subject: Re: Remove carriage returns from input
Message-Id: <ffst5.581840$MB.8741843@news6.giganews.com>


> It depends where your input is coming from, but I'd do 2 s///
> statements, one to remove your returns and then again to remove your
> newlines.


Yes, that's what I want:

Input is from TEXT AREA form input
If carriage returns are used in the Text Area
Then they show up in my POST and script working with the POST

I want to be able to put about 50 words entered in TEXT AREA
(from g*d knows how many Returns the user might use) .. into
 a single line stored to flat file ..

Right now, the line endings show up (carriage returns) ..

Bottom line: I want any of the Text Area input (/012, /015 stripped)
 So that it ends up as one element in my array of input, not multiple
 elements (triggered by /012 or /015) ..

This must be free of line endings and carriage returns:

$line = $FORM{'TextArea'};

 how about:

$line =~ tr/\n//d;
$line =~ tr/\r//d;

Thanks for all the direction.
I'll test it all out

I know it's a cgi Q.













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

Date: Wed, 06 Sep 2000 14:47:21 GMT
From: mexicanmeatballs@my-deja.com
Subject: Re: Remove carriage returns from input
Message-Id: <8p5ldg$ji8$1@nnrp1.deja.com>

In article <ffst5.581840$MB.8741843@news6.giganews.com>,
  "RGA" <rga@io.com> wrote:
>
<snip>
> Input is from TEXT AREA form input
> If carriage returns are used in the Text Area
> Then they show up in my POST and script working with the POST
>
> I want to be able to put about 50 words entered in TEXT AREA
> (from g*d knows how many Returns the user might use) .. into
>  a single line stored to flat file ..
>
> Right now, the line endings show up (carriage returns) ..
>
> Bottom line: I want any of the Text Area input (/012, /015 stripped)
>  So that it ends up as one element in my array of input, not multiple
>  elements (triggered by /012 or /015) ..
>
> This must be free of line endings and carriage returns:
>

But you still have the case where a line end marker is
used to split two words i.e. "Jon has\na\ncat"
If you just strip them you get "Jon hasacat" when you
would _probably_ want "Jon has a cat"

In which case you'd want something like:
s/[\r\n]+/ /g;
or
tr/\r\n/ /s;

-
Jon
perl -e 'print map {chr(ord($_)-3)} split //, "MrqEdunhuClqdph1frp";'


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 06 Sep 2000 08:11:41 -0500
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: Stable sorting
Message-Id: <39B6428D.6F563236@rac.ray.com>

Abigail wrote:
> 
> Perl 5.7.0 uses merge sort to implement sort(). Merge sort is stable.
> 


But Perl 5.7.0 isn't. That Catch 22, that's one hell of a catch.


-- 
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747

Quae narravi, nullo modo negabo. - Catullus


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

Date: 06 Sep 2000 10:42:27 EDT
From: abigail@foad.org (Abigail)
Subject: Re: Stable sorting
Message-Id: <slrn8rclsr.tjm.abigail@alexandra.foad.org>

Russ Jones (russ_jones@rac.ray.com) wrote on MMDLXIII September MCMXCIII
in <URL:news:39B6428D.6F563236@rac.ray.com>:
$$ Abigail wrote:
$$ > 
$$ > Perl 5.7.0 uses merge sort to implement sort(). Merge sort is stable.
$$ 
$$ 
$$ But Perl 5.7.0 isn't. That Catch 22, that's one hell of a catch.


    $ /opt/devperl/bin/perl -v | grep built
    This is perl, v5.7.0 built for i686-linux-64int-ld
    $


I don't quite see your point. Sure, 5.7.0 isn't stable. But 5.7.x leads
to 5.8.x which _will_ be stable.



Abigail
-- 
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()


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

Date: 06 Sep 2000 08:03:42 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Stable sorting
Message-Id: <m14s3tmuk1.fsf@halfdome.holdit.com>

>>>>> "Russ" == Russ Jones <russ_jones@rac.ray.com> writes:

Russ> Abigail wrote:
>> 
>> Perl 5.7.0 uses merge sort to implement sort(). Merge sort is stable.
>> 


Russ> But Perl 5.7.0 isn't. That Catch 22, that's one hell of a catch.

5.6.1 will most likely keep this feature.  And 5.6.1 should be more
stable than either 5.6.0 or 5.7.0 (one would hope).

-- 
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: Wed, 06 Sep 2000 10:41:01 -0400
From: brian d foy <brian+usenet@smithrenaud.com>
Subject: Re: Test if array which was returned as a reference has something in it?
Message-Id: <brian+usenet-D43F06.10410106092000@news.panix.com>

In article <39b58b4e.138622915@news.pacbell.net>, brian@brie.com (Brian 
Lavender) wrote:

> You will notice that I have the "&&"  which will after sucessfully
> returning a reference, will test to see if the array it returned has
> something in it, but this way seems a bit kludish, so I was wondering
> if this is a good way to do this?

> while (  ($columns = $csv->getline($fh))  && @$columns ) {

looks fine.  i'd probably do something like

   while( $columns = $csv->getline($fh) )
      {
      next unless @$columns;

      }

so i could get past a line with no elements, though.

-- 
brian d foy
Perl Mongers <URL:http://www.perl.org>
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>


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

Date: 06 Sep 2000 07:59:58 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: The XY problem (was Re: CGI.pm: controlling Back & Reload)
Message-Id: <m18zt5muq9.fsf_-_@halfdome.holdit.com>

>>>>> "Alan" == Alan J Flavell <flavell@mail.cern.ch> writes:

Alan> This looks to me to be another case of "premature closure": the
Alan> questioner wanted to solve some not very clearly stated X, they
Alan> concluded that Y and Z were components of a solution, and now they're
Alan> asking how to implement Y and Z.  Take a step back, look at the bigger
Alan> picture, free yourself of this inappropriate partial solution.

On IRC chatting (EFnet #perl, to be precise), we call this an "XY
problem" for shorthand.  Alan of course has made it more complicated
by introducing another variable. :) :)

It's important for me as a person who's been on the listening end of
questions for many years, and who has to listen professionally (and
most of the time answer professionally) to realize that all problems
are pieces of solutions to larger problems.  (Think about it a second,
and you'll see that its necessarily so, all the way back to "why the
heck did I get out of bed today?", if not higher.)  So, to answer
question Y, without understanding larger problem (the context) X, will
most likely *not* help them entirely with X.  I actually consider
that a bit irresponsible.

How it shows up in the chatrooms (or even live, but rarer) is that
someone will say "how do I do Y?".  I usually take a deep breath
before answering, and try to understand who a person would have to be
to *ask* about Y, and make sure that I know enough about all possible
X's to verify that an answer is invariant (doesn't depend) on those.
Often, my spider sense will tingle, and I start asking the context
questions, but at the same time, I see a lot of other people answering
the Y question literally.  More often than not, they have presumed too
much, and it sends the person off with premature answer that really
doesn't help solve X or Y entirely.

So, the key is to listen, and try to crawl inside the head of the
requestor to see why they would even have that question.  It helps to
be appropriate.  When I'm doing it live while teaching, it also keeps
me on my toes, as I have to do this in a way that respects the
questioner *and* still keeps the rest of the classroom interested.
Fun, and challenging at the same time.  It's one of the parts of
teaching that I most enjoy.

print "NOT just another Perl trainer," # :-)

-- 
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: Wed, 06 Sep 2000 13:47:22 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: using the value of a variable for another varible's name?
Message-Id: <slrn8rcin7.e12.tjla@thislove.dyndns.org>

I was shocked! How could Uri Guttman <uri@sysarch.com>
say such a terrible thing:
>>>>>> "GJ" == Gwyn Judd <tjla@guvfybir.qlaqaf.bet> writes:
>
>  GJ> my $day = 'monday';
>  GJ> my $monday = '11 am';
>  GJ> print $$day, "\n";
>  >> 
>  >> because $monday has no entry in the symbol table as it is lexical. so
>  >> you can't access it with a symref.
>
>  GJ> Okay that makes sense...seems a shame though
>
>why is it a shame? the whole point of lexicals is they don't exist in
>the symbol table. they are safer for that reason and because they
>require hard refs. there is no way to have what you want as they are not
>compatible ideas.

I agree realy, I was just referring to the obvious symmetry with the
hard ref which is what tripped me up. Here is a question. Why doesn't
this trigger a run-time warning on the third line:

my $day = 'monday';
my $monday = '11 am';
my $temp = $$day;

Since $monday has no entry in the symbol table, isn't the third line
always going to be in error? Wouldn't it be better to trigger an warning
such as '$day is not a valid symref' rather than 'Use of uninitialized
value' later on?

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
I don't even butter my bread.  I consider that cooking.
		-- Katherine Cebrian


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

Date: Wed, 06 Sep 2000 14:01:42 GMT
From: Jerry Jorgenson <jerry@promo2.gte.net>
Subject: Re: using the value of a variable for another varible's name?
Message-Id: <39B64D91.F389E6C@promo2.gte.net>

Gwyn Judd wrote:

> I agree realy, I was just referring to the obvious symmetry with the
> hard ref which is what tripped me up. Here is a question. Why doesn't
> this trigger a run-time warning on the third line:
>
> my $day = 'monday';
> my $monday = '11 am';
> my $temp = $$day;
>
>

It does:

     1  #!/usr/sbin/perl
     2  use diagnostics;
     3  use strict;
     4
     5
     6  my $day = 'monday';
     7  my $monday = '11 am';
     8  my $temp = $$day;
     9
    10  print "\n", $temp, "\n" ;
    11
    12  exit;

$ ./junk.pl
Can't use string ("monday") as a SCALAR ref while "strict refs" in use at
        ./junk.pl line 8 (#1)

    (F) Only hard references are allowed by "strict refs".  Symbolic
references
    are disallowed.  See perlref.

Uncaught exception from user code:
        Can't use string ("monday") as a SCALAR ref while "strict refs" in use
at ./junk.pl line 8.

Jerry

--
Jerry Jorgenson
972-209-0191 (pager)
jerry@j3iss.com





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

Date: Wed, 6 Sep 2000 15:15:34 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: why does foreach iterate on an undef variable?
Message-Id: <Pine.GHP.4.21.0009061502300.8800-100000@hpplus03.cern.ch>

On Wed, 6 Sep 2000, Louise Davis wrote:

> I'll remember that but I don't think I will be posting again - not after
> this !

When you were reading this forum's discussions prior to deciding
whether to post anything to it, it's hard to understand how you
wouldn't have noticed that it's mostly a technical forum with a fairly
robust style of discourse.  If you're involved in Perl programming
then it can be a deal of help to you (it certainly has been to me - in
most cases by reading threads in which I haven't actually
participated, and only occasionally by getting involved myself).  But
you have to be able to take a few knocks and not flounce off in a
huff.

> > Rather: think
> > the problem through a bit better before posting, so you don't have to
> > post as much. One followup to yourself is acceptable, two is a bit much]
> 
> Sorry - I don't understand this - I only posted once and this is my only
> follow up.

Martien seems to have got confused, partly exacerbated by the
inability or unwillingness of the original poster as well as yourself
to conform with the long-established usenet quoting style: i.e quote
specifically what relates to your new comment, place your new comment
after that quote, and delete the remainer of the quoted posting.

Again it's hard to see how a new participant would not become aware of
the group's collective view on this topic, while following the
existing discussions before deciding whether to contribute.  Usenet
netiquette, at least for the major (now "big 8") groups has been
established over quite a number of years, as set out in new user FAQs
etc., see e.g the routine postings to news.announce.newusers; they
aren't suddenly obsoleted because some slovenly vendor has released a
pointy-clicky thing that pretends amongst other things to be a usenet
news client, but seems to violate (or to encourage its users to
violate) a significant proportion of the netiquette rules.  It's high
time that news administrators started blocking the propagation of
articles that seriously violate these netiquette conventions, but
that's off-topic for this group.

have fun



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

Date: Wed, 06 Sep 2000 10:37:10 -0400
From: brian d foy <brian+usenet@smithrenaud.com>
Subject: Re: why does foreach iterate on an undef variable?
Message-Id: <brian+usenet-0313F6.10371006092000@news.panix.com>

In article <hPnt5.1223$5E3.62197@bgtnsc06-news.ops.worldnet.att.net>, 
"Paul Johnston" <johnston.p@worldnet.att.net> wrote:

> I'm confused as to the logic of why a foreach loop block *is* entered when
> the LIST is undef (NOT expected), but *is not* when the LIST is an empty
> array (expected behavior):

> # empty list
> @array = ();

yes.  that list is an empty list.

> # empty list
> @array = undef;

no. that is a list of one element. try:

   @array = undef;
   print $#array, "\n"; 

the same thing happens when you assign a scalar to any
array.  the scalar is promoted to a list of one element.

if you want to undef an array, do it as documented:

   undef @array;

see http://www.perldoc.com/perl5.6/pod/func/undef.html

-- 
brian d foy
Perl Mongers <URL:http://www.perl.org>
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>


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

Date: 06 Sep 2000 10:46:28 EDT
From: abigail@foad.org (Abigail)
Subject: Re: why does foreach iterate on an undef variable?
Message-Id: <slrn8rcm4c.tjm.abigail@alexandra.foad.org>

Martien Verbruggen (mgjv@tradingpost.com.au) wrote on MMDLXIII September
MCMXCIII in <URL:news:slrn8rc8g3.ucf.mgjv@martien.heliotrope.home>:
%% 
%% That's correct. I'm glad you figured it out. My post is mainly as an
%% asddition to that. If you now next time test these sorts of things with
%% _all_ the help Perl gives you (-w flag, the strict pragma), you will
%% probably figure it out before you need to post :)

No. Perl doesn't think anything strange is going on.

    $ perl -Mstrict -wle 'my @a = undef; foreach my $s (@a) {print "foo"}'
    foo
    $


Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 4235
**************************************


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