[7583] in Perl-Users-Digest
Perl-Users Digest, Issue: 1209 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 21 11:17:17 1997
Date: Tue, 21 Oct 97 08:05:29 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 21 Oct 1997 Volume: 8 Number: 1209
Today's topics:
[Reposted due to Enlow UCE cancel]: Re: map or for : wh <jholzman@fas.harvard.edu>
[Reposted due to Enlow UCE cancel]: Re: map or for : wh <jholzman@fas.harvard.edu>
[Reposted due to Enlow UCE cancel]: Re: map or for : wh <jholzman@fas.harvard.edu>
[Reposted due to Enlow UCE cancel]: Re: map or for : wh <jholzman@fas.harvard.edu>
[Reposted due to Enlow UCE cancel]: Re: Perl for Window <nihonjin@cyberdude.com>
[Reposted due to Enlow UCE cancel]: Re: Perl for Window (Faust Gertz)
[Reposted due to Enlow UCE cancel]: Re: Perl for Window (Faust Gertz)
[Reposted due to Enlow UCE cancel]: Re: Perl for Window <nihonjin@cyberdude.com>
[Reposted due to Enlow UCE cancel]: Regular Expressions <bufic@cs.rpi.edu>
[Reposted due to Enlow UCE cancel]: Regular Expressions <bufic@cs.rpi.edu>
Re: Best way to comma seperate a number? <friedman@uci.edu>
Re: Fastest Compare On Array Elements (Toutatis)
help on odd problem <s.nisbet@doc.mmu.ac.uk>
Re: perl debugger doesn't show "my" vars. (Jason Gloudon)
sorting code? <tcm@tcmd.com>
Re: sorting code? (Mike Stok)
variable checking <josh@jersey.net>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 20 Oct 1997 18:43:50 -0400
From: Joanna Holzman <jholzman@fas.harvard.edu>
To: brian moseley <brian@criticalpath.net>
Subject: [Reposted due to Enlow UCE cancel]: Re: map or for : which is better in this case?
Message-Id: <REPOST-18064.448699951172.344BDEA6.B9EC072@fas.harvard.edu>
brian moseley wrote:
>
> ok. $list is a reference to an array of objects( which respond to a
> header() method) and $hdr is a string; both $list and $hdr have been
> passed into this particular sub.
>
> i want to create a hash with key "value of this object's $hdr header"
> and value "index of this object in @$list", such that i can create
>
> @sorted_table = sort keys %table;
>
> and then build a new sorted array of objects.
>
> which of the below pieces of code is preferable, in terms of speed,
> readability, and overall niceness?
>
> candidate 1:
>
> my %table;
> for ( my $idx = 0; $idx < ( scalar @$list ); $idx++ ) {
> my $val = $list->[$idx]->header( $hdr );
> $table{$val} = $idx;
> }
>
> candidate 2:
>
> my $idx = 0;
> my %table = map {
> $_->header( $hdr ), $idx++
> } @$list;
>
First, in number 1, you don't need the '(scalar @$list)'; just '@$list'
will do fine in that instance. As to which candidate is "better", that
probably depends on who will be maintaining it. If it will be a c
programmer, then number 1 would make more sense; if a lisp programmer,
number 2. However, in either case, I'm curious why you're copying
everything in to a hash, when you should probably just use a schwartzian
transform:
my @sortedlist = map {$_->[1]}
sort {$_->[0] cmp $_->[0]}
map {[$_->header($hdr), $_]}
@$list;
This will be easily maintainable by a perl programmer ;-)
> --
>
> * brian moseley *
> { agent of chaos => critical path }
========= WAS CANCELLED BY =======:
Rogue cancel from Michael Enlow, X-Cancelled-by etc. are forged.
Further information can be acquired at http://www.sputum.com/ucepage.htm
You can express your displeasure with Mr. Enlow by contacting him at:
enlow@direcpc.com
Control: cancel <344BDEA6.B9EC072@fas.harvard.edu>
Newsgroups: comp.lang.perl.misc
Path: ...!news.rediris.es!news-ge.switch.ch!newscore.univie.ac.at!newsfeed.nacamar.de!howland.erols.net!news-peer.gsl.net!news-tokyo.gip.net!news.gsl.net!gip.net!nspixp!newsfeed.btnis.ad.jp!newsfeed1.btnis.ad.jp!news.fsinet.or.jp!ubc.co.jp!nobody
From: godmom@pagesz.net
Subject: cmsg cancel <344BDEA6.B9EC072@fas.harvard.edu>
Approved: godmom@pagesz.net
Message-ID: <cancel.344BDEA6.B9EC072@fas.harvard.edu>
X-No-Archive: Yes
Sender: Joanna Holzman <jholzman@fas.harvard.edu>
X-Cancelled-By: godmom@pagesz.net
Organization: UBC
Date: Tue, 21 Oct 1997 00:22:48 GMT
Lines: 2
This article cancelled within Tin.
------------------------------
Date: Mon, 20 Oct 1997 18:45:08 -0400
From: Joanna Holzman <jholzman@fas.harvard.edu>
To: brian moseley <brian@criticalpath.net>
Subject: [Reposted due to Enlow UCE cancel]: Re: map or for : which is better in this case?
Message-Id: <REPOST-28993.115173339844.344BDEF4.F8873637@fas.harvard.edu>
brian moseley wrote:
>
> ok. $list is a reference to an array of objects( which respond to a
> header() method) and $hdr is a string; both $list and $hdr have been
> passed into this particular sub.
>
> i want to create a hash with key "value of this object's $hdr header"
> and value "index of this object in @$list", such that i can create
>
> @sorted_table = sort keys %table;
>
> and then build a new sorted array of objects.
>
> which of the below pieces of code is preferable, in terms of speed,
> readability, and overall niceness?
>
> candidate 1:
>
> my %table;
> for ( my $idx = 0; $idx < ( scalar @$list ); $idx++ ) {
> my $val = $list->[$idx]->header( $hdr );
> $table{$val} = $idx;
> }
>
> candidate 2:
>
> my $idx = 0;
> my %table = map {
> $_->header( $hdr ), $idx++
> } @$list;
>
First, in number 1, you don't need the '(scalar @$list)'; just '@$list'
will do fine in that instance. As to which candidate is "better", that
probably depends on who will be maintaining it. If it will be a c
programmer, then number 1 would make more sense; if a lisp programmer,
number 2. However, in either case, I'm curious why you're copying
everything in to a hash, when you should probably just use a schwartzian
transform:
my @sortedlist = map {$_->[1]}
sort {$_->[0] cmp $_->[0]}
map {[$_->header($hdr), $_]}
@$list;
This will be easily maintainable by a perl programmer ;-)
Benjamin Holzman
> --
>
> * brian moseley *
> { agent of chaos => critical path }
========= WAS CANCELLED BY =======:
Rogue cancel from Michael Enlow, X-Cancelled-by etc. are forged.
Further information can be acquired at http://www.sputum.com/ucepage.htm
You can express your displeasure with Mr. Enlow by contacting him at:
enlow@direcpc.com
Control: cancel <344BDEF4.F8873637@fas.harvard.edu>
Newsgroups: comp.lang.perl.misc
Path: ...!news.tamu.edu!newshost.comco.com!news.altair.com!uwvax!uwm.edu!news.sprintisp.com!sprintisp!nntprelay.mathworks.com!news-peer.gsl.net!news-tokyo.gip.net!news.gsl.net!gip.net!nspixp!newsfeed.btnis.ad.jp!newsfeed1.btnis.ad.jp!news.fsinet.or.jp!ubc.co.jp!nobody
From: godmom@pagesz.net
Subject: cmsg cancel <344BDEF4.F8873637@fas.harvard.edu>
Approved: godmom@pagesz.net
Message-ID: <cancel.344BDEF4.F8873637@fas.harvard.edu>
X-No-Archive: Yes
Sender: Joanna Holzman <jholzman@fas.harvard.edu>
X-Cancelled-By: godmom@pagesz.net
Organization: UBC
Date: Tue, 21 Oct 1997 00:22:09 GMT
Lines: 2
This article cancelled within Tin.
------------------------------
Date: Mon, 20 Oct 1997 18:43:50 -0400
From: Joanna Holzman <jholzman@fas.harvard.edu>
To: brian moseley <brian@criticalpath.net>
Subject: [Reposted due to Enlow UCE cancel]: Re: map or for : which is better in this case?
Message-Id: <REPOST-24945.238708496094.344BDEA6.B9EC072@fas.harvard.edu>
brian moseley wrote:
>
> ok. $list is a reference to an array of objects( which respond to a
> header() method) and $hdr is a string; both $list and $hdr have been
> passed into this particular sub.
>
> i want to create a hash with key "value of this object's $hdr header"
> and value "index of this object in @$list", such that i can create
>
> @sorted_table = sort keys %table;
>
> and then build a new sorted array of objects.
>
> which of the below pieces of code is preferable, in terms of speed,
> readability, and overall niceness?
>
> candidate 1:
>
> my %table;
> for ( my $idx = 0; $idx < ( scalar @$list ); $idx++ ) {
> my $val = $list->[$idx]->header( $hdr );
> $table{$val} = $idx;
> }
>
> candidate 2:
>
> my $idx = 0;
> my %table = map {
> $_->header( $hdr ), $idx++
> } @$list;
>
First, in number 1, you don't need the '(scalar @$list)'; just '@$list'
will do fine in that instance. As to which candidate is "better", that
probably depends on who will be maintaining it. If it will be a c
programmer, then number 1 would make more sense; if a lisp programmer,
number 2. However, in either case, I'm curious why you're copying
everything in to a hash, when you should probably just use a schwartzian
transform:
my @sortedlist = map {$_->[1]}
sort {$_->[0] cmp $_->[0]}
map {[$_->header($hdr), $_]}
@$list;
This will be easily maintainable by a perl programmer ;-)
> --
>
> * brian moseley *
> { agent of chaos => critical path }
========= WAS CANCELLED BY =======:
Rogue cancel from Michael Enlow, X-Cancelled-by etc. are forged.
Further information can be acquired at http://www.sputum.com/ucepage.htm
You can express your displeasure with Mr. Enlow by contacting him at:
enlow@direcpc.com
Control: cancel <344BDEA6.B9EC072@fas.harvard.edu>
Newsgroups: comp.lang.perl.misc
Path: ...!news.rediris.es!news-ge.switch.ch!newscore.univie.ac.at!newsfeed.nacamar.de!howland.erols.net!news-peer.gsl.net!news-tokyo.gip.net!news.gsl.net!gip.net!nspixp!newsfeed.btnis.ad.jp!newsfeed1.btnis.ad.jp!news.fsinet.or.jp!ubc.co.jp!nobody
From: godmom@pagesz.net
Subject: cmsg cancel <344BDEA6.B9EC072@fas.harvard.edu>
Approved: godmom@pagesz.net
Message-ID: <cancel.344BDEA6.B9EC072@fas.harvard.edu>
X-No-Archive: Yes
Sender: Joanna Holzman <jholzman@fas.harvard.edu>
X-Cancelled-By: godmom@pagesz.net
Organization: UBC
Date: Tue, 21 Oct 1997 00:22:48 GMT
Lines: 2
This article cancelled within Tin.
------------------------------
Date: Mon, 20 Oct 1997 18:45:08 -0400
From: Joanna Holzman <jholzman@fas.harvard.edu>
To: brian moseley <brian@criticalpath.net>
Subject: [Reposted due to Enlow UCE cancel]: Re: map or for : which is better in this case?
Message-Id: <REPOST-25208.230682373047.344BDEF4.F8873637@fas.harvard.edu>
brian moseley wrote:
>
> ok. $list is a reference to an array of objects( which respond to a
> header() method) and $hdr is a string; both $list and $hdr have been
> passed into this particular sub.
>
> i want to create a hash with key "value of this object's $hdr header"
> and value "index of this object in @$list", such that i can create
>
> @sorted_table = sort keys %table;
>
> and then build a new sorted array of objects.
>
> which of the below pieces of code is preferable, in terms of speed,
> readability, and overall niceness?
>
> candidate 1:
>
> my %table;
> for ( my $idx = 0; $idx < ( scalar @$list ); $idx++ ) {
> my $val = $list->[$idx]->header( $hdr );
> $table{$val} = $idx;
> }
>
> candidate 2:
>
> my $idx = 0;
> my %table = map {
> $_->header( $hdr ), $idx++
> } @$list;
>
First, in number 1, you don't need the '(scalar @$list)'; just '@$list'
will do fine in that instance. As to which candidate is "better", that
probably depends on who will be maintaining it. If it will be a c
programmer, then number 1 would make more sense; if a lisp programmer,
number 2. However, in either case, I'm curious why you're copying
everything in to a hash, when you should probably just use a schwartzian
transform:
my @sortedlist = map {$_->[1]}
sort {$_->[0] cmp $_->[0]}
map {[$_->header($hdr), $_]}
@$list;
This will be easily maintainable by a perl programmer ;-)
Benjamin Holzman
> --
>
> * brian moseley *
> { agent of chaos => critical path }
========= WAS CANCELLED BY =======:
Rogue cancel from Michael Enlow, X-Cancelled-by etc. are forged.
Further information can be acquired at http://www.sputum.com/ucepage.htm
You can express your displeasure with Mr. Enlow by contacting him at:
enlow@direcpc.com
Control: cancel <344BDEF4.F8873637@fas.harvard.edu>
Newsgroups: comp.lang.perl.misc
Path: ...!news.tamu.edu!newshost.comco.com!news.altair.com!uwvax!uwm.edu!news.sprintisp.com!sprintisp!nntprelay.mathworks.com!news-peer.gsl.net!news-tokyo.gip.net!news.gsl.net!gip.net!nspixp!newsfeed.btnis.ad.jp!newsfeed1.btnis.ad.jp!news.fsinet.or.jp!ubc.co.jp!nobody
From: godmom@pagesz.net
Subject: cmsg cancel <344BDEF4.F8873637@fas.harvard.edu>
Approved: godmom@pagesz.net
Message-ID: <cancel.344BDEF4.F8873637@fas.harvard.edu>
X-No-Archive: Yes
Sender: Joanna Holzman <jholzman@fas.harvard.edu>
X-Cancelled-By: godmom@pagesz.net
Organization: UBC
Date: Tue, 21 Oct 1997 00:22:09 GMT
Lines: 2
This article cancelled within Tin.
------------------------------
Date: Tue, 21 Oct 1997 02:09:21 +0100
From: "A.K" <nihonjin@cyberdude.com>
Subject: [Reposted due to Enlow UCE cancel]: Re: Perl for Windows NT
Message-Id: <REPOST-9832.6999206542969.344C00C1.7725DE16@cyberdude.com>
Tell me when you find it I'm looking for the same thing!
Thanx!
AAMU wrote:
> Hi,
>
> Does anybody know where I can download Perl for Windows NT 4.0
> (workstation)?
>
> Thanks for your assistance,
> aamu
========= WAS CANCELLED BY =======:
Rogue cancel from Michael Enlow, X-Cancelled-by etc. are forged.
Further information can be acquired at http://www.sputum.com/ucepage.htm
You can express your displeasure with Mr. Enlow by contacting him at:
enlow@direcpc.com
Control: cancel <344C00C1.7725DE16@cyberdude.com>
Newsgroups: comp.lang.perl.misc
Path: ...!news.rediris.es!news-ge.switch.ch!newscore.univie.ac.at!europa.clark.net!204.59.152.222!news-peer.gsl.net!news-tokyo.gip.net!news.gsl.net!gip.net!nspixp!newsfeed.btnis.ad.jp!newsfeed1.btnis.ad.jp!news.fsinet.or.jp!ubc.co.jp!nobody
From: godmom@pagesz.net
Subject: cmsg cancel <344C00C1.7725DE16@cyberdude.com>
Approved: godmom@pagesz.net
Message-ID: <cancel.344C00C1.7725DE16@cyberdude.com>
X-No-Archive: Yes
Sender: "A.K" <nihonjin@cyberdude.com>
X-Cancelled-By: godmom@pagesz.net
Organization: UBC
Date: Tue, 21 Oct 1997 02:30:15 GMT
Lines: 2
This article cancelled within Tin.
------------------------------
Date: Tue, 21 Oct 1997 00:38:00 GMT
From: faust@wwa.com (Faust Gertz)
Subject: [Reposted due to Enlow UCE cancel]: Re: Perl for Windows NT
Message-Id: <REPOST-10211.688354492188.344bf4f0.16573289@news.wwa.com>
On 20 Oct 97 22:56:31 GMT, "AAMU" <fcrutch@ami.net> wrote:
>Does anybody know where I can download Perl for Windows NT 4.0
>(workstation)?
People who can read FAQs know. From
http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ_1.html
:1.4. Where is the Perl for Win32 interpreter available?
:
:The Perl for Win32 package is available as a ZIP archive by anonymous FTP from ActiveWare and from CPAN, the
:Comprehensive Perl Archive Network.
:
:To download from ActiveWare, look in this directory:
:
:ftp://ftp.ActiveState.com/Perl-Win32/Release/
:
:There are 4 distribution packages: one for Intel x86 machines, one for DEC Alpha machines, one for PowerPC machines, and one
:source code package. These packages are named XXX-i86.zip, XXX-Alp.zip, XXX-Ppc.zip, and XXX-src.zip, respectively, where
:XXX is the current build number. The current build number is 110.
:
:To download files from CPAN, go to the following URL:
:
:http://www.perl.com/CPAN-local/ports/nt/
:
:Note that this will automatically redirect you to your nearest CPAN mirror site.
HTH
Faust Gertz
Philosopher at Large
========= WAS CANCELLED BY =======:
Rogue cancel from Michael Enlow, X-Cancelled-by etc. are forged.
Further information can be acquired at http://www.sputum.com/ucepage.htm
You can express your displeasure with Mr. Enlow by contacting him at:
enlow@direcpc.com
Control: cancel <344bf4f0.16573289@news.wwa.com>
Newsgroups: comp.lang.perl.misc
Path: ...!ddsw1!news.mcs.net!peerfeed.ncal.verio.net!europa.clark.net!204.59.152.222!news-peer.gsl.net!news-tokyo.gip.net!news.gsl.net!gip.net!nspixp!newsfeed.btnis.ad.jp!newsfeed1.btnis.ad.jp!news.fsinet.or.jp!ubc.co.jp!nobody
From: godmom@pagesz.net
Subject: cmsg cancel <344bf4f0.16573289@news.wwa.com>
Approved: godmom@pagesz.net
Message-ID: <cancel.344bf4f0.16573289@news.wwa.com>
X-No-Archive: Yes
Sender: faust@wwa.com (Faust Gertz)
X-Cancelled-By: godmom@pagesz.net
Organization: UBC
Date: Tue, 21 Oct 1997 02:29:52 GMT
Lines: 2
This article cancelled within Tin.
------------------------------
Date: Tue, 21 Oct 1997 00:38:00 GMT
From: faust@wwa.com (Faust Gertz)
Subject: [Reposted due to Enlow UCE cancel]: Re: Perl for Windows NT
Message-Id: <REPOST-17284.472503662109.344bf4f0.16573289@news.wwa.com>
On 20 Oct 97 22:56:31 GMT, "AAMU" <fcrutch@ami.net> wrote:
>Does anybody know where I can download Perl for Windows NT 4.0
>(workstation)?
People who can read FAQs know. From
http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ_1.html
:1.4. Where is the Perl for Win32 interpreter available?
:
:The Perl for Win32 package is available as a ZIP archive by anonymous FTP from ActiveWare and from CPAN, the
:Comprehensive Perl Archive Network.
:
:To download from ActiveWare, look in this directory:
:
:ftp://ftp.ActiveState.com/Perl-Win32/Release/
:
:There are 4 distribution packages: one for Intel x86 machines, one for DEC Alpha machines, one for PowerPC machines, and one
:source code package. These packages are named XXX-i86.zip, XXX-Alp.zip, XXX-Ppc.zip, and XXX-src.zip, respectively, where
:XXX is the current build number. The current build number is 110.
:
:To download files from CPAN, go to the following URL:
:
:http://www.perl.com/CPAN-local/ports/nt/
:
:Note that this will automatically redirect you to your nearest CPAN mirror site.
HTH
Faust Gertz
Philosopher at Large
========= WAS CANCELLED BY =======:
Rogue cancel from Michael Enlow, X-Cancelled-by etc. are forged.
Further information can be acquired at http://www.sputum.com/ucepage.htm
You can express your displeasure with Mr. Enlow by contacting him at:
enlow@direcpc.com
Control: cancel <344bf4f0.16573289@news.wwa.com>
Newsgroups: comp.lang.perl.misc
Path: ...!ddsw1!news.mcs.net!peerfeed.ncal.verio.net!europa.clark.net!204.59.152.222!news-peer.gsl.net!news-tokyo.gip.net!news.gsl.net!gip.net!nspixp!newsfeed.btnis.ad.jp!newsfeed1.btnis.ad.jp!news.fsinet.or.jp!ubc.co.jp!nobody
From: godmom@pagesz.net
Subject: cmsg cancel <344bf4f0.16573289@news.wwa.com>
Approved: godmom@pagesz.net
Message-ID: <cancel.344bf4f0.16573289@news.wwa.com>
X-No-Archive: Yes
Sender: faust@wwa.com (Faust Gertz)
X-Cancelled-By: godmom@pagesz.net
Organization: UBC
Date: Tue, 21 Oct 1997 02:29:52 GMT
Lines: 2
This article cancelled within Tin.
------------------------------
Date: Tue, 21 Oct 1997 02:09:21 +0100
From: "A.K" <nihonjin@cyberdude.com>
Subject: [Reposted due to Enlow UCE cancel]: Re: Perl for Windows NT
Message-Id: <REPOST-24797.243225097656.344C00C1.7725DE16@cyberdude.com>
Tell me when you find it I'm looking for the same thing!
Thanx!
AAMU wrote:
> Hi,
>
> Does anybody know where I can download Perl for Windows NT 4.0
> (workstation)?
>
> Thanks for your assistance,
> aamu
========= WAS CANCELLED BY =======:
Rogue cancel from Michael Enlow, X-Cancelled-by etc. are forged.
Further information can be acquired at http://www.sputum.com/ucepage.htm
You can express your displeasure with Mr. Enlow by contacting him at:
enlow@direcpc.com
Control: cancel <344C00C1.7725DE16@cyberdude.com>
Newsgroups: comp.lang.perl.misc
Path: ...!news.rediris.es!news-ge.switch.ch!newscore.univie.ac.at!europa.clark.net!204.59.152.222!news-peer.gsl.net!news-tokyo.gip.net!news.gsl.net!gip.net!nspixp!newsfeed.btnis.ad.jp!newsfeed1.btnis.ad.jp!news.fsinet.or.jp!ubc.co.jp!nobody
From: godmom@pagesz.net
Subject: cmsg cancel <344C00C1.7725DE16@cyberdude.com>
Approved: godmom@pagesz.net
Message-ID: <cancel.344C00C1.7725DE16@cyberdude.com>
X-No-Archive: Yes
Sender: "A.K" <nihonjin@cyberdude.com>
X-Cancelled-By: godmom@pagesz.net
Organization: UBC
Date: Tue, 21 Oct 1997 02:30:15 GMT
Lines: 2
This article cancelled within Tin.
------------------------------
Date: Mon, 20 Oct 1997 17:45:34 -0400
From: Corey Bufi <bufic@cs.rpi.edu>
Subject: [Reposted due to Enlow UCE cancel]: Regular Expressions and Record Separators
Message-Id: <REPOST-20676.368988037109.344BD0FD.101C7E@cs.rpi.edu>
I want to set the input record separator to a regurlar expression
so that a file can be segmented according to any one of a set of
multi-character delimiters. For example, I want to set the
delimiting condition to be case insensitive. From what I gather,
this can't be done. Is this correct?
Thanks,
Corey
========= WAS CANCELLED BY =======:
Rogue cancel from Michael Enlow, X-Cancelled-by etc. are forged.
Further information can be acquired at http://www.sputum.com/ucepage.htm
You can express your displeasure with Mr. Enlow by contacting him at:
enlow@direcpc.com
Control: cancel <344BD0FD.101C7E@cs.rpi.edu>
Newsgroups: comp.lang.perl.misc
Path: ...!news.tamu.edu!newshost.comco.com!news.altair.com!uwvax!uwm.edu!vixen.cso.uiuc.edu!howland.erols.net!news-peer.gsl.net!news-tokyo.gip.net!news.gsl.net!gip.net!nspixp!newsfeed.btnis.ad.jp!newsfeed1.btnis.ad.jp!news.fsinet.or.jp!ubc.co.jp!nobody
From: godmom@pagesz.net
Subject: cmsg cancel <344BD0FD.101C7E@cs.rpi.edu>
Approved: godmom@pagesz.net
Message-ID: <cancel.344BD0FD.101C7E@cs.rpi.edu>
X-No-Archive: Yes
Sender: Corey Bufi <bufic@cs.rpi.edu>
X-Cancelled-By: godmom@pagesz.net
Organization: UBC
Date: Tue, 21 Oct 1997 00:23:33 GMT
Lines: 2
This article cancelled within Tin.
------------------------------
Date: Mon, 20 Oct 1997 17:45:34 -0400
From: Corey Bufi <bufic@cs.rpi.edu>
Subject: [Reposted due to Enlow UCE cancel]: Regular Expressions and Record Separators
Message-Id: <REPOST-17147.476684570312.344BD0FD.101C7E@cs.rpi.edu>
I want to set the input record separator to a regurlar expression
so that a file can be segmented according to any one of a set of
multi-character delimiters. For example, I want to set the
delimiting condition to be case insensitive. From what I gather,
this can't be done. Is this correct?
Thanks,
Corey
========= WAS CANCELLED BY =======:
Rogue cancel from Michael Enlow, X-Cancelled-by etc. are forged.
Further information can be acquired at http://www.sputum.com/ucepage.htm
You can express your displeasure with Mr. Enlow by contacting him at:
enlow@direcpc.com
Control: cancel <344BD0FD.101C7E@cs.rpi.edu>
Newsgroups: comp.lang.perl.misc
Path: ...!news.tamu.edu!newshost.comco.com!news.altair.com!uwvax!uwm.edu!vixen.cso.uiuc.edu!howland.erols.net!news-peer.gsl.net!news-tokyo.gip.net!news.gsl.net!gip.net!nspixp!newsfeed.btnis.ad.jp!newsfeed1.btnis.ad.jp!news.fsinet.or.jp!ubc.co.jp!nobody
From: godmom@pagesz.net
Subject: cmsg cancel <344BD0FD.101C7E@cs.rpi.edu>
Approved: godmom@pagesz.net
Message-ID: <cancel.344BD0FD.101C7E@cs.rpi.edu>
X-No-Archive: Yes
Sender: Corey Bufi <bufic@cs.rpi.edu>
X-Cancelled-By: godmom@pagesz.net
Organization: UBC
Date: Tue, 21 Oct 1997 00:23:33 GMT
Lines: 2
This article cancelled within Tin.
------------------------------
Date: 21 Oct 1997 13:56:08 GMT
From: "Eric D. Friedman" <friedman@uci.edu>
Subject: Re: Best way to comma seperate a number?
Message-Id: <62ic9o$sv9@news.service.uci.edu>
In article <62ekss$1s1$1@gte2.gte.net>, Eric <pojo@gte.net.nospam> wrote:
<Okay, I found this in the FAQ. Why does it work? More specifically, why does:
<
< 1 while s/^(-?\d+)(\d{3})/$1,$2/;
<
<do what it does?? What is that 1 doing in there?
while loops, like for, and foreach loops, continue executing until
their test condition is false. In this case, you're witnessing Perl's
much-vaunted flexibility, since the person who wrote this has turned
that logic on its end. That is, the real work gets done in the
test condition, while the loop doesn't do a damn thing.
Another way to write it would have been
while (s/^(-?\d+)(\d{3})/$1,$2/)
{
1;
}
Now, what's really happening here?
the s/// operator returns true if it succeeds, allowing the loop another
(do-nothing) iteration.
The regex, which is really very clever, gobbles up all of the numbers
from the beginning of the string (which may start with zero or one
`-' characters) UP TO THE `.', and inserts a comma between the >last<
triplet and the front of the string.
So, the first iteration on the number 123456789.987 yields
123456,789.987
^ ^ ^
| | + - stop here
(-?\d+) + - (\d{3})
On the second iteration, the pattern match stops at the comma, and the
substitution yields
123,456,789.987
$1 $2 ^
|
stop here
The third loop test fails (can't find 1 or more \d characters followed
by exactly three \d's at the beginning of the string, so the loop
ends.
As you can see, the loop is needed, because you couldn't do it with
a single /g regex. Oh J. Friedl probably could, but I imagine that
the FAQ solution is the more efficient way to go. It certainly is
in terms of programmer time, 'cause it's already written. ;-)
But, you should still buy/read Friedl's book. Oh yes you should!
HTH,
Eric
--
Eric D. Friedman
friedman@uci.edu
------------------------------
Date: 21 Oct 1997 14:45:12 GMT
From: toutatis@_SPAMTRAP_toutatis.net (Toutatis)
Subject: Re: Fastest Compare On Array Elements
Message-Id: <toutatis-ya023180002110971645120001@news.euro.net>
Eric D. Friedman" <friedman@uci.edu> wrote:
Stephan Vladimir Bugaj <bugaj@bell-labs.com> wrote:
>
> <What is the fastest way (computation time, not programmer time) to use
> <all of the elements in an array for && and || comparison?
> If you don't mind checking all of the elements of the array, you
> should use grep in a scalar context, which perldoc -f grep
> tells us gives the number of matches for that array. thus:
>
> my $flag = grep /$lookfor/o, @search;
> if ($flag) { print "got it\n" }
Since the fastest way was requested, you *do* mind to check the entire list.
You could build your own grepfunction that deals with that:
sub _grep {
my ($find,$listref) = @_;
grep{/$find/o and return 1}@$listref;
0;
}
print "Yippie\n" if _grep('aaa',['aaa'..'zzz']);
#will print *substantially* faster than:
print "Yeaaah\n" if _grep('zzz',['aaa'..'zzz']);
--
Toutatis
------------------------------
Date: 21 Oct 97 14:41:44 GMT
From: "Steve Nisbet" <s.nisbet@doc.mmu.ac.uk>
Subject: help on odd problem
Message-Id: <01bcde30$26717ee0$3fc3aa95@JD-e114-04.doc.aca.mmu.ac.uk>
Thanks to anyone in advance, but how would I go about converting a string
such as:
frank Spencer (held in say $name)
into the following:
F.Spencer
I've tried mucking around with splice, but I'm missing something.
If you could mail me any answer I'd be grateful
Steve Nisbet
Web Admin
DOC MMU
------------------------------
Date: 21 Oct 1997 14:44:11 GMT
From: jgloudon@bbn.remove.com (Jason Gloudon)
Subject: Re: perl debugger doesn't show "my" vars.
Message-Id: <62if3r$195$1@daily.bbnplanet.com>
Evgenij Beresin (beg@mrl.sps.mot.com) wrote:
: Hi all,
: Recently I started to use perl debugger (-d option),
: and discovered that it doesn't show vars declared as "my".
: Global and "local" vars are displayed OK.
: What is wrong?
I believe you're talking about using X to list package variables.
my variables don't exist in package symbol tables, hence X can't be used
to view their value. lowercase x can be. I don't know of a way to list such
variables.
Jason Gloudon
------------------------------
Date: Tue, 21 Oct 1997 10:30:11 -0400
From: "Ernie Johnson" <tcm@tcmd.com>
Subject: sorting code?
Message-Id: <62idpp$eee$1@nr1.toronto.istar.net>
in lieu of re-inventing the wheel, does anyone have any code to sort a small
(200 item) list or know of where there is a routine to do this?
please cc replies to tcm@tcmd.com if convenient.
Ernie Johnson
TCM Online
------------------------------
Date: 21 Oct 1997 14:41:43 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: sorting code?
Message-Id: <62iev7$1n3@news-central.tiac.net>
In article <62idpp$eee$1@nr1.toronto.istar.net>,
Ernie Johnson <tcm@tcmd.com> wrote:
>in lieu of re-inventing the wheel, does anyone have any code to sort a small
>(200 item) list or know of where there is a routine to do this?
Perl's build in sort uses a qsort and should be quite effective:
@sorted = sort @list;
is documented in the on-line docs and books about perl. How do you want
the list sorted? If you have a recent perl installation then
perldoc perlfunc
should get you a (long) page which describes how to use sort.
If you're doing a more complex sort then you might want to look at the FAQ
(list of frequently asked questions) which is included in recent
distributions an can be reached via http://www.perl.com/
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Sat, 18 Oct 1997 10:19:09 -0400
From: Josh <josh@jersey.net>
Subject: variable checking
Message-Id: <3448C55D.7E79@jersey.net>
I have two problems, although they all revolve around the same thing:
I need a user to input an IP address and then have the program check to
see if the address is valid. Here are the problems I'm running into:
1) I can't seem to use periods in the address, when I do, the split
command will not work. So, for right now, I'm stuck using comma's.
2) I don't know how to test the IP. I don't care what the actually
numbers are, I just want to make sure that it follows the correct
format; i.e. 111.111.111.111 .
Any Ideas???
Josh
josh@jersey.net
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 1209
**************************************