[22338] in Perl-Users-Digest
Perl-Users Digest, Issue: 4559 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 12 18:10:47 2003
Date: Wed, 12 Feb 2003 15:10:14 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 12 Feb 2003 Volume: 10 Number: 4559
Today's topics:
Please explain this weird error message <elf@ee.ryerson.ca>
Re: Please explain this weird error message (Walter Roberson)
Re: Please explain this weird error message <shanem@nospam.ll.mit.edu>
Re: Please explain this weird error message (Tad McClellan)
Re: Please explain this weird error message <flavell@mail.cern.ch>
Re: Please explain this weird error message <jedgell@adelphia.net>
Re: problem with "piping" data from STDOUT into the Per <goldbb2@earthlink.net>
Re: puzzling operator priorities <bkennedy@hmsonline.com>
Re: puzzling operator priorities <krahnj@acm.org>
Re: puzzling operator priorities <chang0@adelphia.net>
Re: Re Installing modules from CPAN (Randy Kobes)
Re: Saving/Editing SQL queries <goldbb2@earthlink.net>
Re: strict and warnings <abigail@abigail.nl>
Re: strict and warnings <tassilo.parseval@post.rwth-aachen.de>
Re: Syntax error <uri@stemsystems.com>
use integer, strange negative results <mthunter@students.uiuc.edu>
Re: use integer, strange negative results (Jay Tilton)
Using a variable to create a slice (Terry Bolands)
Re: Using a variable to create a slice <kjetilsk.skotheim@usit.uio.no>
Re: Using a variable to create a slice (Jay Tilton)
Re: Using a variable to create a slice <jkeen@concentric.net>
Re: Using a variable to create a slice <dha@panix.com>
Weirdness with 'use constant X' and open(X ... ) (pt)
Re: Weirdness with 'use constant X' and open(X ... ) <tassilo.parseval@post.rwth-aachen.de>
Re: Win32::OLE GroupItems PPT <goldbb2@earthlink.net>
Re: Win32::OLE GroupItems PPT (Jay Tilton)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 12 Feb 2003 15:00:09 -0500
From: Luis Fernandes <elf@ee.ryerson.ca>
Subject: Please explain this weird error message
Message-Id: <x0of5hclrq.fsf@ee.ryerson.ca>
Version:
This is perl, v5.6.1 built for sun4-solaris
Program:
------------------------------------------------------------------------
#!/usr/local/bin/perl
$prfile="ps";
$prfile=~s/ps/PostScript File/;
printf("$prfile\n");
------------------------------------------------------------------------
When run, "PostScript File" is printed (as expected).
Modified Line 3 (change "ps" to "*.ps") like so:
$prfile=~s/*.ps/PostScript File/;
When run, I get the error: "Quantifier follows nothing before HERE mark in
regex m/* << HERE .ps/ at ttt line 3."
Explain please.
------------------------------
Date: 12 Feb 2003 21:02:30 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Please explain this weird error message
Message-Id: <b2ecp6$13$1@canopus.cc.umanitoba.ca>
In article <x0of5hclrq.fsf@ee.ryerson.ca>,
Luis Fernandes <elf@ee.ryerson.ca> wrote:
:This is perl, v5.6.1 built for sun4-solaris
:$prfile=~s/*.ps/PostScript File/;
:When run, I get the error: "Quantifier follows nothing before HERE mark in
:regex m/* << HERE .ps/ at ttt line 3."
:Explain please.
$prfile=~s/.*\.ps/PostScript File/;
The '*' does not mean "any number of any characters": the '*' means
'any number of the most-immediately previous pattern'.
--
The Knights Of The Lambda Calculus aren't dead --this is their normal form!
------------------------------
Date: Wed, 12 Feb 2003 16:15:02 -0500
From: Shane McDaniel <shanem@nospam.ll.mit.edu>
Subject: Re: Please explain this weird error message
Message-Id: <3E4AB956.BAA96566@nospam.ll.mit.edu>
Luis Fernandes wrote:
>
> Version:
> This is perl, v5.6.1 built for sun4-solaris
>
> Program:
> ------------------------------------------------------------------------
> #!/usr/local/bin/perl
> $prfile="ps";
> $prfile=~s/ps/PostScript File/;
> printf("$prfile\n");
> ------------------------------------------------------------------------
>
> When run, "PostScript File" is printed (as expected).
>
> Modified Line 3 (change "ps" to "*.ps") like so:
>
> $prfile=~s/*.ps/PostScript File/;
>
> When run, I get the error: "Quantifier follows nothing before HERE mark in
> regex m/* << HERE .ps/ at ttt line 3."
>
> Explain please.
Your * has nothing to operate on, perhaps /.*\.ps/ is what you want.
Also remember that \. is the char '.' . represents any character in a
regexp.
Perhaps you need a perl regexp refresher or a fresher even. Get the
camel book if you don't have it and review the regexp section. If you
don't understand this stuff well you'll just keep shooting yourself in
the foot and sometimes the Perl interpreter won't tell you.
-shane
------------------------------
Date: Wed, 12 Feb 2003 15:13:22 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Please explain this weird error message
Message-Id: <slrnb4le7i.4ka.tadmc@magna.augustmail.com>
Luis Fernandes <elf@ee.ryerson.ca> wrote:
> $prfile=~s/*.ps/PostScript File/;
^^
^^ transposed?
> When run, I get the error: "Quantifier follows nothing before HERE mark in
> regex m/* << HERE .ps/ at ttt line 3."
>
> Explain please.
Look it up in the manual please.
perldoc perldiag
(F) You started a regular expression with a quantifier. Backslash it if you
meant it literally. The <-- HERE shows in the regular expression about
where the problem was discovered. See perlre.
Or, put this at the top of your program, and perl will look it up for you:
use diagnostics;
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 12 Feb 2003 23:11:37 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Please explain this weird error message
Message-Id: <Pine.LNX.4.53.0302122310430.20639@lxplus090.cern.ch>
On Feb 12, Tad McClellan inscribed on the eternal scroll:
> Look it up in the manual please.
Quite.
Perhaps the group could also hold a sweepstake on the least
useful Subject: header. SCNR.
------------------------------
Date: Wed, 12 Feb 2003 22:20:55 GMT
From: "Jeremy Edgell" <jedgell@adelphia.net>
Subject: Re: Please explain this weird error message
Message-Id: <bNz2a.15496$0L3.4957641@news2.news.adelphia.net>
"Alan J. Flavell" <flavell@mail.cern.ch> wrote in message
news:Pine.LNX.4.53.0302122310430.20639@lxplus090.cern.ch...
> On Feb 12, Tad McClellan inscribed on the eternal scroll:
>
> > Look it up in the manual please.
>
> Quite.
>
> Perhaps the group could also hold a sweepstake on the least
> useful Subject: header. SCNR..
I agree with everyone that the manual is extremely useful; but give those
of us with modest knowledge of the language and even worse knowledge of the
manual a little break. Don't mean to be mean, but ...
------------------------------
Date: Wed, 12 Feb 2003 15:07:37 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: problem with "piping" data from STDOUT into the PerlTK's Text widget - blocking pipe
Message-Id: <3E4AA989.E88CFB80@earthlink.net>
Vitali wrote:
>
> I've writen an application with GUI written in PerlTk. I have lots of
> "print" statements throughout the program and I would like to collect
> whatever they print into STDOUT and display it in the Text area of a
> dedicated window of MonitorW.pm widget I have also written:
[snip]
A more practical way of doing this is to tie the *STDOUT filehandle,
rather than fiddling with pipes.
PS: The reason for the blocking is due to a limitation on how pipes
work, and is not caused by anything with Tk. There is a finite amount
of data that you can push into a pipe, and if you try to write more, the
writing process will go to sleep until data is pulled out of the other
end of the pipe. Since your process is the only one reading from the
pipe, once it goes to sleep due to writing too much, it won't be able to
read from the other end of the pipe ... thus, it goes to sleep forever.
--
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"
------------------------------
Date: Wed, 12 Feb 2003 14:02:44 -0500
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: puzzling operator priorities
Message-Id: <9pucnXqQU4N0B9ejXTWcpQ@giganews.com>
"Ben Kennedy" <bkennedy@hmsonline.com> wrote in message
news:AQGdnUMJ5JX5GtejXTWcqw@giganews.com...
>
> "ebchang" <chang0@adelphia.net> wrote in message
> news:Xns9320694C7EFF9chang0adelphia.net@24.48.107.53...
> > Looking at the expression $x = 5 && $y = 7, I thought it would be
> > parenthesized as either ($x = (5 && $y)) = 7 or as $x = (5 && $y)) = 7)
> > since && has higher priority than assignment.
>
> If I had to guess, perhaps the interpreter doing some optimization:
>
> $x = 5 && $y = 7
>
Just to follow up, I was told by someone that knows much more about Perl
than I do, that this optimization (constant folding) is what is going on and
should probably be considered a bug because it is not allowed by the
constraints of the language.
perl -MO=Deparse -e '$x = 5 && $y = 7'
--Ben Kennedy
------------------------------
Date: Wed, 12 Feb 2003 19:15:04 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: puzzling operator priorities
Message-Id: <3E4A9D05.7A8088BF@acm.org>
Ben Kennedy wrote:
>
> "ebchang" <chang0@adelphia.net> wrote in message
> news:Xns9320694C7EFF9chang0adelphia.net@24.48.107.53...
> > Looking at the expression $x = 5 && $y = 7, I thought it would be
> > parenthesized as either ($x = (5 && $y)) = 7 or as $x = (5 && $y)) = 7)
> > since && has higher priority than assignment.
>
> If I had to guess, perhaps the interpreter doing some optimization:
>
> $x = 5 && $y = 7
>
> Becomes via the precedence rules:
>
> $x = (5 && $y) = 7
>
> perl sees (5 && $y), realizes this will *always* return simply $y, and
> substitutes $y instead:
>
> $x = $y = 7
>
> which produces the behavior your are seeing. In experimenting, I noticed
> that:
>
> $x = rand() && $y = 7
>
> produces a compile time error, saying "Can't modify logical and (&&) in
> scalar assignment". Without the value '5' which is known at compile time,
> perl cannot optimize the && out of the picture, and thus producess the error
> related to the assignment operator. This is just a guess, perhaps someone
> with more internals experience can comment.
Easy enough to check:
$ perl -MO=Deparse -le'$x = 5 && $y = 7; print $x; print $y'
$x = $y = 7;
print $x;
print $y;
-e syntax OK
John
--
use Perl;
program
fulfillment
------------------------------
Date: Wed, 12 Feb 2003 22:35:57 GMT
From: ebchang <chang0@adelphia.net>
Subject: Re: puzzling operator priorities
Message-Id: <Xns9320B306DC2DDchang0adelphia.net@24.48.107.53>
"Ben Kennedy" <bkennedy@hmsonline.com> wrote in
news:9pucnXqQU4N0B9ejXTWcpQ@giganews.com:
>
> "Ben Kennedy" <bkennedy@hmsonline.com> wrote in message
> news:AQGdnUMJ5JX5GtejXTWcqw@giganews.com...
>>
>> "ebchang" <chang0@adelphia.net> wrote in message
>> news:Xns9320694C7EFF9chang0adelphia.net@24.48.107.53...
>> > Looking at the expression $x = 5 && $y = 7, I thought it would be
>> > parenthesized as either ($x = (5 && $y)) = 7 or as $x = (5 && $y))
>> > = 7) since && has higher priority than assignment.
>>
>> If I had to guess, perhaps the interpreter doing some optimization:
>>
>> $x = 5 && $y = 7
>>
>
> Just to follow up, I was told by someone that knows much more about
> Perl than I do, that this optimization (constant folding) is what is
> going on and should probably be considered a bug because it is not
> allowed by the constraints of the language.
>
> perl -MO=Deparse -e '$x = 5 && $y = 7'
Thanks, that certainly explains it. But further fiddling with Deparse
leads to another question. Using Deparse shows that both '$x = 5 && $y =
7' and '$x = (5 && ($y = 7))' are parsed as $x = $y = 7. However it says
that $x = ((5 && $y) = 7) is also parsed as $x = $y = 7, which seems
reasonable. But the value actually assigned to $x is 1 for that last
expression, not 7, suggesting that it is really parsed differently. I'm
puzzled afresh.
--
EBC
------------------------------
Date: 12 Feb 2003 19:13:26 GMT
From: randy@theoryx5.uwinnipeg.ca (Randy Kobes)
Subject: Re: Re Installing modules from CPAN
Message-Id: <slrnb4l6pr.a4k.randy@theoryx5.uwinnipeg.ca>
On Wed, 12 Feb 2003 16:58:09 -0000,
Brian Smart <brian.smart@blueyonder.co.uk> wrote:
>Hello Randy,
>I followed your advice to reconfigure using
>cpan> o config init
>and tried again.
>Unfortunately I still seem to have the same problem. The text I
>got was as follows:
[ .. ]
>Could not gzopen
>n/sources/authors/id/I/IL/ILYAZ/modules/Math-Pari-2.010305.tar.gz at
>/usr/lib/perl5/5.00503/CPAN.pm line 4159.
It's progress - this time there's a stray 'n' present in
CPAN.pm's configuration file, as you most likely don't have
a directory "n/sources/authors/id/" on your system.
This may be in the value of 'build_dir', or perhaps
'cpan_home', in CPAN/Config.pm - does your's start with
an 'n'? If so, change it so that it points to a directory,
like /path/to/your/home/directory/.cpan, that exists.
Alternatively, reconfigure CPAN.pm via 'o conf init'; it's
generally safe to accept the defaults (by just pressing
<ENTER> at the prompt, without typing anything), except
for the list of CPAN mirrors you want to use, and if you
have any special proxy settings.
--
best regards,
randy
------------------------------
Date: Wed, 12 Feb 2003 14:58:23 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Saving/Editing SQL queries
Message-Id: <3E4AA75F.545422F5@earthlink.net>
Guy wrote:
>
> Hi,
> I'm working on a web application (written in Perl, duh!) that allows
> users to execute SQL queries on a relational database (and save/edit
> these queries).
> Since the users have no knowledge of either the db scheme or SQL, my
> application lets them create queries using a web based GUI according
> to terms that the users know (an abstraction of the db scheme).
>
> I'm looking for a way to translate a given data structure (that
> represents what the user wants in their query) to actual SQL (so I can
> run it) and to save this query in order to edit it later.
What data structure do you have?
Show us, and we can help you translate it to an SQL query.
--
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"
------------------------------
Date: 12 Feb 2003 21:10:10 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: strict and warnings
Message-Id: <slrnb4le1i.n4t.abigail@alexandra.abigail.nl>
Tassilo v. Parseval (tassilo.parseval@post.rwth-aachen.de) wrote on
MMMCDLII September MCMXCIII in <URL:news:b2d0t2$gss$1@nets3.rz.RWTH-Aachen.DE>:
:}
:} What you say is that you prefer warning messages pop up all over the
:} place whenever something unexpected but harmless has happened on the
:} internals. Unlike a "General Protection Fault", a warning is not fatal
:} (it has fatal consequences only sometimes).
If a piece of code of mine produces a warning, than something I had
not anticipated happened. It might happen to be harmful, but that
would be sheer luck. I do consider that a bug. Had I antipated the
potential warning, and it deemed to be harmless, warnings would had
been turned off selectively for that section of the code.
:} > Even if I don't peek in the module, I rather send a bug report with
:} > a generated warning than a report "it doesn't work". I also rather
:} > get a report with a warning than without.
:}
:} Quite understandably. But that doesn't mean that you should annoy the
:} user with warnings. A user should send you a report whenever a bug shows
:} up. If you as a module maintainer feel that you have too few
:} information to fix the problem, you can still ask him to re-run the code
:} with -w or provide some other information needed for debugging. I do
:} that all the time, slightly succesfully I'd say.
:}
:} I know that bug-free code virtually doesn't exist. My implication is
:} that we should still assume that it works 99% of the time (this mileage
:} varies) and not vice versa.
:}
:} Hmmh, when you compile some piece of software, do you always compile it
:} with debugging flags? I guess you don't because you don't like the
:} performance hit and increeasd size of the object-code caused by it. I,
:} for one, want my stderr stream to be clean when using Perl modules.
You guessed wrong. I don't write C code very often, but from my latest
project (more than half a year ago), I had:
CFLAGS = -Wall -pedantic-errors -Wpointer-arith -Wstrict-prototypes \
-Wmissing-prototypes -Winline -Wshadow -Wcast-qual -Wcast-align \
-Wwrite-strings -Wconversion -Waggregate-return -Winline -W \
-Wno-unused -Wsign-compare -g
in my Makefile.
It's now happily running at a production cluster of a large bank,
sending payments to the payments router.
Abigail
--
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
------------------------------
Date: 12 Feb 2003 22:55:39 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: strict and warnings
Message-Id: <b2ejdb$ipr$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Abigail:
> Tassilo v. Parseval (tassilo.parseval@post.rwth-aachen.de) wrote on
> MMMCDLII September MCMXCIII in <URL:news:b2d0t2$gss$1@nets3.rz.RWTH-Aachen.DE>:
>:}
>:} What you say is that you prefer warning messages pop up all over the
>:} place whenever something unexpected but harmless has happened on the
>:} internals. Unlike a "General Protection Fault", a warning is not fatal
>:} (it has fatal consequences only sometimes).
>
> If a piece of code of mine produces a warning, than something I had
> not anticipated happened. It might happen to be harmful, but that
> would be sheer luck. I do consider that a bug. Had I antipated the
> potential warning, and it deemed to be harmless, warnings would had
> been turned off selectively for that section of the code.
I think we are gradually moving away from the original issue. There is
no need to argue that warnings are indispensable for the developer. What
you describe is common for the development stage but a different
approach might be needed when something is released. A new pragma is
needed, 'mod_warnings' perhaps, that is a replacement for warnings in
modules. It is the analogy of warn() <=> carp().
>:} Hmmh, when you compile some piece of software, do you always compile it
>:} with debugging flags? I guess you don't because you don't like the
>:} performance hit and increeasd size of the object-code caused by it. I,
>:} for one, want my stderr stream to be clean when using Perl modules.
>
> You guessed wrong. I don't write C code very often, but from my latest
> project (more than half a year ago), I had:
>
> CFLAGS = -Wall -pedantic-errors -Wpointer-arith -Wstrict-prototypes \
> -Wmissing-prototypes -Winline -Wshadow -Wcast-qual -Wcast-align \
> -Wwrite-strings -Wconversion -Waggregate-return -Winline -W \
> -Wno-unused -Wsign-compare -g
>
> in my Makefile.
I call that defensive programming. ;-)
It's not quite comparable since no matter how many -W flags you add, the
binary later will behave identically. These warnings show up only once
during compilation whereas Perl warnings affect runtime as well.
Admittedly, it is different with -g in that it will make your program
possibly a little slower. But again, it wont mess up stderr.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Wed, 12 Feb 2003 21:12:49 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Syntax error
Message-Id: <x7r8ad5hkf.fsf@mail.sysarch.com>
>>>>> "P" == Paanwa <paanwa@hotmail.com> writes:
P> Have you tried:
have you tried to not top post?
P> my @unverified_emails=("$form{'usermail'}", "$ID");
and why do you have the double quotes there? they aren't needed and are
a potential bug.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class
------------------------------
Date: Wed, 12 Feb 2003 21:21:12 GMT
From: Mike Hunter <mthunter@students.uiuc.edu>
Subject: use integer, strange negative results
Message-Id: <slrnb4les0.ja5.mthunter@ux12.cso.uiuc.edu>
I found this pretty odd:
#!/usr/bin/perl -w
use strict;
use integer;
print "".(2149594597/2)."\n";
-1072686349
It did that for me on two different perl5 systems:
perl -V
Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
Platform:
osname=freebsd, osvers=5.0-current, archname=i386-freebsd
...
perl -V
Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration:
Platform:
osname=solaris, osvers=2.7, archname=sun4-solaris
I'm using integer because I'm toying around with converting between hex
and dotted quad ip notation. I'm sure there are 100 perl modules I
should be using instead :) But can anybody explain this negative
result?
Thanks,
Mike
------------------------------
Date: Wed, 12 Feb 2003 22:45:46 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: use integer, strange negative results
Message-Id: <3e4acd61.285145508@news.erols.com>
Mike Hunter <mthunter@students.uiuc.edu> wrote:
: I found this pretty odd:
That's only half of the picture.
When something surprising happens, describe also what you expected to
happen and how it is different from reality.
: #!/usr/bin/perl -w
: use strict;
: use integer;
: print "".(2149594597/2)."\n";
:
: -1072686349
Look at what perl thinks of your integer even before the division.
H>perl -le "use integer; print 2149594597 + 0"
-2145372699
Is your original result less surprising now, or more so?
Read the documentation for the integer pragma. Use Math::BigInt for
math operations on integers that can't be represented by a mere 32
bits.
------------------------------
Date: 12 Feb 2003 14:12:28 -0800
From: tbolands@yahoo.com (Terry Bolands)
Subject: Using a variable to create a slice
Message-Id: <6393ea9a.0302121412.11235c6c@posting.google.com>
Hi,
I want to do something like this:
@array[1,2,3] = (stuff);
with a variable like this:
$v = "1,2,3";
@array[$v] = (stuff);
but it doesn't work. Can anyone give me a hint?
Thanks very much!
TB
------------------------------
Date: Wed, 12 Feb 2003 22:45:09 GMT
From: Kjetil Skotheim <kjetilsk.skotheim@usit.uio.no>
Subject: Re: Using a variable to create a slice
Message-Id: <1103_1045089909@nntp.uio.no>
12 Feb 2003 14:12:28 -0800, skrev tbolands@yahoo.com (Terry Bolands):
> Hi,
>
> I want to do something like this:
>
> @array[1,2,3] = (stuff);
>
> with a variable like this:
>
> $v = "1,2,3";
> @array[$v] = (stuff);
>
> but it doesn't work. Can anyone give me a hint?
$v = "1,2,3";
@v = split ",",$v;
@array[@v] = (stuff);
------------------------------
Date: Wed, 12 Feb 2003 22:47:14 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Using a variable to create a slice
Message-Id: <3e4acec1.285498133@news.erols.com>
tbolands@yahoo.com (Terry Bolands) wrote:
: I want to do something like this:
:
: @array[1,2,3] = (stuff);
:
: with a variable like this:
:
: $v = "1,2,3";
: @array[$v] = (stuff);
:
: but it doesn't work. Can anyone give me a hint?
How about
@v = ( 1, 2, 3 );
@array[@v] = (stuff);
------------------------------
Date: 12 Feb 2003 22:48:08 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Using a variable to create a slice
Message-Id: <b2eiv8$17g@dispatch.concentric.net>
"Terry Bolands" <tbolands@yahoo.com> wrote in message
news:6393ea9a.0302121412.11235c6c@posting.google.com...
> Hi,
>
> I want to do something like this:
>
> @array[1,2,3] = (stuff);
>
> with a variable like this:
>
> $v = "1,2,3";
> @array[$v] = (stuff);
>
You can't do this. Inside the square brackets you can place either a single
integer (or an expression that evaluates to an integer) or a range of
integers indicated by the range operator. Your $v holds a string of
characters.
This is legit: @array[1..3] = qw(alpha beta gamma);
(but note that $array[0] is uninitialized).
------------------------------
Date: Wed, 12 Feb 2003 22:50:13 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: Using a variable to create a slice
Message-Id: <slrnb4ljt5.hok.dha@panix2.panix.com>
In article <6393ea9a.0302121412.11235c6c@posting.google.com>, Terry
Bolands wrote:
> Hi,
>
> I want to do something like this:
>
> @array[1,2,3] = (stuff);
>
> with a variable like this:
>
> $v = "1,2,3";
> @array[$v] = (stuff);
>
> but it doesn't work. Can anyone give me a hint?
yep. the first example uses a 3 element list to slice, the second a
single scalar.
Effectively, you're asking for a one-element array slice, with the
element being at index "1,2,3" - which, of course, doesn't exist.
What you'd want for that same slice is @v = (1,2,3);
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"I think I'd better sit down."
"You are sitting down."
"Oh. Good for me." - BtVS, "Welcome to the Hellmouth"
------------------------------
Date: 12 Feb 2003 13:20:00 -0800
From: mnemotronic@yahoo.com (pt)
Subject: Weirdness with 'use constant X' and open(X ... )
Message-Id: <da662010.0302121319.3474caf9@posting.google.com>
Until I saw that I was using the same name for the constant and the
filehandle this was weirding me out. The compiler gave absolutely no
clue about the real problem:
--- cut here ---
use constant X => 'some text';
open(X,"some/file.txt");
my @a=<X>;
--- cut here ---
When run this would give "readline() on unopened filehandle X ...".
When run with the debugger ("-d") option, it gives "Can't use
string ("some/file.txt") as a symbol ref while "strict refs" in use
..."
I'm not sure what the proper behavior should be .... I would
certainly have appreciated better warning or error diagnostics. As it
is, I had to actually *think*, and I haven't had my afternoon espresso
yet ;-) BTW, this is under ActiveState 5.6.1-633.
------------------------------
Date: 12 Feb 2003 22:46:02 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Weirdness with 'use constant X' and open(X ... )
Message-Id: <b2eira$i8g$1@nets3.rz.RWTH-Aachen.DE>
Also sprach pt:
> Until I saw that I was using the same name for the constant and the
> filehandle this was weirding me out. The compiler gave absolutely no
> clue about the real problem:
>
> --- cut here ---
> use constant X => 'some text';
> open(X,"some/file.txt");
> my @a=<X>;
> --- cut here ---
>
> When run this would give "readline() on unopened filehandle X ...".
> When run with the debugger ("-d") option, it gives "Can't use
> string ("some/file.txt") as a symbol ref while "strict refs" in use
> ..."
This must be a bug. I now did the following:
ethan@ethan:~$ perl -wMstrict
use constant X => "string";
open X, ".bashrc";
my @f = <string>;
print $f[0];
__END__
export LS_OPTIONS=--color=auto
Doesn't the above open() statement qualify as some sort of symbolic
reference? I mean, it can't be more symbolic, can it? The following,
however, does not work with strictures (Can't use string ("ethan") as a
symbol ref while...):
open +(gethostbyname("localhost"))[0], ".bashrc";
my @file = <ethan>;
print $file[0];
This is hardly consistent.
> I'm not sure what the proper behavior should be .... I would
> certainly have appreciated better warning or error diagnostics. As it
> is, I had to actually *think*, and I haven't had my afternoon espresso
> yet ;-) BTW, this is under ActiveState 5.6.1-633.
Also under 5.005_03 and 5.8.0.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Wed, 12 Feb 2003 15:21:35 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Win32::OLE GroupItems PPT
Message-Id: <3E4AACCF.FB0EA229@earthlink.net>
Lance Hoffmeyer wrote:
>
> Help with syntax:
>
> $shape = $p2->Slides(1)->Shapes(6);
> my $text = $shape->ShapeRange->GroupItems(Index=>6)->
> TextFrame->TextRange->{Text};
>
> Win32::OLE(0.1502) error 0x80020003: "Member not found"
> in METHOD/PROPERTYGET "" at test.pl line 67
I have no idea what this line means, but...
> Can't call method "GroupItems" on an undefined value
> at test.pl line 67.
This clearly indicates that $shape->ShapeRange returned undef.
> I imagine it is my (Index=>6) but I have tried a number
> of different things and nothing seems to work. Any suggestions?
Nothing to do with the arguments you passed to ->GroupItems, the problem
has to do with the stuff to the left of that.
--
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"
------------------------------
Date: Wed, 12 Feb 2003 22:39:57 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Win32::OLE GroupItems PPT
Message-Id: <3e4acc2f.284840040@news.erols.com>
Benjamin Goldberg <goldbb2@earthlink.net> wrote:
: Lance Hoffmeyer wrote:
: >
: > Help with syntax:
: >
: > $shape = $p2->Slides(1)->Shapes(6);
: > my $text = $shape->ShapeRange->GroupItems(Index=>6)->
: > TextFrame->TextRange->{Text};
: >
: > Win32::OLE(0.1502) error 0x80020003: "Member not found"
: > in METHOD/PROPERTYGET "" at test.pl line 67
:
: I have no idea what this line means, but...
A method not available to the object was invoked, ShapeRange in this
case. Which explains the undef return.
But that message feels broken. Something belongs in those empty
quotes, like the name of the invalid method. I'd swear that's what
used to happen, before 5.8.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 4559
***************************************