Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

There's a new feature that appeared in "developer release 5.25.3". It's mentioned in "(5.25.3) perldelta: Declaring a reference to a variable". Details are in "(5.25.3) perlref: Declaring a Reference to a Variable". The text of that last link starts with "Beginning in v5.26.0, ...": so, if you don't want to install a developer version (the latest is 5.25.9), you probably won't have long to wait for a stable one.

I think this is the sort of thing you were after:

#!/usr/bin/env perl use 5.025003; use strict; use warnings; no warnings 'experimental::refaliasing'; use experimental qw{refaliasing declared_refs}; use feature 'declared_refs'; { my $str = \'string'; my $list = [qw{a b c}]; my $map = {x => 24, y => 25, z => 26}; func($str, $list, $map); } sub func { my (\$string, \@array, \%hash) = @_; say $string; say "@array"; say "$_ => $hash{$_}" for sort keys %hash; return; }

Sample run:

$ perl -v | head -2 | tail -1 This is perl 5, version 25, subversion 9 (v5.25.9) built for darwin-th +read-multi-2level $ pm_1179933_test_exp_declared_refs.pl string a b c x => 24 y => 25 z => 26

Important: Do note that this feature is experimental; subject to change; and, as such, not suitable for production code.

— Ken


In reply to Re: Improve readability of Perl code. Naming reference variables. [New Perl Feature] by kcott
in thread Improve readability of Perl code. Naming reference variables. by hakonhagland

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Domain Nodelet?
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others exploiting the Monastery: (3)
    As of 2024-09-11 19:32 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      The PerlMonks site front end has:





      Results (15 votes). Check out past polls.

      Notices?
      erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.