Re: Missing Bracket
by BrowserUk (Patriarch) on Nov 30, 2005 at 00:50 UTC
|
@({...} is a hash slice on the hash %(. Tricky.
What I think you are trying for is
$tmpstr = join( '|', @{0 .. 366} = '' x 366 );
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] [select] |
|
Excuse me for being curious but what is %(? I cannot find that documented anywhere. Why does use strict; not require a declaration for this hash?
| [reply] [d/l] [select] |
|
(Almost?) every non-alpha printable character is used as a global variable for something. In this case, $( is defined in perlvar as $REAL_GROUP_ID (Whatever that is:).
But every global scalar, is just one part of a 'glob', which also has 6 (or 7?) 'slots' (*).
You are familiar with $_ and @_, well there is also a %_ which doesn't see much use outside golf. So it is with all other globals, the are $|, @| & %|, only the first of which has a predefined use, but the others exist and are usable as with any other general purpose global.
(*). I forget exactly what they all are, but broquaint did a very good tutorial on them somewhere. See that for the full SP. Try supersearch for tutorial glob and author broquaint.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] [select] |
|
| [reply] |
|
It isn't actually anything, ie it's not used as a Perl special variable. However, all punctuation variables are essentially considered special whether they have meaning or not. This is documented in perlvar where it says...
Perl identifiers that begin with digits, control characters, or punctuation characters are exempt from the effects of the package declaration and are always forced to be in package main ; they are also exempt from strict 'vars' errors.
| [reply] |
|
|
$tmpstr = join( '|', @{0 .. 366} = '' x 366 );
This gives an error ..
| [reply] [d/l] |
|
P:\test>perl -Mstrict -wle"print join( '|', @{+{}}{1 .. 366} = ('') x
+366)"
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+||||||
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] |
Re: Missing Bracket
by GrandFather (Saint) on Nov 30, 2005 at 00:58 UTC
|
( is being treated as a special variable in @({...}. I presume that pretty much any "special" character will be treated in the same fashion. I suspect you will get uninitialised warnings when you run it.
DWIM is Perl's answer to Gödel
| [reply] [d/l] [select] |
|
You are right , It gives uninitialised warnings but prints the string , removing the "(" gives an error
| [reply] |
Re: Missing Bracket
by sub_chick (Hermit) on Nov 30, 2005 at 00:45 UTC
|
#! /usr/bin/perl -w
and see if that helps.
| [reply] [d/l] |