[11161] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4761 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 27 13:07:16 1999

Date: Wed, 27 Jan 99 10:00:23 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 27 Jan 1999     Volume: 8 Number: 4761

Today's topics:
    Re: [Perl] How to find the Perl FAQ <upsetter@ziplink.net>
    Re: dupes in Perl <jdf@pobox.com>
    Re: dupes in Perl <jdf@pobox.com>
    Re: dupes in Perl (Larry Rosler)
    Re: dupes in Perl (I R A Aggie)
    Re: HELP - with redirect of STDERR and STDOUT <qdtrini@jdicms88.ericsson.se>
    Re: Help a newbie with a custom shipping script? (Abigail)
        Help on deleting an item in an array? <c-denman@dircon.co.uk>
    Re: Help on deleting an item in an array? <jdf@pobox.com>
    Re: Help on deleting an item in an array? (Sam Holden)
    Re: Help on deleting an item in an array? <tbriles@austin.ibm.com>
    Re: How could this NOT work? (Abigail)
    Re: How long would the Unixes last without Perl? (Kenneth Hamer)
    Re: how to return multiple values in perl? (Tad McClellan)
    Re: Is s///ge non-reentrent? Or did I find a bug? <jdf@pobox.com>
    Re: Is this possible? (Tad McClellan)
    Re: Is this possible? (Abigail)
    Re: Jesus Rides a HOG(tm) : was :CONCLUSIVE PROOF: The  (Ears)
    Re: login script with perl ! <imran@orangenet.co.uk>
    Re: Newbie Question <23_skidoo@geocities.com>
    Re: Newbie Question <tbriles@austin.ibm.com>
    Re: Perl Criticism (Larry Rosler)
    Re: Perl Criticism <jeromeo@atrieva.com>
    Re: Perl error/exception strings... droby@copyright.com
    Re: please help: outputting line number to display <jdf@pobox.com>
        Q: CPAN on Win32 (Windows NT) Perl Denis.Haskin@bigfoot.com
        Q: use vs. require mgrimes@my-dejanews.com
        Removing New Lines in Form Fields <r2-d2@REMOVEbigfoot.com>
    Re: Removing New Lines in Form Fields <c-denman@dircon.co.uk>
    Re: sorting dates <bsmith@perf.zko.dec.com>
    Re: system function, Pros and Cons?? <jc@uwm-dev.gte.com>
    Re: system function, Pros and Cons?? (Tad McClellan)
    Re: system function, Pros and Cons?? <tchrist@mox.perl.com>
    Re: system function, Pros and Cons?? (Ilya Zakharevich)
        The Art of Computer Mindmaking (Arthur T. Murray)
    Re: The Art of Computer Mindmaking <jdf@pobox.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 27 Jan 1999 17:34:51 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: [Perl] How to find the Perl FAQ
Message-Id: <%6Ir2.55$q74.10062@news.shore.net>


Cho Man Yu <chomanyu@netvigator.com> wrote:
: Tom Phoenix wrote:

[entire previous post included]

: Is this free of charge

Please send your money orders directly to me. 

--Art

-- 
--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
                  http://www.agitators.com/calendar/
--------------------------------------------------------------------------


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

Date: 27 Jan 1999 17:21:10 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: dturley@pobox.com
Subject: Re: dupes in Perl
Message-Id: <m3u2xcptzd.fsf@joshua.panix.com>

dturley@pobox.com writes:

> Well, you've got me there. I might have no idea what PLONK! means
> (not good I'm sure :-)

http://www.wins.uva.nl/~mes/jargon/p/plonk.html

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: 27 Jan 1999 17:30:48 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: tadmc@metronet.com (Tad McClellan)
Subject: Re: dupes in Perl
Message-Id: <m3r9sgptjb.fsf@joshua.panix.com>

tadmc@metronet.com (Tad McClellan) writes:

>   I have similarly stepped on my di^H^H... on a part of my anatomy
>   that is very painful to step on, in the past.

If I were physically able to do such a thing, I'd be in another line
of work entirely.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf
rolling...  speed...   ACTION!


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

Date: Wed, 27 Jan 1999 08:39:01 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: dupes in Perl
Message-Id: <MPG.1118e0fe51105ef79899d2@nntp.hpl.hp.com>

I have modified the Subject to hook this back into the original thread, 
for closure -- I hope!

In article <78nadc$21v$1@nnrp1.dejanews.com> on Wed, 27 Jan 1999 
15:12:54 GMT, dturley@pobox.com <dturley@pobox.com> says...
> Okay, this thread might get as long as topmind's. Apparently I was the only
> one who found Larry Rosler's email reply and post to be condenscending. Fine.
> I apologize to Larry, although I am sure he couldn't care less about what I
> have to say. I apologize to the 'neighborhood' for wasting bandwidth.

I assure you that I do care, because accumulating karma is not a zero-
sum game.  Each of ours can now increase.

> My plea for no more responses to topmind went ignored, why not my spouting
> off? :-)
> 
> Anyway, please direct further responses to me via email and let's get back to
> Perl.

My main goal in this post is to acknowledge closure of this issue in the 
thread in which it began.

> I'll go back to read-only mode.

Why?  Take Tad McClellan's advice -- keep in mind that all these 
submissions are archived and indexed, and give the flames a little 
chance to cool down or burn out.

> sigh.
> 
> cheers, david
> --

If you add a trailing space character on that line (according to a 
literally inscrutable Internet convention), your .sig will not appear in 
follow-ups.

<SNIP> remainder of .sig.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 27 Jan 1999 12:10:50 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: dupes in Perl
Message-Id: <fl_aggie-2701991210500001@aggie.coaps.fsu.edu>

In article <m3r9sgptjb.fsf@joshua.panix.com>, Jonathan Feinberg
<jdf@pobox.com> wrote:

+ tadmc@metronet.com (Tad McClellan) writes:

+ >   I have similarly stepped on my di^H^H... on a part of my anatomy
+ >   that is very painful to step on, in the past.

+ If I were physically able to do such a thing, I'd be in another line
+ of work entirely.

I believe you would pass out, due to low blood pressure in the rest
of the system...

James


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

Date: Wed, 27 Jan 1999 17:14:24 +0100
From: Richard Nilsson <qdtrini@jdicms88.ericsson.se>
Subject: Re: HELP - with redirect of STDERR and STDOUT
Message-Id: <36AF3B60.F8BCAC65@jdicms88.ericsson.se>

Ronald J Kimball wrote:

> [comp.lang.perl no longer exists]
>
> Richard Nilsson <qdtrini@jdicms88.ericsson.se> wrote:
>
> > What I need to do is to execute a command, and redirect STDOUT to my own
> > filehandle, and redirect SDTERR to another filehandle.
>
> This is an FAQ.  Please refer to perlfaq8.
>
> <http://language.perl.com/newdocs/pod/perlfaq8.html#How_can_I_capture_STDERR_from_an>
>
> --
>  _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
> ( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
>     /                                  http://www.ziplink.net/~rjk/
>         "It's funny 'cause it's true ... and vice versa."

Thank you for the hint. I made almost as the FAQ said, but my thought was to avoid
temporary
files (in C, you can dup STDERR and STDOUT to it's respective pipe). I used:

--------
 open(STDERR, ">/tmp/stderr.out");    # Redirect STDERR
 open (T1, "$defs::ct @_|");
 close (STDERR);

# And then I open my stderr.out file, and just read it normally

--------

Which is basically the same as the FAQ suggests.

Thanks,

/Richard Nilsson



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

Date: 27 Jan 1999 16:32:46 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Help a newbie with a custom shipping script?
Message-Id: <78nf3e$k9m$1@client2.news.psi.net>

mfrey@my-dejanews.com (mfrey@my-dejanews.com) wrote on MCMLXXV September
MCMXCIII in <URL:news:78lnsa$pjq$1@nnrp1.dejanews.com>:
~~ 
~~ I just started learning Perl last week in order to do this so go easy
~~ on me. Running Perl -w doesn't give me any real info--I know I'm not
~~ really using all the variables. What am I really doing wrong?
~~ 
~~ #  When I test this script with country = CA, it calculates shipping
~~ # fine for all weights less than 125. When the totalWeight is 125
~~ # or more, it returns a customShippingCost of 0. It seems to skip
                           ^^^^^^^^^^^^^^^^^^
~~ # the line below which is supposed to calculate the shipping for
~~ #  any totalWeight over 124 (ounces).
~~ 
~~    else { $customerShippingCost =
             ^^^^^^^^^^^^^^^^^^^^^
~~      ( $totalWeight * .13 ); }


Maybe you should have listened to -w after all. And a 'use strict'
should have helped as well.



Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'


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

Date: Wed, 27 Jan 1999 16:43:31 -0000
From: "Chris Denman" <c-denman@dircon.co.uk>
Subject: Help on deleting an item in an array?
Message-Id: <78nfgo$kva$1@starburst.uk.insnet.net>

I need to do this, but it is obviously wrong:

undef $fred[6];

$fred[6] needs to be completely erased, and all others shifted down.

Any ideas anyone?




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

Date: 27 Jan 1999 18:29:49 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: "Chris Denman" <c-denman@dircon.co.uk>
Subject: Re: Help on deleting an item in an array?
Message-Id: <m3hftcpqsy.fsf@joshua.panix.com>

"Chris Denman" <c-denman@dircon.co.uk> writes:

> $fred[6] needs to be completely erased, and all others shifted down.

   $ perldoc -f splice

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: 27 Jan 1999 17:29:14 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Help on deleting an item in an array?
Message-Id: <slrn7auj7a.hb8.sholden@pgrad.cs.usyd.edu.au>

On Wed, 27 Jan 1999 16:43:31 -0000, Chris Denman <c-denman@dircon.co.uk> wrote:
>I need to do this, but it is obviously wrong:
>
>undef $fred[6];
>
>$fred[6] needs to be completely erased, and all others shifted down.
>
>Any ideas anyone?

perldoc -f splice

-- 
Sam

Basically, avoid comments. If your code needs a comment to be
understood, it would be better to rewrite it so it's easier to
understand.	--Rob Pike


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

Date: Wed, 27 Jan 1999 11:20:22 -0600
From: Tom Briles <tbriles@austin.ibm.com>
Subject: Re: Help on deleting an item in an array?
Message-Id: <36AF4AD6.F54002@austin.ibm.com>

Chris Denman wrote:

> I need to do this, but it is obviously wrong:
>
> undef $fred[6];
>
> $fred[6] needs to be completely erased, and all others shifted down.
>
> Any ideas anyone?

perldoc -f splice

- Tom



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

Date: 27 Jan 1999 16:35:49 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: How could this NOT work?
Message-Id: <78nf95$k9m$2@client2.news.psi.net>

sara starre (webqueen@bol.net) wrote on MCMLXXV September MCMXCIII in
<URL:news:36AE930E.763D16EF@bol.net>:
:: Hi there-
:: 
:: OK I racked my tiny brain all night on this- how could this code NOT
:: work? This is my cgi:
:: 
::  my $fin= "../test/test.txt";
::  my $fout= "\>../test/test2";
::  open(NEW, $fin) || pmessage::SayError($fin, "old file");
::  open(OLD, $fout) || pmessage::SayError($fout, "new file");
:: 
:: If I put an invalid path in $fin, I sucessfully get an error message
:: (SayError generates an HTML error message). Then I correct the $fin
:: path,  but no matter what I do the second open causes the dreaded "The
:: Document contains no data" message.


Perhaps you should take a look at $!. 



Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


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

Date: 27 Jan 1999 16:20:59 GMT
From: khamer@halcyon.com (Kenneth Hamer)
Subject: Re: How long would the Unixes last without Perl?
Message-Id: <78nedb$26g$1@brokaw.wa.com>

dhosek@webley.com wrote:

: As for the HP inclusion of Perl, I found no indication that HP does ship the
: OS with Perl on their website & my last ocntract, where we were running HPUX
: didn't have Perl installed by default on any of the machines, although that
: could have just as easily been a side-effect of how the systems had been
: configured.

HPUX 10.20 does ship with perl4, in /usr/contrib.  If you don't install
the /usr/contrib stuff you won't see it, but it is on the OS CD.

- Ken

-- 
Oh My God!  They Killed init!  You Bastards!


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

Date: Wed, 27 Jan 1999 09:44:19 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: how to return multiple values in perl?
Message-Id: <j8cn87.9l.ln@magna.metronet.com>

scraig@my-dejanews.com wrote:
: In article <78l7v7$cge$1@nnrp1.dejanews.com>,
:   tariq.ahmed@usa.net wrote:

: > I want to return multiple values. And for simple types, I have no problem.
: > But I want to return a number, hash, and an array.

[snip correct explanation]

: Basically, a subroutine can only return one list. But there are ways around
: this.

: A subroutine can return a list of references ( which are scalars ) to arrays
: and hashes. But then the referenced objects have to be global.
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

   No they don't.


----------------------------------------
#!/usr/bin/perl -w
use strict;

my($a, $hashref, $arrayref)=doit();

my(%items_hash) = %$hashref;  # dereference and copy
my(@eachline) = @$arrayref;

foreach (@eachline) {print "$_\n"}      # use the copy
print "\n";

foreach (@$arrayref) {print "$_\n"}      # use the array ref directly
print "\n";

foreach (sort keys %items_hash) {       # use the copy
   print  "$_ ==> $items_hash{$_}\n";
}
print "\n";

foreach (sort keys %$hashref) {       # use the hash ref directly
   print  "$_ ==> $$hashref{$_}\n";
}


sub doit
{
    my(%myhash, @array);
    $myhash{"a"}="b";
    $myhash{"b"}="c";
    @array=("one","two","three");
    return(1, \%myhash, \@array);

}
----------------------------------------


   No referenced globals there...


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 27 Jan 1999 18:17:39 +0100
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Is s///ge non-reentrent? Or did I find a bug?
Message-Id: <m3k8y8prd8.fsf@joshua.panix.com>

AAron nAAs <anaas@funb.com> writes:

> The result is that the 'g' seems to lose its place and the regular
> expression seems to act up and find things incorrectly and
> completely miss other things.

Have you read about the \G zero-width assertion in perlop?  There's
also perlfaq6, "What good is \G in a regular expression?".

> I've attached the script which shows all of this,

> ID0gIk1BQ1JPMSAtLSBNQUNSTzIgLS0gTUFDUk8zIC0tIE1BQ1JPMSI7DQpwcmludCAiYmVm

I can't quite make that out.  I speak plain text.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Wed, 27 Jan 1999 10:02:22 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Is this possible?
Message-Id: <eadn87.9l.ln@magna.metronet.com>

Jim Matzdorff (syran@best.com) wrote:
: I have a hash that has subroutine names defined in it (or at least, this
: is what I *want* to be able to do)

: %subs = (
: 	sub1	=> "ThisSub()",
: 	sub2	=> "AnotherSub()",
: 	sub3	=> "CoolSub()",
: 	sub4	=> "NotSoCoolSub()",
: 	)


   You probably want to change those to be code references.

   Search for 'coderef' in the 'perlref.pod' man page.

   This is commonly known as a "dispatch table". Search for that
   at www.dejanews.com to see an example posted here just last week.


: these subroutines live in files that aren't in main, that are required
: into as they are called, or at least that's what I want to do.


   perldoc AutoLoader

   might help with that part.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 27 Jan 1999 16:41:56 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Is this possible?
Message-Id: <78nfkk$k9m$3@client2.news.psi.net>

Jim Matzdorff (syran@best.com) wrote on MCMLXXV September MCMXCIII in
<URL:news:78lv8u$f4d$1@shell18.ba.best.com>:
 .. I have a hash that has subroutine names defined in it (or at least, this
 .. is what I *want* to be able to do)
 .. 
 .. %subs = (
 .. 	sub1	=> "ThisSub()",
 .. 	sub2	=> "AnotherSub()",
 .. 	sub3	=> "CoolSub()",
 .. 	sub4	=> "NotSoCoolSub()",
 .. 	)
 .. 
 .. these subroutines live in files that aren't in main, that are required
 .. into as they are called, or at least that's what I want to do.
 .. 
 .. For instance, if ThisSub() is in "sub1.pm" then i only want to require
 .. "sub1.pm" if ThisSub() is called.  ie:
 .. 
 .. if ($subs{sub1})
 .. {
 .. 	require "sub1.pm";
 .. 	&subs{sub1};
 .. }
 .. 
 .. Now, to get a little tricker, I also want to have the following hash:
 .. &requires = (
 .. 	sub1	=> "sub1.pm",
 .. 	sub2	=> "sub1.pm",
 .. 	sub3	=> "sub2.pm",
 .. 	sub4	=> "sub2.pm",
 .. 	)
 .. 
 .. So now I can say...
 .. 
 .. if ($subs{sub1})
 .. {
 .. 	require $requires{sub1};
 .. 	&subs{sub1}
 .. }


%subs = (
    sub1   =>   ["sub1.pm"  =>  "ThisSub"],
    sub2   =>   ["sub1.pm"  =>  "AnotherSub"],
    sub3   =>   ["sub2.pm"  =>  "CoolSub"],
    sub4   =>   ["sub2.pm"  =>  "NotSoCoolSub"],
)

if (exists $subs {$sub}) {
    require $subs {$sub} -> [0];
    &{$subs {$sub} -> [1]} (@whatever);
}



Abigail
-- 
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


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

Date: Wed, 27 Jan 1999 17:35:59 GMT
From: ears@dania.dialisdn.com (Ears)
Subject: Re: Jesus Rides a HOG(tm) : was :CONCLUSIVE PROOF: The Beatles are bigger than Jesus!
Message-Id: <slrn7at9om.1p8.ears@dania.dialisdn.com>

On Wed, 27 Jan 1999 05:41:42 -0500, grendal <grendal@buffnet.net> wrote:
>Take sci.astro.amateur out of your list...or start posting something related.
>Astro and riding aren't that far apart, unless you're a dip shit.
>My 21 year old rebuilt honda cb 750 will tool you insignificant fuckers anyway.
>Not saying I don't want a harley, but what am I supposed to do, kill
>one of you? (Easier done then said, but you can't see the stars from
>jail.)  You probably don't ride anyway.  If you want to debate the facts,
>email me, you bloated jackass. (Or even better...
>actually, I like this NG too much to go on.)   Always good to have
>my theory proven, genetics are in fact working in reverse.  

>> BTW, this thread is no longer being posted to rec.games.video.nintendo.
>> If you don't want this posted to your newsgroup either, reply to us here
>> at rec.motorcycles.harley, and we will be glad to take it out of the
>> header for you. Unless of course, you're smart enough to do it yourself
>> before you repost.

Believe it or not, this guy wasn't smart enough. To add to the dilemma, his
newsgroup happened to be the first one in line. If this guy thinks I'm gonna
e-mail him when he can't maintain his posts himself, he's got a screw loose.
I can't imagine what his honda must look like. I don 't get that remark about
killing one of us either. Like, he can't just buy one instead ?

http://www.skyway99.com/freeharleyads.htm has Harleys for sale. So save your 
bullets.


-- 
 *Ears*  98 XL 1200 Custom   
     kd4zkw@amsat.org
 http://www.dialisdn.net/user/cdlevin


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

Date: Wed, 27 Jan 1999 17:04:05 +0000
From: imran <imran@orangenet.co.uk>
Subject: Re: login script with perl !
Message-Id: <36AF4705.5877898B@orangenet.co.uk>

try usig libnet package from cpan site..
imran

kurtje@my-dejanews.com wrote:

> In article <369CC686.E9DB743F@ip-plus.net>,
>   Patrick <ammann@ip-plus.net> wrote:
> > Hi,
> >
> > I'm really new and I don't know much about perl programming.
> > My problem is that i have to write a script witch should do the
> > following. I have a few routers and i have do do some commands to all of
> > them. I also have a list witch is formated likethe following one:
> >
> > IP-Adress    Hostname
> > IP Adress    Hostname
> >
> > The point is that i have to login to ech router and make a "show
> > version" and "show mem". Then i need to analyse the output.
> >
> > If you already have a script that does the described thing please e-mail
> > it to ammann@ip-plus.net. If you can give me some information on how to
> > make a telnet connection with perl please let me know also.
> >
> > Many thanks in advance.
> >
> > Patrick
> >
> >
>
> I am looking for the same so please help me
>
> Kurtje,
>
> kurt.baetens@unisource.be
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own



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

Date: Wed, 27 Jan 1999 16:32:46 +0000
From: 23_skidoo <23_skidoo@geocities.com>
Subject: Re: Newbie Question
Message-Id: <36AF3FA3.6D99@geocities.com>

cba wrote:
> 
> Hi there...
> 
> i have a simple program :
> 
> @a = ('one ',' two',' three);
> $count = @a;
> for ($i = 0; $i < $count;) {
> print @a[$count++];
> }

i think you have a badly flawed program.
i can strongly recommend you take a long look at 

http://WDVL.com/Authoring/Scripting/Tutorial/toc.html 

and get your head round a few basics before ploughing in any further.

-23


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

Date: Wed, 27 Jan 1999 11:10:07 -0600
From: Tom Briles <tbriles@austin.ibm.com>
Subject: Re: Newbie Question
Message-Id: <36AF486F.63A1F358@austin.ibm.com>

cba wrote:

> Hi there...
>
> i just started doing some programming in Perl and have the following question...
>
> i have a simple program :
>
> @a = ('one ',' two',' three);
> $count = @a;
> for ($i = 0; $i < $count;) {
> print @a[$count++];
> }
>

We can't answer a question until you post real code.

The code above obviously doesn't work.

1) No matching quote on 'three
2) $i is never incremented
3) An array element is referred by $array[0], not @array[0]

I'm guessing you meant something like:

#!/usr/local/bin/perl -w

@a = ('one','two','three');
$count = @a;
for ($i = 0; $i < $count;) {
     print "$a[$i++]\n";
}

If you have real, working code, it's best to cut-and-paste.

- Tom



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

Date: Wed, 27 Jan 1999 08:19:49 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl Criticism
Message-Id: <MPG.1118dc7a9147f8529899d1@nntp.hpl.hp.com>

In article <slrn7au5am.ivr.dformosa@godzilla.zeta.org.au> on 27 Jan 1999 
13:32:07 GMT, David Formosa (aka ? the Platypus) <dformosa@zeta.org.au> 
says...
 ...
> However optimisations like this have a magour impact in code running
> time and useablity.  if ($a != 0 and $b/$a>10) { is not something that
> I can do without.

Certainly you could do without it, as all it is is a sequence of 
decisions:

    if ($a != 0) {
        if ($b/$a > 10) {

>                     Indeed I would argue that given that these are
> quite commen in most langages most programers will be expecting them
> and therefore a lanague without them would be more confising.

Compound conditionals are indeed common and convenient.  But they are 
not indispensable.  If one were designing a bare-bones, TIOOWTDI 
language, one could leave them out, but not without some pain.

Consider this snippet:  Assign the first TRUE result of a set of 
alternative, costly computations (possibly with side effects), or a 
default:

    $x = f() || g() || h() || $y;

This is beautiful, spare, clean Perl (but not C, by the way, where the 
result would be a Boolean!).  The following is both Perl and C (ignoring 
variable-naming syntax):

    $x = ($t = f()) ? $t : ($t = g()) ? $t : ($t = h()) : $y;

Ouch.  Now try that again in a language that doesn't have conditional 
expressions either:

    if ($t = f()) {
        $x = $t;
    } elsif ($t = g()) {
        $x = $t;
    } elsif ($t = h()) {
        $x = $t;
    } else {
        $x = $y;
    }

As you can see, it gets 'old' really fast.  But it certainly can be 
done, and even in assembly language, God forbid!

Remember the 'Perl baby talk' metaphor in the introduction to the Blue 
Camel (and probably elsewhere)?  Fortunately Perl lets those who are 
able to do so talk 'adult talk' also.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 27 Jan 1999 08:25:04 -0800
From: Jerome O'Neil <jeromeo@atrieva.com>
Subject: Re: Perl Criticism
Message-Id: <36AF3DE0.73455051@atrieva.com>

topmind@technologist.com wrote:

> > That still draws more attention to the error instead of to the opening
> > of the file.
> 
> How so? Because it starts with an IF statement?
> 
> To me it seems silly to invent multiple variations of IF's
> to improve readability by 5%.

So you admit that the perl model is more readable, and therefore more
maintainable.

Now go away.


-- 
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947 
The Atrieva Service: Safe and Easy Online Backup  http://www.atrieva.com


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

Date: Wed, 27 Jan 1999 16:36:38 GMT
From: droby@copyright.com
Subject: Re: Perl error/exception strings...
Message-Id: <78nfal$6lf$1@nnrp1.dejanews.com>

In article <36ae28aa.0@news2.uswest.net>,
  "Olson, D. A." <dolson093@sprintmail-ns.com> wrote:
> I am currently up to my ears in design documentation, and need to finish up
> a section on error handling / codes.  In a nutshell, I need to get a list of
> all possible error/exception strings produced by Perl if possible ( via $!
> and $@ ).  Does such a list exist?  We have designed the handling to be via
> eval and at times in conjunction w/die, so the customer needs a list of
> possible error strings.  Any help would be greatly appreciated... I searched
> the FAQs and dejanews to no avail.
>

strings `which perl`

Unfortunately, that shows a few strings more than you're after...

The possible $@ strings must be in the source tree somewhere, but I don't
know if they're all in a single table or scattered.  And I've no idea where
to look. Perhaps someone else can help here.

But $! is easy.  You can set it in numeric context, and view it in string
context, as in

perl -e'foreach (1..255){$!=$_;print"$_ : $!\n"}'

which goes way past where there seem to actually be any assigned meanings at
least in my system.

--
Don Roby

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 27 Jan 1999 18:13:00 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: 23_skidoo@geocities.com
Subject: Re: please help: outputting line number to display
Message-Id: <m3n234prkz.fsf@joshua.panix.com>

23_skidoo <23_skidoo@geocities.com> writes:

> is there a way to get perl to output the line number it is executing
> at any given point so i don't have to change these by hand?

   $ perldoc -f warn
   $ perldoc -f die

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Wed, 27 Jan 1999 16:04:47 GMT
From: Denis.Haskin@bigfoot.com
Subject: Q: CPAN on Win32 (Windows NT) Perl
Message-Id: <78ndeo$4n5$1@nnrp1.dejanews.com>

Does anyone have recommendations on getting CPAN to work well on Win32
(Windows NT) Perl (the standard perl, 5.005.02, not the ActiveState version)?

I've got CPAN 1.47 (the latest), but the stumbling block appears to be tar
and gzip.  I've got external zip program(s) that know how to handle tar and
gzip files (e.g. pkzip 2.50 command line) but CPAN appears to be trying to
send only the standard options (e.g. -decompress), which pkzip doesn't grok.

An alternative would be to have tar and gzip programs that obey the usual
Unix command line options--anyone have any good recommendations of where to
find such beasts for NT (yes, I suppose I could just buy them from MKS)?

I believe another alternative would be to install Archive::Tar and
Compress::Zlib myself, and have CPAN use those instead of the external
programs (there seems to be indications it will do that), but so far I'm a
little hung up getting Compress::Zlib to build (although I may be able to
resolve that yet).

But I find it hard to believe I'm the first person trying to do this.  Any
recommendations?

Much thanks,

dwh

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 27 Jan 1999 16:35:32 GMT
From: mgrimes@my-dejanews.com
Subject: Q: use vs. require
Message-Id: <78nf8k$6dt$1@nnrp1.dejanews.com>

I am trying to use my own modules in a perl script which have
been placed in a non-standard directory. I have been using
the "use lib <directory>;" to add the non-standard path to @INC,
but now since I'm developing the script on one platform and
running them on another, I want the <directory> to be a variable
rather than static.

Unfortunately, since "use" is interpretted at compile time, the
variable I'm using for <directory> doesn't get parsed. It appears
the only way around this is using "require" instead, but I'm not
really sure what problems will arrise.

According to the perl documentation, other than being interpretted
at runtime rather than compile time, require also won't "import
symbols and semantics from the package to the current one," and I'm
not sure of the practical ramifications. I don't think I want to
import any symbols (all the module does is define a class), but
what about symantics? I would think that would be an integral part
of the module.

Anyway, I have already tried it and it appears to work, but I'm
still a little suspect. Any clarificaton of the difference?
Thanks in advance.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 27 Jan 1999 17:19:36 -0000
From: "Artoo" <r2-d2@REMOVEbigfoot.com>
Subject: Removing New Lines in Form Fields
Message-Id: <78nhvh$9hu$1@plug.news.pipex.net>

Hi All

How can you remove all new lines that are entered in a form?  I've tried the
following which works but still leaves a block in it's place.

  read(STDIN, $input,$ENV{'CONTENT_LENGTH'});
  @pairs = split(/&/, $input);
  foreach $pair (@pairs) {
   ($name, $value) = split(/=/, $pair);
   $name =~ tr/+/ /;
   $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
   $value =~ tr/+/ /;
   $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
   $value =~ s/\n/ /g; ####### This should take out New Lines But it leaves
a block!!!
   $IN{$name} = $value;
  }

Is there another method that doesn't leave a return block in its place.
Thanks for any help
Artoo




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

Date: Wed, 27 Jan 1999 17:28:49 -0000
From: "Chris Denman" <c-denman@dircon.co.uk>
Subject: Re: Removing New Lines in Form Fields
Message-Id: <78ni5q$m1b$1@starburst.uk.insnet.net>

I could be wrong, but I think at the end of the line there is more than just
\n

Try \n\r together or \r\n (can't remeber which way round)

Chris D





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

Date: Wed, 27 Jan 1999 11:04:46 -0500
From: Ben Smith <bsmith@perf.zko.dec.com>
Subject: Re: sorting dates
Message-Id: <36AF391D.888D7DAC@perf.zko.dec.com>

Randal L. Schwartz wrote:

> But a Schwartzian[1] Transform (or something similar) should be used
> instead of all those splits inside the subr.
I'm getting old and slow. This is the second time in two days that my
understanding of Perl has shown up as obsolete. I take it you are
refering
to the use of map as the Schwartzian Transform? You know, I never
noticed
map before. Thanks Mssr. Schwartz.
-- 
work: bsmith@perf.zko.dec.com = Ben Smith = ZKO2-3R55 = 603-884-2836 
home: ben@roninhouse.com = 603-924-4131 = FAX: 603-924-3582


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

Date: Wed, 27 Jan 1999 11:03:48 -0500
From: John Chambers <jc@uwm-dev.gte.com>
Subject: Re: system function, Pros and Cons??
Message-Id: <36AF38E4.E6E09E90@uwm-dev.gte.com>

Tom Christiansen wrote:
> 
> Plus, doing it this way doesn't require the obscene rigamarole that you
> would need to include proper support for multi-threaded, object-oriented,
> persistent, distributed, platform-independent, and language-neutral (i18n)
> support in your module, complete with transparent access via Java RMI
> and as a COM object -- the way the frothing fanantics keep espousing.
> These poor deluded folks constitute a cult of complexity, one whose
> credo breeds fragile overengineering and inscrutable overabstraction.
> 
> Please don't encourage them.

Well, there's the old story about the debate over whose occupation
was the oldest.

The surgeon claimed his professin the oldest, and quoted the
story of God removing one of Adam's ribs and fashioning a woman
from it.

The engineer objected that his profession was the oldest, pointing
out that earlier God had built the world out of chaos.

Then the computer scientist spoke up and asked "But who do you
think created the chaos?"

(This is also told as a lawyer joke.)


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

Date: Wed, 27 Jan 1999 10:15:40 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: system function, Pros and Cons??
Message-Id: <c3en87.9l.ln@magna.metronet.com>

Jeff Hester (jeff@toad.net) wrote:
: I'm reposting this do to errors I received the first time.  Hopefully
: I'm not doubling up the posts  (if so except my apologies before hand)


   s/except/accept/     ;-)


: A coworker of mine (who is a much more experienced perl person than
: myself) Took a look at it and informed me that I "Should never use
: system()".  


   "never" is pretty strong.

   I would amend that to:

      "never 'shell out' (system(), qx//, and pipe open) for
       something that can be done from within Perl itself"


   And there are a whole lot of things that you can do from
   within Perl itself.


: I called allot of unix commands through this and they seemed
: to work just fine.  


   It passes the Ultimate Test of Correctness then  :-)


   If you tell us what you use it for, we might be able to
   suggest how to avoid the extra process(es) or how to
   use it more safely...


: Unfortunately he couldn't give me a good reason why
: I shouldn't use that function.


   It is a resource pig, because it spawns a whole new process.

   Processes are expensive.

   Probably doesn't matter much if this is a "standalone" program
   that you run once in a while.

   Probably matters a whole bunch if it is a CGI program at
   a popular site, where dozens or hundreds of copies of your
   program are all running at once.


: Does anyone know if "system" is faulty in some way?  why would you not
: want to use it???


   Since they spawn (or can spawn anyway) a shell, they can
   be a security risk.

   See the 'perlsec.pod' man page.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 27 Jan 1999 10:30:49 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: system function, Pros and Cons??
Message-Id: <36af4d49@csnews>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, tadmc@metronet.com (Tad McClellan) writes:
:   I would amend that to:
:      "never 'shell out' (system(), qx//, and pipe open) for
:       something that can be done from within Perl itself"

Perl is a Turing-complete language (given infinite memory, of course).
Therefore, all things can be done in Perl.  

Why parse the output of netstat?  Since you can obviously parse the
contents of /proc/net or seek around in /dev/kmem all by yourself, why
don't you?  If you want to send something to the printer daemon, there's
no reason to call lpr since you can just open /dev/printer on your own
system and mumble the right protocol at it.  And if you want to send mail,
with MX lookups, queueing, and fallback, there's no reason to call mail
transport agent.  You can be that agent.  Just do the raw socket stuff.

Obviously, these are silly.  

Just because all things are possible does not mean that all things are
expedient.  Laziness demands the expedient, like using existing tools
and not reinventing the wheel gratuitously as so many seem wont to do.
Willful ignorance of the system is a false idol -- worship it not.

But I think you know all that, Tad.  This missive is for a broader
audience.

--tom
-- 
Procedure names should reflect what they do; function names should reflect
what they return. --Rob Pike


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

Date: 27 Jan 1999 17:54:41 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: system function, Pros and Cons??
Message-Id: <78njt1$6bf$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Tom Christiansen 
<tchrist@mox.perl.com>],
who wrote in article <36af4d49@csnews>:

[This argument is repeated again and again, but today I do not feel
well, so cannot do much more than refute sick arguments.  And I
replied two Tom's postings already ;-). ]

> Perl is a Turing-complete language (given infinite memory, of course).
> Therefore, all things can be done in Perl.  

Turing machines have nothing to do with computers.  Most things Perl
do involve interaction with the outside world, thus cannot be done
with Turing machines.

Even if you think of your file system as a region on (one of?) the
Turing machine tape(s), where would you put the link counts?  The
system clock?  How would a Turing machine TAB-complete user input?
Decrease the loudness of your sound card?

It may be interesting to coin a name for a CS abstraction which
matches the *needs* of current programming, but a Turing machine is
not one.

Ilya


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

Date: 27 Jan 99 16:12:25 GMT
From: uj797@victoria.tc.ca (Arthur T. Murray)
Subject: The Art of Computer Mindmaking
Message-Id: <36af3ae9.0@news.victoria.tc.ca>
Keywords: artificial intelligence, mentifex, pdai, pdaimind, robotics 

Using any viable language to code the minimal pdaimind:

  /^^^^^^^^^^^\ Mind-grid Arrays{ } in Robot PDAI /^^^^^^^^^^^\      
 /visual memory\                   _________     /  auditory   \
|      /--------|---------\       / LANG-UK \   |   memory      |
|      |  recog-|nition   |       \_________/---|-------------\ |       
|   ___|___     |         | flush-vector|       |   ________  | |
|  /image  \    |     ____V_        ____V__     |  /        \ | |
| / percept \   |    /psi{ }\------/ uk{ } \----|-/ ear{ }   \| |  
| \ engrams /---|---/concepts\----/ lexicon \---|-\ phonemes /  |     
|  \_______/    |   \________/    \_________/   |  \________/   |

Checklist of steps in coding or porting the PDAIMIND

___ Step 001:  In your intended programming language, first make
sure that the language will permit you to write a never-ending program
that endlessly performs its own computations while only occasionally or
periodically checking for input from a human user or from another AI.

___ Step 002:  Familiarize yourself with the information flow in the
mind-diagram above.

___ Step 003:  Create a Web page where you will release each new level
of PDAI functionality for the benefit of history and of other individuals
working in your target programming language.

___ Step 004:  Write some code for getting the input of ASCII characters
from the keyboard.  Although AI programs which go beyond the basic,
minimal pdaimind will need to use speech recognition for the input of
actual phonemes of continuous human speech, the pdaimind as an example
for other AI programs will make do with simple keyboard text-entry.  The
http://www.geocities.com/Athens/Agora/7256/m-forth.html Mind.forth
AUDITION Screen #9 shows an implementation in Forth with Comments on
AUDITION Scr #9 available to show how audition is handled.
   
___ Step 005:  Directly from the World Wide Web, print out your current
Internet Web Release as a working document.  Freely mark up the hardcopy
with corrections, algorithm ideas, URL's, etc., until you have coded
enough new functionality to warrant a new, up-to-date Web release.
   
___ Step 006:  Create an array such as ear{ } to store the keyboard
text entry.
   
___ Step 007:  Write code for a Comparator which will recognize words
already stored in the PDaiMind.
   
___ Step 008:
--
http://www.geocities.com/Athens/Agora/7256/perl.html


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

Date: 27 Jan 1999 18:28:38 +0100
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: The Art of Computer Mindmaking
Message-Id: <m3iudspqux.fsf@joshua.panix.com>

uj797@victoria.tc.ca (Arthur T. Murray) writes:

> Using any viable language to code the minimal pdaimind:
[snip]

Ooh, another Dr. Bronner's Soap Post!

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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