[17387] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4809 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 4 09:10:21 2000

Date: Sat, 4 Nov 2000 06:10:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <973347011-v9-i4809@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 4 Nov 2000     Volume: 9 Number: 4809

Today's topics:
    Re: Perl syntax and beyond (was: Re: Perl style and mod <james@NOSPAM.demon.co.uk>
    Re: Perl syntax and beyond (was: Re: Perl style and mod (Gwyn Judd)
    Re: Perl syntax and beyond (was: Re: Perl style and mod <bart.lateur@skynet.be>
    Re: Perl syntax and beyond (was: Re: Perl style and mod (Gwyn Judd)
    Re: Problems Downloading a Web Page <gellyfish@gellyfish.com>
    Re: Quick newbie question:  Perl fork() and signals on  <gellyfish@gellyfish.com>
    Re: String manipulation?? <james@NOSPAM.demon.co.uk>
    Re: two dimensional arrays <adancygier@nyc.rr.com>
    Re: Unix commands via perl? (Gwyn Judd)
    Re: Unix commands via perl? <jeffp@crusoe.net>
    Re: Want to process all files less than 24 hours old <abe@ztreet.demon.nl>
    Re: Want to process all files less than 24 hours old <abe@ztreet.demon.nl>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 4 Nov 2000 09:40:40 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Perl syntax and beyond (was: Re: Perl style and module searches)
Message-Id: <ant040940868fNdQ@oakseed.demon.co.uk>

In article <slrn906u1r.fn7.tjla@thislove.dyndns.org>, Gwyn Judd
<URL:mailto:tjla@guvfybir.qlaqaf.bet> wrote:
>
> I was shocked! How could Bart Lateur <bart.lateur@skynet.be>
> say such a terrible thing:
> 
> > Gwyn, in what way would you like to see Perl go "even further"?
> 
> Well how about a linked list data type for a start? I think it would be
> useful to have one as a built in type. I know it is possible to create
> one using references but the thing about having it as a built in means
> it is simpler for everyone to use. Having a linked list type is useful
> when you are wanting to add or delete items in the middle of an array.

So in what way does splice() on an array (of scalars or references to
more complex objects) not perform the function you want?

-- 
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02



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

Date: Sat, 04 Nov 2000 11:22:21 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Perl syntax and beyond (was: Re: Perl style and module searches)
Message-Id: <slrn907sba.h71.tjla@thislove.dyndns.org>

I was shocked! How could James Taylor <james@NOSPAM.demon.co.uk>
say such a terrible thing:
>> it is simpler for everyone to use. Having a linked list type is useful
>> when you are wanting to add or delete items in the middle of an array.
>
>So in what way does splice() on an array (of scalars or references to
>more complex objects) not perform the function you want?

Well addition or deletion in a linked list is O(1) whereas splice is
O(n). So if you are going through the list one by one and adding or
deleting items one by one then it will be quicker to do so using a
linked list rather than an array.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
My mind is made up, don't confuse me with the facts!

		-- Unknown


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

Date: Sat, 04 Nov 2000 12:41:37 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Perl syntax and beyond (was: Re: Perl style and module searches)
Message-Id: <rp080tcuiumc6qc62rmnfvr2vff124ogr2@4ax.com>

Gwyn Judd wrote:

>>So in what way does splice() on an array (of scalars or references to
>>more complex objects) not perform the function you want?
>
>Well addition or deletion in a linked list is O(1) whereas splice is
>O(n). 

Is it? I thought accessing an element in a linked list is O(n) (while
for arrays, it's O(1)) Therefore, if you need to locate an item in a
linked list first before deleting it, or inserting something right after
it, that must be O(n), too. (Inless there is some hashy structure, or a
binary tree, or such, pointing inside  the tree. That's O(log n), at
best, I guess.)
 
Anyway, this distinction between arrays and linked lists is too low
level for me. I have no complaints about Perl's speed, so I only
concentrate on the syntax.

-- 
	Bart.


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

Date: Sat, 04 Nov 2000 13:24:21 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Perl syntax and beyond (was: Re: Perl style and module searches)
Message-Id: <slrn9083g3.h71.tjla@thislove.dyndns.org>

I was shocked! How could Bart Lateur <bart.lateur@skynet.be>
say such a terrible thing:
>Gwyn Judd wrote:
>
>>>So in what way does splice() on an array (of scalars or references to
>>>more complex objects) not perform the function you want?
>>
>>Well addition or deletion in a linked list is O(1) whereas splice is
>>O(n). 
>
>Is it? I thought accessing an element in a linked list is O(n) (while
>for arrays, it's O(1)) Therefore, if you need to locate an item in a
>linked list first before deleting it, or inserting something right after
>it, that must be O(n), too. (Inless there is some hashy structure, or a

You deleted what I said afterwards. Sure if you have to find the element
then there is no advantage but (as I said) if you are traversing the
list then insertion and deletion at that point is O(1).

>Anyway, this distinction between arrays and linked lists is too low
>level for me. I have no complaints about Perl's speed, so I only
>concentrate on the syntax.

Well I think extending the syntax to have a linked list data type would
be nice.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
It takes little strain and no art
To bang out an echoing fart.
	The reaction is hearty
	When you fart at a party,
But the sensitive persons depart.


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

Date: 4 Nov 2000 11:55:29 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Problems Downloading a Web Page
Message-Id: <8u0tfh$ffv$1@orpheus.gellyfish.com>

On Fri, 03 Nov 2000 15:12:12 GMT REMOVEdino@texas.net wrote:
> I am trying to learn Perl and the first thing I wanted to do was
> download a Web page.  The following:
> 
> use LWP::Simple;
> getprint 'http://www.perl.com';
> 
> returns 500 Can't connect to http://www.perl.com:80 (Bad protocol
> 'tcp')
> 
> I'm using Active States's Win32 build on a Win NT networked machine.


you are missing your 'protocols' file which should be in somewhere in your
%WINDIR% - you will need to have at least :

ip      0       IP              # internet protocol, pseudo protocol number
icmp    1       ICMP            # internet control message protocol
tcp     6       TCP             # transmission control protocol
udp     17      UDP             # user datagram protocol

In it I would say.  If you have difficulty determining where the file
should be or how you would create it you would be better off asking in 
some newsgroup that discusses the NT operating system.

I think the behaviour of the Win32 port changed between the 5* and 6* builds.

/J\
-- 
Jonathan Stowe                      |     
<http://www.gellyfish.com>          |      This space for rent
                                    |


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

Date: 4 Nov 2000 11:58:25 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Quick newbie question:  Perl fork() and signals on NT?
Message-Id: <8u0tl1$fjc$1@orpheus.gellyfish.com>

On Fri, 03 Nov 2000 14:18:43 GMT David Sisk wrote:
> Do the perl constructs like fork(), wait(), exec(), system(), and the signal
> handling constructs work on NT as well as unix? I realize those don't exist
> natively in NT, but does the Perl executable fabricate them?   I need to
> develop a process on NT, but I want to do it so that it will work on unix
> because that's where it will be run eventually.
> 

There is a document distributed with the Activestate distribution that
describes the differences between the Win32 port and the Unix version.

/J\
-- 
Jonathan Stowe                      |     
<http://www.gellyfish.com>          |      This space for rent
                                    |


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

Date: Sat, 4 Nov 2000 09:33:27 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: String manipulation??
Message-Id: <ant040927b49fNdQ@oakseed.demon.co.uk>

In article <slrn906kk3.ac5.mgjv@martien.heliotrope.home>, Martien Verbruggen
<URL:mailto:mgjv@tradingpost.com.au> wrote:
>
> On Fri, 3 Nov 2000 22:39:04 +0000,
>     James Taylor <james@NOSPAM.demon.co.uk> wrote:
> > 
> > Aha, I didn't know that that implicitly passed @_ down as the
> > parameters of &bar. In fact, I would have expected your &bar to get no
> > parameters. Can anyone supply a Camel reference for this behaviour?
> 
> perlsub
> 'Subroutines may be called recursively ...'
> 
> Camel 2, top of page 112

Wow, I wonder how I managed to miss that on first reading.
Perhaps my mind filtered it out subconsciously judging it
to be an unimportant nuance of an outdated calling mechanism.
I see now, that the & calling mechanism has its uses.

> Camel 3, top of page 222

And there it is again even more clearly stated. Thanks.
I seem to learn something new every day from this group. :-)

-- 
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02



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

Date: Sat, 04 Nov 2000 06:56:58 GMT
From: Aaron Dancygier <adancygier@nyc.rr.com>
Subject: Re: two dimensional arrays
Message-Id: <3A03B305.751124BE@nyc.rr.com>

Try this as an outlline
my @array = ([$lname, $fname, $minit, $suffix, $prefix, $title,$affiliation]);
to add just push(@array, [$lname, $fname, $minit, $suffix, $prefix,
$title,$affiliation]);
this is actually an array of anonymous array references;
@array = ([1, 2, 3] [4, 5, 6] [7,8, 9]);
is a 3x3 array where item $array[0][0] is 1 [0][1] is 2 [0][2] is  3
[1][0] is 4 etc.

if you simply push all elements into that array as a regular array you will
just end up with a longer one dimensional arrray
@array = (@array1, @array2); will simply extend a one dimensional array;

Brian McDonald wrote:

> Hi. (I hope the following is not too much info to swallow...)
>
> I have a question about how to implement a two-dimensional array in Perl.
> Specifically, what I am trying to do is create an array named @authors that
> is composed of elements of type @author, where @author is defined to be
>
> my @author = ( $lname, $fname, $minit, $suffix, $prefix, $title,
> $affiliation, );
>
> So, I imagine I want to declare @authors in this way...
>
> my @authors = (
>     @author,
> );
>
> I will have to grow @authors at run-time.
>
> The data for @authors will be coming from a CSV file that has a rather
> complex structure (Note: I'm using the Text::CSV_XS module). The syntax of
> the "authors" field looks like this:
>
> "author1|author2|author3|...|authorN"
>
> and the syntax of the "author" sub-fields looks like this:
>
> lname,fname,minit,suffix,prefix,title,affil
>
> I've declared the following CSV objects to handle the parsing of the
> "authors" and "author" fields:
>
> ------------------------
> # create a new CSV object for the author sub-fields
> my $objCSVAuthors = Text::CSV_XS->new({
>  'quote_char' => '',
>  'sep_char' => '|',
>  'binary' => 1
> });
>
> # create a new CSV object for the name components sub-field
> my $objCSVAuthor = Text::CSV_XS->new({
>  'quote_char' => '',
>  'sep_char' => ',',
>  'binary' => 1
> });
> -------------------------
>
> The first thing I do is read in one record from the CSV file, parse it, and
> put all the fields in the @field array. $field[8] holds the value in the
> "authors" field. Then I parse the "authors" field in this manner...
>
>    # parse the "authors" field in order to get at the "author" sub-fields
>    #
>     if ($objCSVAuthors->parse($field[8])) {
>         my @authors_field = $objCSVAuthors->fields;
>
> So, @authors_field is an array of the unparsed "author" sub-fields. Next, I
> size the @authors array based on the number of "author" sub-fields...
>
>         # size the @authors array
>         #
>         $size = scalar(@authors_field);
>         @authors = (0) x $size;
>
> Then, I increment the x-dimension index of the 2D array (initialized to 0
> earlier)...
>
>         $nn++;
>
> Finally, I loop over...
>
>         # loop over each element in @author_field (i.e. each "author"
> sub-field)
>         # and initialize the @authors array
>         #
>         for ($y = 0; $y < $size; $y++) {
>             # parse this "author" field into the @authors array
>             #
>             if ($objCSVAuthor->parse($authors_field[$y])) {
>             @author = $objCSVAuthor->fields;
>             $authors[$nn][$y] = \@author;
>             }
>             $nn++;
>         } # end for
>     }
>
> But, I get the following error:
>
> "Can't use string ("0") as an ARRAY ref while "strict refs" in use at
> txt2xml.pl line 839, <CSV> line 1."
>
> It is possible that I am either screwing up on my understanding of
> multi-dimensional arrays or dereferencing in Perl... or both. But I am going
> cross-eyed trying to debug my problem...
>
> Any help appreciated!
>
> Brian



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

Date: Sat, 04 Nov 2000 12:59:43 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Unix commands via perl?
Message-Id: <slrn90821t.h71.tjla@thislove.dyndns.org>

I was shocked! How could Wyzelli <wyzelli@yahoo.com>
say such a terrible thing:
>"Tom Christiansen" <tchrist@perl.com> wrote in message
>news:3a017bd3$1@cs.colorado.edu...
>>
>> How many licks does it take to get to the center of a tootsie pop?
>>
>
>Doesn't the centre keep moving as you lick so you never actually get there?

On behalf of all the mystified non-merkins: What's a tootsie-pop?

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Q:	How do you stop an elephant from charging?
A:	Take away his credit cards.


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

Date: Sat, 4 Nov 2000 08:36:09 -0500
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Unix commands via perl?
Message-Id: <Pine.GSO.4.21.0011040835120.25313-100000@crusoe.crusoe.net>

On Nov 4, Gwyn Judd said:

>>> How many licks does it take to get to the center of a tootsie pop?
>>
>>Doesn't the centre keep moving as you lick so you never actually get there?
>
>On behalf of all the mystified non-merkins: What's a tootsie-pop?

Gwyn, just how many of the readers of clpm do you think are merkins?!  Are
the non-merkins all quims? ;)

A tootsie-pop is a round lollipop with a tootsie roll (chewy candy) in the
center.

-- 
Jeff "japhy" Pinyan     japhy@pobox.com     http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/
CPAN - #1 Perl Resource  (my id:  PINYAN)        http://search.cpan.org/



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

Date: Sat, 04 Nov 2000 12:22:12 +0100
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Want to process all files less than 24 hours old
Message-Id: <gkr70tgiirnr3fiellj3mtc2k9tpdvfu5q@4ax.com>

On Fri, 03 Nov 2000 12:59:56 -0800, Mark Thompson
<mark-lists@webstylists.com> wrote:

 ...
> One question I have is that split the cookie variable into multiple
> items by semi-colon because that's how it gets split up by the browser
> and then had it search each individual cookie separately.  If the
> cookie is in the form:
> 
> 	Cookie1=Value1; Cookie2=Value2; Cookie3=Value3 or
> 	Cookie2=Value2; Cookie3=Value3; Cookie1=Value1 or
> 	Cookie3=Value3; Cookie1=Value1; Cookie2=Value2
> 
> is there a way to have it find the value of Cookie1 no matter where
> it's located?  I can get it to find it if it's the first or second
> item in the list and I can get it to find it if it's the 3rd value in
> the list, but I can't get it to work for both.  

You could use a hash like this (as long as your cookienames are unique):

	my %cookies = map trim(split /=/, $_, 2) => split /;/, $cookie;

	$log{ $cookie{ManualDownloadCode} }{$file} = 1
		if exists $cookie{ManualDownloadCode};

-- 
Good luck,
Abe
perl -we '$_="rekcah lreP rehtona tsuJ";print$2while s/(.*)(.)/$1/g'


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

Date: Sat, 04 Nov 2000 12:44:32 +0100
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Want to process all files less than 24 hours old
Message-Id: <jet70toqhhibdcuojph83rdkau3e44grjn@4ax.com>

On Sat, 04 Nov 2000 12:22:12 +0100, Abe Timmerman <abe@ztreet.demon.nl>
wrote:

brrr, I hate it when this happens :-(

> On Fri, 03 Nov 2000 12:59:56 -0800, Mark Thompson
> <mark-lists@webstylists.com> wrote:
> 
> ...
> > One question I have is that split the cookie variable into multiple
> > items by semi-colon because that's how it gets split up by the browser
> > and then had it search each individual cookie separately.  If the
> > cookie is in the form:
> > 
> > 	Cookie1=Value1; Cookie2=Value2; Cookie3=Value3 or
> > 	Cookie2=Value2; Cookie3=Value3; Cookie1=Value1 or
> > 	Cookie3=Value3; Cookie1=Value1; Cookie2=Value2
> > 
> > is there a way to have it find the value of Cookie1 no matter where
> > it's located?  I can get it to find it if it's the first or second
> > item in the list and I can get it to find it if it's the 3rd value in
> > the list, but I can't get it to work for both.  
> 
> You could use a hash like this (as long as your cookienames are unique):
> 
> 	my %cookies = map trim(split /=/, $_, 2) => split /;/, $cookie;
> 
> 	$log{ $cookie{ManualDownloadCode} }{$file} = 1
> 		if exists $cookie{ManualDownloadCode};

Better make that (missing 's'):

 	$log{ $cookies{ManualDownloadCode} }{$file} = 1
 		if exists $cookies{ManualDownloadCode};

-- 
Good luck,
Abe
perl -we '$_="rekcah lreP rehtona tsuJ";print$2while s/(.*)(.)/$1/g'


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

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


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