[16345] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3757 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 20 11:10:27 2000

Date: Thu, 20 Jul 2000 08:10:17 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <964105816-v9-i3757@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 20 Jul 2000     Volume: 9 Number: 3757

Today's topics:
        Looking for http module tltt@my-deja.com
    Re: Looking for http module (Rafael Garcia-Suarez)
        Matts Script Archive - A critique <ralawrence@my-deja.com>
    Re: Matts Script Archive - A critique <care227@attglobal.net>
    Re: Matts Script Archive - A critique <callgirl@la.znet.com>
    Re: Matts Script Archive - A critique (NP)
    Re: NEW: AI::NeuralNetwork - idea, comments <richly@samart.co.th>
    Re: NEW: AI::NeuralNetwork - idea, comments <iltzu@sci.invalid>
    Re: NT4-IIS-MSSQL7 <jbroz@transarc.com>
        Odd or even ? <jimmy.lantz@ostas.lu.se>
    Re: Patternmatch and replace values?? <mauldin@netstorm.net>
    Re: perl equivalent to "cat /dev/null >filename"? <shon@mad.scientist.com>
    Re: PLEASE HELP!!!! <newsposter@cthulhu.demon.nl>
        Process problem <jamesmckay@MailAndNews.com>
    Re: Process problem <pavel@gingerall.cz>
    Re: Process problem <pavel@gingerall.cz>
    Re: Quoting, interpolation and regular expressions (Abigail)
    Re: Quoting, interpolation and regular expressions <iltzu@sci.invalid>
    Re: Quoting, interpolation and regular expressions <roman.stawski@fr.adp.com>
        Removing (not extracting!) URL's from a string?? <ralawrence@my-deja.com>
    Re: Removing (not extracting!) URL's from a string?? (NP)
    Re: Substr question : what about the fourth argument? <cal@iamcal.com>
    Re: Suggestion for syntax change (jason)
    Re: Suggestion for syntax change (jason)
    Re: Translation from csh to Perl? <dbohl@sgi.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 20 Jul 2000 14:18:37 GMT
From: tltt@my-deja.com
Subject: Looking for http module
Message-Id: <8l71n9$ln0$1@nnrp1.deja.com>

Hello,

I am trying to test my web site. Instead of using my browser I thought
I'd write a Perl program that connects to the web server, sends requests
and then stores what the server returns, in order to automate the task.

I searched in CPAN for "http" and got about 85 modules. Could someone
tell me which one is the one I need for this job?

thanks.


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


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

Date: Thu, 20 Jul 2000 14:38:37 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Looking for http module
Message-Id: <slrn8ne40h.f9k.rgarciasuarez@rafael.kazibao.net>

tltt@my-deja.com wrote in comp.lang.perl.misc:
>Hello,
>
>I am trying to test my web site. Instead of using my browser I thought
>I'd write a Perl program that connects to the web server, sends requests
>and then stores what the server returns, in order to automate the task.
>
>I searched in CPAN for "http" and got about 85 modules. Could someone
>tell me which one is the one I need for this job?

Look for the bundle called libwww, that contains several modules in the
LWP::*, HTTP::* and WWW::* namespaces.

You will also enjoy the O'Reilly book, Web Client Programming with Perl,
(by Clinton Wong), freely available at
    http://www.oreilly.com/openbook/webclient/

-- 
Rafael Garcia-Suarez


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

Date: Thu, 20 Jul 2000 14:13:35 GMT
From: Richard Lawrence <ralawrence@my-deja.com>
Subject: Matts Script Archive - A critique
Message-Id: <8l71dt$lbj$1@nnrp1.deja.com>

Has anyone ever written a critique of any of the scripts Matt has
written? My perl isn't good enough to spot them myself but I think it
would be an excellent learning tool for myself and others out there.

Rich


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


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

Date: Thu, 20 Jul 2000 10:31:05 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Matts Script Archive - A critique
Message-Id: <39770D29.6A5474CD@attglobal.net>

Richard Lawrence wrote:
> 
> Has anyone ever written a critique of any of the scripts Matt has
> written? My perl isn't good enough to spot them myself but I think it
> would be an excellent learning tool for myself and others out there.
> 
> Rich
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.

Do a Deja search on Matt in this NG, you'll find plenty of... err..
"critiques".


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

Date: Thu, 20 Jul 2000 07:36:54 -0700
From: "Godzilla!" <callgirl@la.znet.com>
Subject: Re: Matts Script Archive - A critique
Message-Id: <39770E86.4660AE03@la.znet.com>

Richard Lawrence wrote:
 
> Has anyone ever written a critique of any of the scripts
> Matt has written? My perl isn't good enough to spot them
> myself but I think it would be an excellent learning tool
> for myself and others out there.


Why only Matt's scripts?

Godzilla!

-- 
print "file:///%43|%2f";


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

Date: Thu, 20 Jul 2000 14:43:54 GMT
From: nvp@spamnothanks.speakeasy.org (NP)
Subject: Re: Matts Script Archive - A critique
Message-Id: <KeEd5.120111$t91.808622@news4.giganews.com>

Thu, 20 Jul 2000 14:13:35 GMT, Richard Lawrence <ralawrence@my-deja.com> wrote:
: Has anyone ever written a critique of any of the scripts Matt has
: written? My perl isn't good enough to spot them myself but I think it
: would be an excellent learning tool for myself and others out there.

Matt's scripts aren't very good, I'm afraid.  On one hand, I've got to
give the kid credit since he wrote an awful lot of code by the time he
was near completion of high school.  BUT on the other hand, A LOT of
his code is just AWFUL.  :-)

I'd start out by offering the advise not to use it for the following
reasons:
1. Lack of file locking or strange file/directory checking.
2. Lack of thorough or proper error messages and error checking.
3. Won't pass taint checking and some won't pass strict checking.
4. Spurious or dangerous or unnecessary usage of external programs.
5. ... etc ... :-)

-- 
Nate II



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

Date: Thu, 20 Jul 2000 19:43:42 +0700
From: Robert White <richly@samart.co.th>
Subject: Re: NEW: AI::NeuralNetwork - idea, comments
Message-Id: <m5qdnscanfk7h3vr4aaigiuhp1p9h87i7q@4ax.com>

On 19 Jul 2000 18:18:58 GMT, The WebDragon <nospam@nospam.com> wrote:
>surely the NAMING of a module space has nothing to do with perl 
>golf. :-P
>
>However "AI::NeuralNet::BackProp" does seem appropriate, conveys the 
>proper imagery, and takes some of the work out of it :D *duck*

	could shorten that Just a bit to NNet, which shouldn't confuse
anyone particularly.

Rob
http://bangkokwizard.com/
now to cram the feedforward into a single map statement hehehhe


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

Date: 20 Jul 2000 13:14:53 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: NEW: AI::NeuralNetwork - idea, comments
Message-Id: <964097891.8673@itz.pp.sci.fi>

In article <Pine.GSO.4.21.0007190940100.2094-100000@mamba.cs.Virginia.EDU>, David Coppit wrote:
>On 19 Jul 2000, Ilmari Karonen wrote:
>
>> In article <8l3moa$7b2$1@nnrp1.deja.com>, peterhi@my-deja.com wrote:
>> >AI::NeuralNetwork::BackProp perhaps and then we can extend the base name
>> 
>>   AI::NeuralNet::BackProp?
>>   AI::Neural::BackProp?
>>   AI::Neural::BP?
>
>Please, NOOO! Most of the lifetime of software is spent in maintenance. That
>is, more people will be reading code that writing it. Make the little
>investment of typing the extra characters so that people later on will know
>what the heck you're talking about.

The point is to find a proper balance between the two.  On one hand, I
did consider the last alternatives a bit too short.  On the other, the
poster I replied to had already dropped "agation" from his suggestion.

ArtificialIntelligence::NeuralNetwork::BackPropagation is just as
silly as AI::NN::BP.  If you want Java, you know where to find it.

I'd prefer AI::NeuralNet::BackProp myself.  It's still readable, yet
short enough that you can type half a dozen constructor calls without
having to resort to cut-and-paste to avoid repetitive strain injury.

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method."  -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: Thu, 20 Jul 2000 14:39:42 +0100
From: "Joe_Broz@transarc.com" <jbroz@transarc.com>
Subject: Re: NT4-IIS-MSSQL7
Message-Id: <3977011E.46BD8B61@transarc.com>

clayton collie wrote:
> 
> hello,
>   ive searched CPAN, but i cant find a DBD module for MSSQL7 (im running
> ActiveState). Any leads ?

There isn't one AFAIK. I think that DBD::ODBC may work but have never tried
it


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

Date: Thu, 20 Jul 2000 17:07:47 +0200
From: Jimmy Lantz <jimmy.lantz@ostas.lu.se>
Subject: Odd or even ?
Message-Id: <397715C3.357FDDFC@ostas.lu.se>

Hi,


The thing I need is to get every other item to be treated differently. 
I thought to make the distinction odd or even number then treat the
objects differently depending if its odd or even. 

I'm trying to do the following:
################
#!perl

$number = 0;

foreach $item (@in_array)
{

#Find out if the scalar $number is an odd or even number
if ($number = odd)
{
#do something
}
else
{
#do something else
}

$number++;

} 
########################

Does anyone has a clue on how to go about it?

Yours sincerely
Jimmy Lantz
Sweden


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

Date: Thu, 20 Jul 2000 12:24:22 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: Patternmatch and replace values??
Message-Id: <3976EEB3.5A94E68B@netstorm.net>

John Casey wrote:
> 
>     $initial_new = "10 k"
>     $next_new = "25 k"
>     $pctincrease_new = "35"
> 
>    I would like to do a pattern match on the following statement ($line) :
> ***
> create unique index  TABLE_IDX  on TABLE_G(DD) storage (initial 30 k next 35 k
> pctincrease 10)  tablespace idxts
> ****
> 
>     and  replace the  values after initial (30 k), next (35 k), pctincrease (10)
> with  values from variables $initial_new, $next_new and $pctincrease_new
> respectively.
> 


Another WTDI is like this:

@new = (10,25,35);
s/(\d+)/shift @new/ges;

-- Jim


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

Date: Thu, 20 Jul 2000 14:00:25 GMT
From: Shon Stephens <shon@mad.scientist.com>
Subject: Re: perl equivalent to "cat /dev/null >filename"?
Message-Id: <8l70le$kpq$1@nnrp1.deja.com>


> Useless use of cat.
>
> $results = `more /dev/null > $filename`;
>
> Or, if you don't care about results (why would you here?) and you
> don't want to spawn a shell, use system() with multiple arguments.
>
> Or...  take advantage of an annoying habit of Perl that clobbers
> files.
>
> open LOG, ">$file" or die $!;
>
> That will do the same thing.
>
Yes, I quite forgot about that. Works nicely too.
Thanks!

--
Shon Stephens
UNIX Systems Administrator
shon@mad.scientist.com
"You want a piece of me?"


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


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

Date: 20 Jul 2000 13:56:48 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: PLEASE HELP!!!!
Message-Id: <8l70f0$n8n$2@internal-news.uu.net>

kj0 <kj0@mailcity.com> wrote:

> The server error log says

>     httpd: [Wed Jul 19 19:35:39 2000] [error] (8)Exec format error: exec of /home/doe/xyz/www/cgi/hi.js failed
>     httpd: [Wed Jul 19 19:35:39 2000] [error] [client ***.***.**.***] Premature end of script headers: /home/doe/xyz/www/cgi/hi.js

> Does anybody know what this means?  The file permissions are all OK.
> The server (apache) is configured to export javascript.

This means the prowser is trying to fetch the hi.js file, but your
server tries to execute it as if it is a cgi script.

Either configure the server to not execute *.js, or move the .js file
into another no-cgi directory.

And ofcourse, this question has nothing to do with Perl, but with
webserver configuration ...

Erik



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

Date: Thu, 20 Jul 2000 06:14:56 -0400
From: James <jamesmckay@MailAndNews.com>
Subject: Process problem
Message-Id: <398FAE09@MailAndNews.com>

Hi All,
      I'm currently stuck on a NT scripting problem.  I'm writing a script 
which  calls an external  16-bit DOS program via the "system()" call.  This 
external program generates a data file which my script then uses.

Unfortunately the DOS program is rather slow, so by the time it's halfway 
thru, my script has raced ahead and then gives an error, because the file it 
needs is only half complete.

I can't just use a "sleep" command, as the DOS program's speed is very 
dependant upon our network's current load, so sometimes it's fast and 
sometimes it's very, very slow!

What I need is a way to halt execution of my script at this point until the 
DOS program completes.  I've tried using the "wait" command but it appears 
to 
behave very differently to its Unix counterpart - in that it is completely 
ignored.

Any clues?

Thanks in advance.
James



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

Date: Thu, 20 Jul 2000 12:50:16 +0200
From: Pavel Hlavnicka <pavel@gingerall.cz>
Subject: Re: Process problem
Message-Id: <3976D968.20202@gingerall.cz>

Try install libwin32 library and look at win32/Process module. It allows 
"wait for process" (as far as I remember). I don't know, how it deals 
with 16-bit space.

P.

James wrote:

> Hi All,
>       I'm currently stuck on a NT scripting problem.  I'm writing a script 
> which  calls an external  16-bit DOS program via the "system()" call.  This 
> external program generates a data file which my script then uses.
> 
> Unfortunately the DOS program is rather slow, so by the time it's halfway 
> thru, my script has raced ahead and then gives an error, because the file it 
> needs is only half complete.
> 
> I can't just use a "sleep" command, as the DOS program's speed is very 
> dependant upon our network's current load, so sometimes it's fast and 
> sometimes it's very, very slow!
> 
> What I need is a way to halt execution of my script at this point until the 
> DOS program completes.  I've tried using the "wait" command but it appears 
> to 
> behave very differently to its Unix counterpart - in that it is completely 
> ignored.
> 
> Any clues?
> 
> Thanks in advance.
> James
> 



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

Date: Thu, 20 Jul 2000 12:50:21 +0200
From: Pavel Hlavnicka <pavel@gingerall.cz>
Subject: Re: Process problem
Message-Id: <3976D96D.90104@gingerall.cz>

Try install libwin32 library and look at win32/Process module. It allows 
"wait for process" (as far as I remember). I don't know, how it deals 
with 16-bit space.

P.

James wrote:

> Hi All,
>       I'm currently stuck on a NT scripting problem.  I'm writing a script 
> which  calls an external  16-bit DOS program via the "system()" call.  This 
> external program generates a data file which my script then uses.
> 
> Unfortunately the DOS program is rather slow, so by the time it's halfway 
> thru, my script has raced ahead and then gives an error, because the file it 
> needs is only half complete.
> 
> I can't just use a "sleep" command, as the DOS program's speed is very 
> dependant upon our network's current load, so sometimes it's fast and 
> sometimes it's very, very slow!
> 
> What I need is a way to halt execution of my script at this point until the 
> DOS program completes.  I've tried using the "wait" command but it appears 
> to 
> behave very differently to its Unix counterpart - in that it is completely 
> ignored.
> 
> Any clues?
> 
> Thanks in advance.
> James
> 



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

Date: 20 Jul 2000 06:58:43 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Quoting, interpolation and regular expressions
Message-Id: <slrn8ndns9.3do.abigail@alexandra.delanet.com>

Roman Stawski (roman.stawski@fr.adp.com) wrote on MMDXV September
MCMXCIII in <URL:news:3976B55B.266CAE75@fr.adp.com>:
-: Hi all,
-: 
-: PROBLEM
-: I want to change a string into a regular expression so that '*' is 
-: replaced '.*?'. Other patterns will be added at a later stage. 
-: Naturally characters like '.' should not be interpreted as special 
-: characters.

The snipped attempt to a solution below only shows what you don't
want to happen, but you are vague at what you do.

Is it that you want to patch dots, and as little as possible?

In that case:

    s/\*/\\.*?/g;

ought to do it.



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
 .qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
 .qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'


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

Date: 20 Jul 2000 14:16:53 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Quoting, interpolation and regular expressions
Message-Id: <964101528.4364@itz.pp.sci.fi>

In article <slrn8ndns9.3do.abigail@alexandra.delanet.com>, Abigail wrote:
>Roman Stawski (roman.stawski@fr.adp.com) wrote on MMDXV September
>MCMXCIII in <URL:news:3976B55B.266CAE75@fr.adp.com>:
>-: I want to change a string into a regular expression so that '*' is 
>-: replaced '.*?'. Other patterns will be added at a later stage. 
>-: Naturally characters like '.' should not be interpreted as special 
>-: characters.
>
>Is it that you want to patch dots, and as little as possible?
>In that case:
>    s/\*/\\.*?/g;
>ought to do it.

PSI::ESP indicates he wants to turn a glob into a regexp:

  sub glob2re {
      my $re = quotemeta(shift);
      $re =~ s/\\\*/.*?/g;
      $re =~ s/\\\?/./g;
      return qr/^$re$/s;
  }

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method."  -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: Thu, 20 Jul 2000 15:25:10 +0200
From: Roman Stawski <roman.stawski@fr.adp.com>
Subject: Re: Quoting, interpolation and regular expressions
Message-Id: <3976FDB5.3C2A4EB4@fr.adp.com>

Abigail wrote:
> 
> Roman Stawski (roman.stawski@fr.adp.com) wrote on MMDXV September
> MCMXCIII in <URL:news:3976B55B.266CAE75@fr.adp.com>:
> -: Hi all,
> -:
> -: PROBLEM
> -: I want to change a string into a regular expression so that '*' is
> -: replaced '.*?'. Other patterns will be added at a later stage.
> -: Naturally characters like '.' should not be interpreted as special
> -: characters.
> 
> The snipped attempt to a solution below only shows what you don't
> want to happen, but you are vague at what you do.

Hmmm, sorry about that...

> Is it that you want to patch dots, and as little as possible?

No... as much as possible. I'd _like_ all metacharacters to be 
matched as their quoted equivalents, apart from a small subset 
that I replace by substitution. 

So	*	becomes .*?
and	x	remains \x for all other metacharacters

Hence the reason that I tried to quote everything and only 
'unquoted' what I substituted. Unfortunately that seems to
run foul of interpolation.

#!perl -lw
use strict;

sub try {
    my $regexp = shift;
    print "Try using $regexp";
    print "[$_] ", (eval {$_ =~ $regexp}) ? "matched" : "didn't match"
        for ( 'ajunkb.c',   # Should match
              'ajunkbxc',   # Shouldn't match
            );
    print '---';
}

my $sample_user_input = 'a*b.c';
my $massaged_input = $sample_user_input;

for ($massaged_input) {
    s/([\\^.$|()[\]+?{}])/\\$1/g; # Beurkk
    s/\*/\.*?/g;
}
try(qr(^$massaged_input$));
___END__

This does what I want, but s/([\\^.$|()[\]+?{}])/\\$1/g; seems to
be doing what \Q...\E should, and less prettily. Hmmm....

[five minutes later...]

$massaged_input = quotemeta($sample_user_input);
$massaged_input =~ s/\\\*/\.*?/g;
try(qr(^$massaged_input$));

seems to do exactly what I wanted. 

Thanks Abigail, knew I could count on you!

-- 
Roman Stawski - ADPgsi


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

Date: Thu, 20 Jul 2000 14:07:10 GMT
From: Richard Lawrence <ralawrence@my-deja.com>
Subject: Removing (not extracting!) URL's from a string??
Message-Id: <8l711v$l62$1@nnrp1.deja.com>

Hi,

Quick question - I have some HTML source stored in a string and I'd
like to remove (not extract) the hyperlinks to other sites. I know this
will work:

  $content =~ /<a .+?>(.*?)<\/a>/$1/gis;

however its a bit too vaige, will fall over with anything slightly more
complicated and makes too many assumptions.

I looked at a few sites and they tend towards LinkExtor but that
extracts links and I just want to get rid of them completely.

Image links can stay, I'm not too fussed about them but the others do
need to be removed.

Can anyone suggest a better regexp or a module I could use?

Thanks

Rich


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


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

Date: Thu, 20 Jul 2000 14:46:30 GMT
From: nvp@spamnothanks.speakeasy.org (NP)
Subject: Re: Removing (not extracting!) URL's from a string??
Message-Id: <ahEd5.120121$t91.808622@news4.giganews.com>

Thu, 20 Jul 2000 14:07:10 GMT, Richard Lawrence <ralawrence@my-deja.com> wrote:
: 
: Can anyone suggest a better regexp or a module I could use?

I'd start with the Perl FAQ (which, IIRC, covers parsing HTML) and
then move onto the HTML::Parser module which you can install as part
of the libwww-perl5 bundle.

-- 
Nate II



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

Date: Thu, 20 Jul 2000 16:02:18 +0100
From: "Cal Henderson" <cal@iamcal.com>
Subject: Re: Substr question : what about the fourth argument?
Message-Id: <AvEd5.452$yE4.7531@news2-win.server.ntlworld.com>


"Abigail" <abigail@delanet.com> wrote...
:
: Which docs that should mention it don't mention it?
:

Programming Perl, 2nd Edition, Page 227

--
Cal Henderson

sub a{my$a=reverse shift;$a=~y/b-z/a-y/;unshift@a,$a;}sub b{$c.=reverse
shift; while(length($c)>=$b[0]){a(substr($c,0,$b[0]));$c=substr($c,$b[0]);
shift@b;}}@b=(6,3,5,4,10,6,4,4,2,1);$a="l?jouipv"."ezvmxpbuxih";$a.=
",jofoqqibmzamsfsfxfjtuiIg";while($a ne ""){b(substr($a,0,2));$a=
substr($a,2);}print join(" ",@a);




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

Date: Thu, 20 Jul 2000 12:09:50 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Suggestion for syntax change
Message-Id: <MPG.13e18962f6cfd5b69896fc@news>

Bart Lateur wrote ..
>jason wrote:
>
>>would there be many (any?) 
>>situations where you'd be interested in going from index (x) to index 
>>(Z-y) (where Z represents the length of the unknown LIST) ??
>
>Try skipping the first 2 items.
>
>	@rest = @somelist[2 .. -1];
>
>If you're talking about dropping a few items at the end: indeed, that
>would be rare.

that's an array .. not an unknown list .. you could just do

  @rest = @somelist[2..$#somelist];

but .. assuming you meant @somelist to represent an unknown LIST .. then 
that's not enough of an example

I mean a real situation where you don't know the length of the list - or 
how many items will be in it .. when would you want everything relative 
to the end of an unknown list ??

I can think of HEAPS of situations in named LISTs (arrays) where you'd 
want the last x elements .. or all but the first two elements .. but 
those situations are already handled with $# (as in the example above)

I still contend that (LIST)[2..-1] should equate to (LIST)[2,1,0,-1] .. 
and 2..-1 should equate to (2,1,0,-1)

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Thu, 20 Jul 2000 12:14:01 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Suggestion for syntax change
Message-Id: <MPG.13e18a601a44c1519896fd@news>

Abigail wrote ..
>Have you tried this?
>
>        @somelist = ('a' .. 'z');
>        @rest     = @somelist [2 .. -1];
>
>        print "[@rest]\n";
>        __END__
>        []
>
>
>A range starting at 2 and ending at -1 contains exactly 0 elements....

Abigail .. you're problem is with the '..' operator .. it will only 
produce a list when the first argument is less than or equal to the 
second

oh .. hang on .. did I take what you're saying completely out of context 
- oh my .. what a silly thing for me to do ;)

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Thu, 20 Jul 2000 09:11:07 -0500
From: Dale Bohl <dbohl@sgi.com>
Subject: Re: Translation from csh to Perl?
Message-Id: <3977087B.BCBFAD32@sgi.com>

"Andreas Vörg" wrote:
> 
> Hi,
> 
> Is there a translator like a2p or s2p for csh scripts availible?
> It also helps if there is a parser that extracts the csh commands at runtime
> and translates them to Perl commands.
> 
> I have to translate lots of csh scripts!
> 
> Thanks
> Andreas

See perlfaq8 - How can I convert my shell script to perl?

at 

http://www.perl.com/CPAN-local/doc/FAQs/FAQ/PerlFAQ.html

Please read the FAQs before asking these types of questions.

-- 

Thanks,
Dale

Dale Bohl
SGI Information Services
dbohl@sgi.com
(715)-726-8406
http://wwwcf.americas.sgi.com/~dbohl/
perl -e 'print "Just Another Perl Hacker.\n";'


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

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


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