Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Regarding $# usage

Expand Messages
  • Jenda Krynicky
    From: Jins Thomas ... This seems to use the %# hash, not the $# scalar. But there is way too many *s. Send us the exact code and
    Message 1 of 6 , Sep 10, 2008
    • 0 Attachment
      From: "Jins Thomas" <hellojins@...>
      > Hi all,
      >
      > I would like to ask one doubt regarding usage of $# in perl 5.8 and perl
      > 5.10
      >
      >
      > Actually i was running one old perl code which contained
      >
      > $lnumParamNames = *$#{*@$lparamNames*} *+ 1;
      >
      >
      > This was working fine with perl 5.8. But not working fine with 5.10.
      >
      > I saw the change log which says $# is no longer used in 5.10. But i assume
      > this has something to do with output format of numbers and not to do with
      > any List Context.

      This seems to use the %# hash, not the $# scalar. But there is way
      too many *s. Send us the exact code and include a few lines above and
      below.

      Jenda
      ===== Jenda@... === http://Jenda.Krynicky.cz =====
      When it comes to wine, women and song, wizards are allowed
      to get drunk and croon as much as they like.
      -- Terry Pratchett in Sourcery
    • Amit Saxena
      ... %# hash ? What s that, I am not aware of this. Is this something like dereferencing etc ? Regards, Amit Saxena [Non-text portions of this message have been
      Message 2 of 6 , Sep 10, 2008
      • 0 Attachment
        On Wed, Sep 10, 2008 at 5:09 PM, Jenda Krynicky <Jenda@...> wrote:

        > From: "Jins Thomas" <hellojins@... <hellojins%40gmail.com>>
        >
        > > Hi all,
        > >
        > > I would like to ask one doubt regarding usage of $# in perl 5.8 and perl
        > > 5.10
        > >
        > >
        > > Actually i was running one old perl code which contained
        > >
        > > $lnumParamNames = *$#{*@$lparamNames*} *+ 1;
        > >
        > >
        > > This was working fine with perl 5.8. But not working fine with 5.10.
        > >
        > > I saw the change log which says $# is no longer used in 5.10. But i
        > assume
        > > this has something to do with output format of numbers and not to do with
        > > any List Context.
        >
        > This seems to use the %# hash, not the $# scalar. But there is way
        > too many *s. Send us the exact code and include a few lines above and
        > below.
        >
        > Jenda
        > ===== Jenda@... <Jenda%40Krynicky.cz> === http://Jenda.Krynicky.cz=====
        > When it comes to wine, women and song, wizards are allowed
        > to get drunk and croon as much as they like.
        > -- Terry Pratchett in Sourcery
        >
        >
        >


        %# hash ? What's that, I am not aware of this. Is this something like
        dereferencing etc ?

        Regards,
        Amit Saxena


        [Non-text portions of this message have been removed]
      • Jenda Krynicky
        From: Amit Saxena ... God knows (well, perl porters probably do as well) I though it s nothing special, just an ordinary hash ...
        Message 3 of 6 , Sep 10, 2008
        • 0 Attachment
          From: "Amit Saxena" <learn.tech123@...>
          > On Wed, Sep 10, 2008 at 5:09 PM, Jenda Krynicky <Jenda@...> wrote:
          > > From: "Jins Thomas" <hellojins@... <hellojins%40gmail.com>>
          > >
          > > > Hi all,
          > > >
          > > > I would like to ask one doubt regarding usage of $# in perl 5.8 and perl
          > > > 5.10
          > > >
          > > >
          > > > Actually i was running one old perl code which contained
          > > >
          > > > $lnumParamNames = *$#{*@$lparamNames*} *+ 1;
          > > >
          > > >
          > > > This was working fine with perl 5.8. But not working fine with 5.10.
          > > >
          > > > I saw the change log which says $# is no longer used in 5.10. But i
          > > assume
          > > > this has something to do with output format of numbers and not to do with
          > > > any List Context.
          > >
          > > This seems to use the %# hash, not the $# scalar. But there is way
          > > too many *s. Send us the exact code and include a few lines above and
          > > below.
          >
          > %# hash ? What's that, I am not aware of this. Is this something like
          > dereferencing etc ?

          God knows (well, perl porters probably do as well) I though it's
          nothing special, just an ordinary hash ... except that it's truly
          global. Like for example %':

          #!/usr/bin/perl
          $'{hello} = 'world';
          print "\$'{hello}=$'{hello}\n";

          package Other;
          print "\$'{hello}=$'{hello}\n";
          __END__


          But it seems it is indeed somehow special:

          #!/usr/bin/perl
          $#{hello} = 'world';
          print "\$#{hello}=$#{hello}\n";

          package Other;
          print "\$#{hello}=$#{hello}\n";
          __END__

          I get:

          $#{hello}=0
          $#{hello}=-1

          But it seems to be undocumented.

          You should not use variables named by a single special character
          though as they are often quite ... special. You get to see those in
          golf and obfu, but in normal everyday programming it's better to keep
          away from them. Unless of course you do want that special behaviour.

          Jenda
          ===== Jenda@... === http://Jenda.Krynicky.cz =====
          When it comes to wine, women and song, wizards are allowed
          to get drunk and croon as much as they like.
          -- Terry Pratchett in Sourcery
        • Jins Thomas
          ... Hello Jenda, I think i tried to use bold higlighting and hence the problem of too many * s in between Actual code is my @lparams= qw/hello how are you/; my
          Message 4 of 6 , Sep 11, 2008
          • 0 Attachment
            On Thu, Sep 11, 2008 at 5:22 AM, Jenda Krynicky <Jenda@...> wrote:

            > From: "Amit Saxena" <learn.tech123@... <learn.tech123%40gmail.com>
            > >
            >
            > > On Wed, Sep 10, 2008 at 5:09 PM, Jenda Krynicky <Jenda@...<Jenda%40krynicky.cz>>
            > wrote:
            > > > From: "Jins Thomas" <hellojins@... <hellojins%40gmail.com><hellojins%
            > 40gmail.com>>
            > > >
            > > > > Hi all,
            > > > >
            > > > > I would like to ask one doubt regarding usage of $# in perl 5.8 and
            > perl
            > > > > 5.10
            > > > >
            > > > >
            > > > > Actually i was running one old perl code which contained
            > > > >
            > > > > $lnumParamNames = *$#{*@$lparamNames*} *+ 1;
            > > > >
            > > > >
            > > > > This was working fine with perl 5.8. But not working fine with 5.10.
            > > > >
            > > > > I saw the change log which says $# is no longer used in 5.10. But i
            > > > assume
            > > > > this has something to do with output format of numbers and not to do
            > with
            > > > > any List Context.
            > > >
            > > > This seems to use the %# hash, not the $# scalar. But there is way
            > > > too many *s. Send us the exact code and include a few lines above and
            > > > below.
            > >
            > > %# hash ? What's that, I am not aware of this. Is this something like
            > > dereferencing etc ?
            >
            > God knows (well, perl porters probably do as well) I though it's
            > nothing special, just an ordinary hash ... except that it's truly
            > global. Like for example %':
            >
            > #!/usr/bin/perl
            > $'{hello} = 'world';
            > print "\$'{hello}=$'{hello}\n";
            >
            > package Other;
            > print "\$'{hello}=$'{hello}\n";
            > __END__
            >
            > But it seems it is indeed somehow special:
            >
            > #!/usr/bin/perl
            > $#{hello} = 'world';
            > print "\$#{hello}=$#{hello}\n";
            >
            > package Other;
            > print "\$#{hello}=$#{hello}\n";
            > __END__
            >
            > I get:
            >
            > $#{hello}=0
            > $#{hello}=-1
            >
            > But it seems to be undocumented.
            >
            > You should not use variables named by a single special character
            > though as they are often quite ... special. You get to see those in
            > golf and obfu, but in normal everyday programming it's better to keep
            > away from them. Unless of course you do want that special behaviour.
            >
            > Jenda
            > ===== Jenda@... <Jenda%40Krynicky.cz> === http://Jenda.Krynicky.cz=====
            >





































































            Hello Jenda,

            I think i tried to use bold higlighting and hence the problem of too many *
            s in between

            Actual code is

            my @lparams= qw/hello how are you/;
            my $lparamNames=\@lparams;
            print $#{@$lparamNames}, "\n";

            This outputs -1 in perl 5.10 and 3 in perl 5.8.

            This was the question i asked.

            Any help would be highly appreciated.

            Jins Thomas


            >
            > When it comes to wine, women and song, wizards are allowed
            > to get drunk and croon as much as they like.
            > -- Terry Pratchett in Sourcery
            >
            >
            >


            [Non-text portions of this message have been removed]
          • Charles K. Clarkson
            Jins Thomas wrote: [snip] ... my @lparams = qw/hello how are you/; my $lparamNames = @lparams; print $#lparams, is the last index of the @lparams
            Message 5 of 6 , Sep 11, 2008
            • 0 Attachment
              Jins Thomas wrote:
              [snip]

              : Actual code is
              :
              : my @lparams= qw/hello how are you/;
              : my $lparamNames=\@lparams;
              : print $#{@$lparamNames}, "\n";
              :
              : This outputs -1 in perl 5.10 and 3 in perl 5.8.


              my @lparams = qw/hello how are you/;
              my $lparamNames = \@lparams;

              print $#lparams, " is the last index of the \@lparams array.\n";
              print $#{ $lparamNames }, " is the last index of the array referenced by
              \$lparamNames.\n";
              print $#$lparamNames, " is the last index of the array referenced by
              \$lparamNames.\n";

              __END__

              Charles K. Clarkson
              --
              Mobile Homes Specialist
              Free Market Advocate
              Web Programmer

              254 968-8328

              http://www.clarksonenergyhomes.com/wordpress/about/

              Don't tread on my bandwidth. Trim your posts.
            Your message has been successfully submitted and would be delivered to recipients shortly.