Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

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

Perhaps a wiser head or three can tell me if the next statement appears to be valid:

The answers in Q&A QandASection: references "How to force one variable to be an alias to another?" have some problems. Rather than post a reply to a single answer there (and to avoid polluting Q&A if I' ve missed something), here's what I observed:

Starting with my OS & perl:
Win7 Pro perl -v: This is perl 5, version 24, subversion 0 (v5.24.0) built for MSWin32- +x86-multi-thr (with 1 registered patch ....)<br> Binary build 2400 [300560] provided by ActiveState http://www.ActiveS +tate.com<br> Built Jul 13 2016 14:32:48
And, my test code:
use v5.22; use warnings; # cat answer to "How to force one variable to be an alias to another? +" # indented text led by #: errors prior to commenting out the bare blo +ck my $seg = 1; say "\$seg: $seg"; =head { use feature 'refalias'; # "C:\>D:\#1183761.pl # Feature "refalias" is not supported by Perl 5.24.0 at D:\_Perl_\p +l_test\#1183761.pl li +ne 3. # BEGIN failed--compilation aborted at D:\_Perl_\pl_test\#1183761.p +l line 3." # No mention of deprecation/elimination found in perldelta 5.24 +but error as above. # Silence warnings if desired: no warnings 'experimental::refaliasing'; my ($x, $y); \$x = \$y; # alias here $x = 5; say $y; # prints nothing -- see msg above }; =cut $seg++; say "\$seg = $seg"; #2 =head { my $x = 5; my $y = 273; make_alias( $x, $y ); # $seg = 2 # Undefined subroutine &main::make_alias called at D:\_Perl_\pl_te +st\#1183761.pl line 3 +6. print $y; # prints nothing -- see msg above }; =cut $seg++; say "\$seg = $seg"; #3 { use Lexical::Alias; my $that = "not_that"; my $this = "another seg"; alias $that, $this; # $this is now an alias for $that. say $this; # prints "not_that" }; $seg++; say "\$seg = $seg"; #4 { my @x = qw(foo bar baz); my @y = qw(bat bif bim); alias @x, @y; for (@x) { say "element of \@x: " . $_; } for (@y) { say "\t element of \@y: " . $_; } }; $seg++; say "\$seg = $seg"; #5 =head { use Data::Alias; # from perldelta for 5.24: # Known Problems # Some modules have been broken by the context s +tack rework. # These modules were relying on non-guaranteed i +mplementation # details in perl. <i> (did I miss something?)< +/i> my( $this, $that ); alias $that, $this; # $this is now an alias for $that. }; =cut =head FINAL OUTPUT AFTER commenting failed bareblocks: $seg: 1 $seg = 2 $seg = 3 not_that $seg = 4 element of @x: foo element of @x: bar element of @x: baz element of @y: foo element of @y: bar element of @y: baz $seg = 5 =cut

Spirit of the Monastery

Come, let us reason together: Spirit of the Monastery

check Ln42!


In reply to Possible Problems in [id://586121] by ww

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
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 avoiding work at the Monastery: (2)
As of 2024-04-20 03:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found