Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Missing Bracket

by mkirank (Chaplain)
on Nov 30, 2005 at 00:37 UTC ( #512802=perlquestion: print w/ replies, xml ) Need Help??
mkirank has asked for the wisdom of the Perl Monks concerning the following question:

I have missed the trailing ")" and even then I dont get syntax error. What am I missing here ?

#!perl use strict; use warnings; my $tmpstr = ''; $tmpstr = join ('|',@({0 .. 366} = '' x 366) ; print $tmpstr;

Comment on Missing Bracket
Download Code
Re: Missing Bracket
by sub_chick (Hermit) on Nov 30, 2005 at 00:45 UTC
    on line one try:
    #! /usr/bin/perl -w
    and see if that helps.
Re: Missing Bracket
by BrowserUk (Pope) 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.
      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?

      Cheers,
      PerlingTheUK

        It isn't anything. I suspect that graphic characters (non alphanumeric) get special treatment because of their use as special variables (like %! for example). Try running the code. :)


        DWIM is Perl's answer to Gödel

        (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.

        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.


        Dave

      $tmpstr = join( '|', @{0 .. 366} = '' x 366 );
      This gives an error ..

        I should have tested, but I wasn't really sure what you were trying to achieve? Anyway, this may be it.

        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.
Re: Missing Bracket
by GrandFather (Cardinal) 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
      You are right , It gives uninitialised warnings but prints the string , removing the "(" gives an error

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://512802]
Approved by PerlingTheUK
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (10)
As of 2014-08-30 13:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (293 votes), past polls