[6879] in Perl-Users-Digest
Perl-Users Digest, Issue: 504 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 20 20:17:15 1997
Date: Tue, 20 May 97 17:00:21 -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, 20 May 1997 Volume: 8 Number: 504
Today's topics:
A complex sorting routine... (Niksun)
Re: A complex sorting routine... <gm@mgm-net.de>
Re: help: how to compare some dd:mm:yy date with sistem <psrc@corp.airmedia.com>
Re: mode results from stat() <jesse@ginger.sig.bsh.com>
NT 4.0 CGI with PERL <no-sleep@televar.com>
Re: Opening a pipe under Solaris <dorman@s3i.com>
Patch to Perl 5.004 for case-insensitive patterns (REFC (Chip Salzenberg)
Re: Pattern matching question <usenet-tag@qz.little-neck.ny.us>
Perl 5.004 is available (Chip Salzenberg)
Re: Perl Textbooks <dean@tbone.biol.sc.edu>
Re: perl4.036 to 5.003 code breaks <jesse@ginger.sig.bsh.com>
printing 2 dimentinal Hash table <ahenig@iil.intel.com>
Q: Experience w/IPC::Open2 ?? (Marc Aitkin)
Re: Q: local in list contex? <jay@rgrs.com>
Re: Year 2000 compliance <usenet-tag@qz.little-neck.ny.us>
Re: Year 2000 Issues with Perl5 (Kerry Schwab)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 20 May 1997 21:44:04 GMT
From: niksun@lconn.net (Niksun)
Subject: A complex sorting routine...
Message-Id: <33821a02.27919821@news.inetw.net>
I'm using Perl to get input from an HTML document, parse it for what
I'm looking for, and then sort parts of it. Actually, the HTML
document is a list of links separated into sections:
<!--begin: SectionX-->
<A HREF="http://url1.here">link1 here</A><BR>
<A HREF="http://url2.here">link2 here</A><BR>
<!--end: SectionX-->
<!--begin: SectionZ-->
<A HREF="http://url4.here">link4 here</A><BR>
<A HREF="http://url3.here">link3 here</A><BR>
<!--end: SectionY-->
<!--begin: SectionY-->
<A HREF="http://url6.here">link6 here</A><BR>
<A HREF="http://url5.here">link5 here</A><BR>
<!--end: SectionZ-->
I first want to sort the sections (SectionX, SectionZ, SectionY,
etc...) then, I want to sort the links within the section by link
title (link4 here, link3 here, etc...)
What's the best way to do this in the least amount of code?
Niksun
------------------------------
Date: Wed, 21 May 1997 01:15:24 +0200
From: Georg Moritz <gm@mgm-net.de>
Subject: Re: A complex sorting routine...
Message-Id: <3382308C.2E1DC7C9@mgm-net.de>
Hello, Niksun,
Niksun wrote:
>
> <!--begin: SectionZ-->
> <A HREF="http://url4.here">link4 here</A><BR>
> <A HREF="http://url3.here">link3 here</A><BR>
> <!--end: SectionY-->
>
> <!--begin: SectionY-->
> <A HREF="http://url6.here">link6 here</A><BR>
> <A HREF="http://url5.here">link5 here</A><BR>
> <!--end: SectionZ-->
> I first want to sort the sections (SectionX, SectionZ, SectionY,
> etc...) then, I want to sort the links within the section by link
> title (link4 here, link3 here, etc...)
>
> What's the best way to do this in the least amount of code?
first you fix up nested sections:
<!--begin: SectionZ-->
<!--end: SectionY-->
<!--begin: SectionY-->
<!--end: SectionZ-->
then you build a loop iterating over your input
in this loop you push() the cleaned() - a subroutine you've got
to write - entries into it's apropriate %entry entry, depending
upon /<!--begin:\s*(\w+)/ && ($section = $1? $1: undef), then you sort
your %entry keys and sort $entry{$section}, each is an anonymous
array. Write some pieces of code for it, run wc -c over them, and you're
figure out.
taking a pencil and the sheets of the doc printed out is the least ...
... no code at all ...
>
> Niksun
-- gm
PS: Sorry. Are you suggesting anybody to do your task?
Or do you have a specific perl problem? In the latter case
check Randal's Homepage and the pages about sorting, get the
Camel book or post again :-)
------------------------------
Date: Tue, 20 May 1997 12:38:07 -0400
From: Paul S R Chisholm <psrc@corp.airmedia.com>
To: Miran Sepic <miran.sepic4@mss.tel.hr>
Subject: Re: help: how to compare some dd:mm:yy date with sistem date (localtime)?
Message-Id: <3381D36F.5C90@corp.airmedia.com>
Mike Stok's answers were pretty good: Use the "time_t" value (which
time() will return, and which many Perl functions use), or use one of
the Date modules in CPAN (http://www.perl.com/perl/CPAN/).
I recently took a third approach. I was planning on using the
Date::Manip module from CPAN, and adopted its date format:
YYYYMMDDhh:mm:ss
YYYY = year
MM = month (01-12)
DD = day of month (01-31)
hh = hour (24 hour style, 00-23)
mm = minutes
ss = seconds
For example, I'm posting this (local time) at 1997052012:37:00 or so.
One of the several nice things about this format is that you can compare
two date/time values, and one will be less than, equal to, or greater
than the other as the date/times are.
(By the time I was done, I managed to live without Date::Manip entirely.
Just as well; it was a little slow to load, and its functions were a
little slow themselves.) --PSRC
------------------------------
Date: 20 May 1997 12:39:33 -0400
From: Jesse Glick <jesse@ginger.sig.bsh.com>
Subject: Re: mode results from stat()
Message-Id: <4opvum6qt6.fsf@ginger.sig.bsh.com>
Magius@Greenwood.net (Jeremy T. Elston) writes:
> On a file with permissions of 0444, $mode results in 33060.
>
> What format is $mode returned in??
Octal 33060 is 0100444. If you take a look at chown(2) or the like, it appears
that you could logically-and all your stat-modes with 07777 to get what you
actually want: the permission bits, plus sticky bits &c. The higher ones are
file-typing bits, though I am not sure what bits are for what; 0100000 seems
to be for regular files, 040000 for directories.
--
Jesse "Da Juice" Glick
mailto:jglick@sig.bsh.com
617-867-1017
------------------------------
Date: Tue, 20 May 1997 15:36:37 -0700
From: Shane Monroe <no-sleep@televar.com>
Subject: NT 4.0 CGI with PERL
Message-Id: <33822775.E82AE5D5@televar.com>
I am migrating from a Novell Web Server to Windows NT running IIS. My
PERL scripts don't seem to work quite right - they run, no problem. But
those involving file operations, namely my site search engine no longer
seem to function properly. I have also tried Matt's Archives 'Simple
Search' program which is about as universal as it comes and IT doesn't
work.
Is there anyone who can comment on porting this specific type of file to
the NT environment? Using some coding tricks I have determined that the
programs doesn't seem to find ANY files in the 'to be searched'
directory (the foreach $file loop).
Is this an NT quirk? Is there a work around. Yes, I have tried all the
PERL 32 FAQs and explored the WWW and IRC almost to the point of
madness. Any help or suggestions would be very appreciated.
------------------------------
Date: 20 May 1997 13:49:51 -0400
From: Clark Dorman <dorman@s3i.com>
Subject: Re: Opening a pipe under Solaris
Message-Id: <dk9ku11a8.fsf@s3i.com>
Frank Buntschuh <P26053@email.mot.com> writes:
> I seem to be having a problem with opening pipes under Solaris. I am
> trying to run the "standard" example of a pipe, like this:
>
> #!/tools/shareware/bin/perl -w
>
> use sigtrap;
> use Socket;
>
> open(STATUS, "netstat |") || die "pipe failed $!";
> print "After the pipe open\n";
> while(<STATUS>) {
> print "in the pipe loop\n";
> }
>
> On a SPARC Solaris box (SunOS 5.4), I never seem to get into the pipe
> loop, and the entire output of the netstat is echoed to the screen. On
> an older SPARC box (SunOS 4.1.3) I get the expected stream of "in the
> pipe loop". I need to catch the pipe under Solaris, as some data
> processing I am trying to run needs a precompiled binary that only runs
> on Solaris, and routing the output of this binary to file produces an
> ASCII file that is often 100MB or larger.
>
> BTW - all of this is using perl v5.001 patch 1m.
I think you need the newer perl version. When done on SunOS 5.5, Sparc-20,
perl 5.003_93, it gives:
% temp.pl
After the pipe open
in the pipe loop
...[lots more of these]...
in the pipe loop
% perl -V
Summary of my perl5 (5.0 patchlevel 3 subversion 93) configuration:
Platform:
osname=solaris, osvers=2.5, archname=sun4-solaris
uname='sunos blackbird 5.5 generic sun4m sparc sunw,sparcstation-20 '
...
So it seems to work now. However, if I use my old perl version, it just
hangs completely.
% temp3.pl
...[nothin'! Not even the "After the pipe open", full cpu usage]...
^C
% perl5.003 -V
Summary of my perl5 (5.0 patchlevel 3 subversion 0) configuration:
Platform:
osname=solaris, osver=2.5, archname=sun4-solaris
uname='sunos blackbird 5.5 generic sun4m sparc sunw,sparcstation-20 '
...
--
Clark Dorman "Evolution is cleverer than you are."
http://cns-web.bu.edu/pub/dorman/D.html -Francis Crick
------------------------------
Date: 20 May 1997 17:55:02 GMT
From: chip@rio.atlantic.net (Chip Salzenberg)
Subject: Patch to Perl 5.004 for case-insensitive patterns (REFCASE1)
Message-Id: <5lsohm$m4t$1@nadine.teleport.com>
In a case-insensitive pattern match (//i), back-references to previous
parenthesized subpatterns (e.g. the \1 in "/(\w+)\s+\1/i") should be
case-insensitive as well. In Perl 5.004, they aren't. This patch fixes
that problem.
Index: patchlevel.h
***************
*** 41,42 ****
--- 41,43 ----
+ ,"REFCASE1 - fix for case-insensitivity in regex backreferences"
,NULL
};
Index: regcomp.h
***************
*** 73,95 ****
#define NBOUND 22 /* no Match "" at any word non-boundary */
#define NBOUNDL 23 /* no Match "" at any word non-boundary */
! #define REF 24 /* num Match some already matched string */
! #define OPEN 25 /* num Mark this point in input as start of #n. */
! #define CLOSE 26 /* num Analogous to OPEN. */
! #define MINMOD 27 /* no Next operator is not greedy. */
! #define GPOS 28 /* no Matches where last m//g left off. */
! #define IFMATCH 29 /* no Succeeds if the following matches. */
! #define UNLESSM 30 /* no Fails if the following matches. */
! #define SUCCEED 31 /* no Return from a subroutine, basically. */
! #define WHILEM 32 /* no Do curly processing and see if rest matches. */
! #define ALNUM 33 /* no Match any alphanumeric character */
! #define ALNUML 34 /* no Match any alphanumeric char in locale */
! #define NALNUM 35 /* no Match any non-alphanumeric character */
! #define NALNUML 36 /* no Match any non-alphanumeric char in locale */
! #define SPACE 37 /* no Match any whitespace character */
! #define SPACEL 38 /* no Match any whitespace char in locale */
! #define NSPACE 39 /* no Match any non-whitespace character */
! #define NSPACEL 40 /* no Match any non-whitespace char in locale */
! #define DIGIT 41 /* no Match any numeric character */
! #define NDIGIT 42 /* no Match any non-numeric character */
/*
--- 73,97 ----
#define NBOUND 22 /* no Match "" at any word non-boundary */
#define NBOUNDL 23 /* no Match "" at any word non-boundary */
! #define REF 24 /* num Match already matched string */
! #define REFF 25 /* num Match already matched string, folded */
! #define REFFL 26 /* num Match already matched string, folded in loc. */
! #define OPEN 27 /* num Mark this point in input as start of #n. */
! #define CLOSE 28 /* num Analogous to OPEN. */
! #define MINMOD 29 /* no Next operator is not greedy. */
! #define GPOS 30 /* no Matches where last m//g left off. */
! #define IFMATCH 31 /* no Succeeds if the following matches. */
! #define UNLESSM 32 /* no Fails if the following matches. */
! #define SUCCEED 33 /* no Return from a subroutine, basically. */
! #define WHILEM 34 /* no Do curly processing and see if rest matches. */
! #define ALNUM 35 /* no Match any alphanumeric character */
! #define ALNUML 36 /* no Match any alphanumeric char in locale */
! #define NALNUM 37 /* no Match any non-alphanumeric character */
! #define NALNUML 38 /* no Match any non-alphanumeric char in locale */
! #define SPACE 39 /* no Match any whitespace character */
! #define SPACEL 40 /* no Match any whitespace char in locale */
! #define NSPACE 41 /* no Match any non-whitespace character */
! #define NSPACEL 42 /* no Match any non-whitespace char in locale */
! #define DIGIT 43 /* no Match any numeric character */
! #define NDIGIT 44 /* no Match any non-numeric character */
/*
***************
*** 122,126 ****
/*CURLY*/ 4, /*CURLYX*/ 4,
0,0,0,0,0,0,0,0,0,0,0,0,
! /*REF*/ 2, /*OPEN*/ 2, /*CLOSE*/ 2,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
};
--- 124,128 ----
/*CURLY*/ 4, /*CURLYX*/ 4,
0,0,0,0,0,0,0,0,0,0,0,0,
! /*REF*/ 2, 2, 2, /*OPEN*/ 2, /*CLOSE*/ 2,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
};
***************
*** 156,159 ****
--- 158,163 ----
NBOUND,
REF,
+ REF,
+ REF,
OPEN,
CLOSE,
***************
*** 182,186 ****
#else
EXT char varies[] = {
! BRANCH, BACK, STAR, PLUS, CURLY, CURLYX, REF, WHILEM, 0
};
#endif
--- 186,190 ----
#else
EXT char varies[] = {
! BRANCH, BACK, STAR, PLUS, CURLY, CURLYX, REF, REFF, REFFL, WHILEM, 0
};
#endif
Index: regcomp.c
*************** tryagain:
*** 904,908 ****
else {
regsawback = 1;
! ret = reganode(REF, num);
*flagp |= HASWIDTH;
while (isDIGIT(*regparse))
--- 904,910 ----
else {
regsawback = 1;
! ret = reganode((regflags & PMf_FOLD)
! ? ((regflags & PMf_LOCALE) ? REFFL : REFF)
! : REF, num);
*flagp |= HASWIDTH;
while (isDIGIT(*regparse))
*************** char *op;
*** 1667,1670 ****
--- 1669,1678 ----
case REF:
sv_catpvf(sv, "REF%d", ARG1(op));
+ break;
+ case REFF:
+ sv_catpvf(sv, "REFF%d", ARG1(op));
+ break;
+ case REFFL:
+ sv_catpvf(sv, "REFFL%d", ARG1(op));
break;
case OPEN:
Index: regexec.c
*************** char *prog;
*** 826,830 ****
--- 826,834 ----
nextchar = UCHARAT(++locinput);
break;
+ case REFFL:
+ regtainted = TRUE;
+ /* FALL THROUGH */
case REF:
+ case REFF:
n = ARG1(scan); /* which paren pair */
s = regstartp[n];
*************** char *prog;
*** 836,845 ****
break;
/* Inline the first character, for speed. */
! if (UCHARAT(s) != nextchar)
sayNO;
ln = regendp[n] - s;
if (locinput + ln > regeol)
sayNO;
! if (ln > 1 && memNE(s, locinput, ln))
sayNO;
locinput += ln;
--- 840,856 ----
break;
/* Inline the first character, for speed. */
! if (UCHARAT(s) != nextchar &&
! (OP(scan) == REF ||
! (UCHARAT(s) != ((OP(scan) == REFF
! ? fold : fold_locale)[nextchar]))))
sayNO;
ln = regendp[n] - s;
if (locinput + ln > regeol)
sayNO;
! if (ln > 1 && (OP(scan) == REF
! ? memNE(s, locinput, ln)
! : (OP(scan) == REFF
! ? ibcmp(s, locinput, ln)
! : ibcmp_locale(s, locinput, ln))))
sayNO;
locinput += ln;
--
Chip Salzenberg - a.k.a. - <chip@pobox.com>
"Most organizations reward individuals and groups that
choose to re-invent the wheel." -- Bjarne Stroustrup
------------------------------
Date: 20 May 1997 17:33:25 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: Pattern matching question
Message-Id: <5lsn95$luf$1@news.netusa.net>
Chipmunk <Ronald.J.Kimball@dartmouth.edu> wrote:
>ddougal@concentric.net (David Dougal) writes:
>> Here is the output: element 1 is t0123456787
>> found a lost
>> The output should have been: element 1 is t0123456787
>> found a tie
>> # match the l character followed by any digits
>> } elsif ($array[count] =~ /^l\d*/) {
As Chipmunk pointed out in the text I have deleted, you need a $ in
front of count. Also note that your "\d*" is useless there. That will
match anything that starts with an 'l'.
>> # match the t character followed by any digits
>> } elsif ($array[count] =~ /^t\d*/) {
Same problem here.
Elijah
------
might be your problem, I don't have the original article to check all the code
------------------------------
Date: 20 May 1997 17:54:19 GMT
From: chip@rio.atlantic.net (Chip Salzenberg)
Subject: Perl 5.004 is available
Message-Id: <5lsogb$m4l$1@nadine.teleport.com>
The Perl development team is pleased to announce the release of Perl 5.004.
You should be able to install and use this release of Perl under almost all
families, mutations, and imitations of UNIX, as well as VMS, OS/2, QNX,
LynxOS, AmigaOS, Plan 9, and Windows NT. If this release of Perl is built
under Windows NT, it can also be used under Windows 95.
It is *vital* that you read the file "INSTALL" before building this
release; it contains information you absolutely need to know. For example,
"INSTALL" explains how you can install Perl 5.004 without removing previous
version(s) of Perl, and how you can make Perl 5.004 binary-compatible with
Perl 5.003 (and why you have a choice).
There are several new functions and features in Perl 5.004, including a
small number of unavoidable incompatibilies. See the change notices for
details, in the file "pod/perldelta.pod". It is *highly* recommended that
you read "pod/perldelta.pod" before using this release if you have any
previous experience with Perl.
If you find a bug, please report it to us with the "perlbug" script in the
"utils" directory of the distribution. Since you may have older versions
of "perlbug" installed, run it as "./perl utils/perlbug"; to display its
documentation, use the "-h" flag. If you cannot send external E-Mail from
your development platform, you can still use "perlbug" to prepare the bug
report and save it to a file, which you should then mail to
<perlbug@perl.com>.
If Perl didn't even compile, then you won't be able to use "perlbug".
Instead, compose your bug report by hand, being sure to include the output
of the "myconfig" shell script included in the distribution, and mail it to
<perlbug@perl.com>.
We re-emphasize: *Please* read "INSTALL" and "pod/perldelta.pod". We are
happy to answer questions, but our time is limited. By reading the
excellent documentation included with Perl before asking for help, you will
save yourself time, you will save us time, and you will help us debug the
documentation.
NOTE: One user-visible bug in Perl 5.004 was found between the creation of
Perl 5.004 and its announcement. A bug fix will be posted separately.
You will find this release on CPAN, the Comprehensive Perl Archive Network.
The following URL at Tom Christiansen's web server (perl.com) will
automatically direct your request to a CPAN FTP site appropriate for your
location:
http://www.perl.com/CPAN/src/5.0/perl5.004.tar.gz
If you wish to retrieve the file entirely with HTTP, you can use this URL
at The Perl Institute (perl.org):
http://www.perl.org/CPAN/src/5.0/perl5.004.tar.gz
Finally, to quote Douglas Adams: "Share and enjoy!"
Signed,
The Perl Development Team
--
Chip Salzenberg - a.k.a. - <chip@pobox.com>
"Most organizations reward individuals and groups that
choose to re-invent the wheel." -- Bjarne Stroustrup
------------------------------
Date: 20 May 1997 17:46:37 -0400
From: Dean Pentcheff <dean@tbone.biol.sc.edu>
Subject: Re: Perl Textbooks
Message-Id: <m1n2ppbyv6.fsf@nauplius.psc.sc.edu>
"Overman, Bradshaw Hunter" <s003mto@discover.wright.edu> writes:
> I was wondering if anyone knew of any textbooks written for Perl. Not
> the ones where authors list scripts for you to copy, but a textbook like
> Turbo Pascal, where the language is defined, syntax, etc. The only
> programming experience is one wuarter of TP 7.0.
I _think_ what you're looking for is books that introduce Perl, both
(or either) at an introductory and advanced level. The canonical
recommendations for those purposes are:
Learning Perl
Programming Perl
Both are published by O'Reilly and Associates
(<URL:http://www.ora.com>) and are excellent.
-Dean
--
N. Dean Pentcheff <pentcheff@acm.org> WWW: http://tbone.biol.sc.edu/~dean/
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-3936)
PGP ID=768/22A1A015 Keyprint=2D 53 87 53 72 4A F2 83 A0 BF CB C0 D1 0E 76 C0
Get PGP keys and information with the command: "finger dean@tbone.biol.sc.edu"
------------------------------
Date: 20 May 1997 12:48:39 -0400
From: Jesse Glick <jesse@ginger.sig.bsh.com>
Subject: Re: perl4.036 to 5.003 code breaks
Message-Id: <4ooha66qe0.fsf@ginger.sig.bsh.com>
Wart <wart@ugcs.caltech.edu> writes:
> #!/usr/local/bin/perl
>
> while(<STDIN>) {
> if (m/([0-9])+\s+setlinewidth/) {
> $1 && ($width = --$1);
> s/[0-9]\s+setlinewidth/$width setlinewidth/;
> }
> print;
> }
`--$1'. $1 is considered constant in general, I think. Why on Earth would you
want to decrement it anyway? Do you want `$1-1' or somesuch?
--
Jesse "Da Juice" Glick
mailto:jglick@sig.bsh.com
617-867-1017
------------------------------
Date: Tue, 20 May 1997 17:03:28 +0300
From: Allon Henig <ahenig@iil.intel.com>
Subject: printing 2 dimentinal Hash table
Message-Id: <3381AF30.A5E@iil.intel.com>
Hi,
how is it possible to print each value of a 2 dimentional Hash table ?
It Should be something like:
foreach $key (keys %HashTable) {
...do something..
}
but this is a >>2<< dimentional HT?!
Thanks, ALLon
------------------------------
Date: 20 May 1997 16:33:54 GMT
From: maitkin@cv.hp.com (Marc Aitkin)
Subject: Q: Experience w/IPC::Open2 ??
Message-Id: <5lsjpi$p30@hpcvsnz.cv.hp.com>
I wrote a class to encapsulate some basic querys
going to a database. The class itself calls a C process
that handles the SQL connections to databases, and it also
uses IPC::Open2 to open a bi-directional channel to the C
process. Now, I wrote the C process also, and the output
*is* not buffered, so all is ok there. But, I am noticing
some strange behaviour with this class, and the only thing
I can remotely think may be causing this, is the mechanics
of Open2. Here is what is happenning.
If I run a process that uses the class to do a query from
the command line, all is fine and I get a normal return from
the query.
example:
$ ./do_query
$ do_query:starting
$ data
$ data
$ data
$ do_query:ending
Now the funny stuff starts to happen when I redirect the stdout
of the process. What happens is I get dual copy's of anything
I print to stdout, like headers and so forth. After the data
from the query is returned, normal prints resume.
To re-use the example above:
$ ./do_query > out
now out contains:
$ cat out
do_query:starting
do_query:starting ****(This is the second copy of this string being printed!)
data
data
data
do_query:ending
$
This is quite confusing. Similar behaviour also happens if one pipes the output
to anything else. If you have had the patience to read this far, I thank you.
Any light that could be shed on this would be most appreciated.
marc
------------------------------
Date: 20 May 1997 13:02:09 -0400
From: Jay Rogers <jay@rgrs.com>
To: jwilleke@ix.netcom.com (Jonathan C. Willeke)
Subject: Re: Q: local in list contex?
Message-Id: <82n2pq6pri.fsf@shell2.shore.net>
jwilleke@ix.netcom.com (Jonathan C. Willeke) writes:
> Consider the following Perl code fragment:
>
> local @list = ( 0, 1, 2, 3 );
> local @array[@list] = ( "I'm", "just", "a", "bill" );
> print "@array\n";
>
> Here's the output:
>
> I'm
>
> Why do I need to surround
>
> local @array[@list] = ...
>
> with parens, but not
>
> local @list = ...
>
Just because! :-)
> ? Does the Perl interpreter not understand that the array slice is a
> list? Thanks in advance for responses.
No, it's because Perl *does* recognize the array slice as a list that
you must provide parens.
Here's what the man page has to say:
local EXPR
A local modifies the listed variables to be local to
the enclosing block, subroutine, eval{} or do. If
more than one value is listed, the list must be
placed in parens.
I can see why this is confusing. I think it would take someone
familiar with perl's parser to fully explain the distinction between
localizing one array variable and initializing it, and localizing one
array variable and initializing a slice of it.
--
Jay Rogers
jay@rgrs.com
------------------------------
Date: 20 May 1997 17:42:02 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: Year 2000 compliance
Message-Id: <5lsnpa$mg1$1@news.netusa.net>
Tung-chiang Yang <tcyang@netcom.com> wrote:
>Guys, take it easy. At that time IBM will have a giant software called
>"Deep Brew" with artificial intelligence, and it can search through
>all softwares in C, C++, Java, Perl, Cobol, Pascal, Basic,
>8086 Assembly ..... and correct the 2038 problem by rewriting the codes
>when scanning, just like today we use antivirus programs to disinfect
>our programs :)
_The Economist_ has taken interest in a company that claims it can do
that now.
>(But maybe Deep Brew still has no clues about Microsoft "Window 38"
>with code name "Las Vegas")
Would't the code name "Snub nosed Suicide Solution" be more apropos
for for an OS that probably couldn't be taken cross country in a
station wagon full of DAT tapes in just one trip. (Assuming M$ bloat
continues at current rates.) (Never overestimate the bandwidth of
a stationwagon full of tapes in a battle against M$.)
Elijah
------
OTOH, _The Economist_ predicts a consolidation of US ISPs to 40 by 2001
------------------------------
Date: 20 May 1997 17:20:18 -0600
From: kschwab@nyx10.cs.du.edu (Kerry Schwab)
Subject: Re: Year 2000 Issues with Perl5
Message-Id: <5ltbji$i8f@nyx10.cs.du.edu>
In article <Pine.GSO.3.96.970515140943.29695Q-100000@kelly.teleport.com>,
Tom Phoenix <rootbeer@teleport.com> wrote:
>On 15 May 1997, Tony Zaki wrote:
>
>> Could someone please direct me to any site that has more information
>> regarding Perl5 and problems with the year 2000 ???
>
>You mean www.dev.null? :-)
>
>Or maybe you want the Perl FAQ, which is on CPAN.
>
> http://www.perl.org/CPAN/
> http://www.perl.com/CPAN/
The perl faq's answer is a little incomplete.
A brief "grep" around my /opt/local/lib/perl finds:
(Version 5.003_25, not the latest, but pretty recent)
>From CPAN.pm:
sub autobundle {
....
my($y,$m,$d) = (localtime)[5,4,3];
$y+=1900;
>From ctime.pl:
sub ctime {
...
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
($TZ eq 'GMT') ? gmtime($time) : localtime($time);
$year += 1900;
sprintf("%s %s %2d %2d:%02d:%02d %s%4d\n",
$DoW[$wday], $MoY[$mon], $mday, $hour, $min, $sec, $TZ, $year);
Other gems:
Time/Local.pm: $year -= 1900
Time/Local.pm: if $year > 1900;
Time/localtime.pm: printf "Year is %d\n", localtime->year() + 1900;
pod/perlfunc.pod:the range 0..6 and $year is year-1900, that is, $year is 123 in year
site_perl/CGI.pm: $year += 1900 unless $year < 100;
Now I've not perused these in any great detail and some of it may be just
fine, , but it looks to me like several bundled perl .pm and .pl files may
have Y2K problems. At least someone should have a look around before
declaring that perl is immune.
--
Kerry
>
>Hope this helps!
>
>-- Tom Phoenix http://www.teleport.com/~rootbeer/
>rootbeer@teleport.com PGP Skribu al mi per Esperanto!
>Randal Schwartz Case: http://www.lightlink.com/fors/
>
------------------------------
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 504
*************************************