Re: Interpolating hash

Discussion in 'Perl Misc' started by Bjoern Hoehrmann, Jan 17, 2013.

  1. * Shmuel wrote in comp.lang.perl.misc:
    >I would like to produce a message that includes the value of a hash.
    >Perl does not recognize a % sigil inside of quoted strings. I recall
    >that there is syntax that causes interpolation of an expression, but
    >haven't been able to find it in the documentation. Is there a clean
    >way to do this, or should I just piece the text together with the
    >concatenation operator, or interpolate an intermediate variable? Of
    >the available techniques, which is considered to be the best style?


    You do not need `%` to refer to a value in a hash in Perl5,

    my %hash = ('key' => 'value');
    print "$hash{key}";

    would print `value`.
    --
    Björn Höhrmann · mailto: · http://bjoern.hoehrmann.de
    Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
    25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
    Bjoern Hoehrmann, Jan 17, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jitasi
    Replies:
    1
    Views:
    730
    Terry Reedy
    Mar 4, 2007
  2. rp
    Replies:
    1
    Views:
    478
    red floyd
    Nov 10, 2011
  3. John Elrick
    Replies:
    9
    Views:
    100
    John Carter
    Apr 7, 2005
  4. Lloyd Zusman
    Replies:
    4
    Views:
    198
    Ken Bloom
    Mar 18, 2009
  5. C.DeRykus

    Re: Interpolating hash

    C.DeRykus, Jan 17, 2013, in forum: Perl Misc
    Replies:
    1
    Views:
    153
    C.DeRykus
    Jan 17, 2013
Loading...

Share This Page