Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: scalar reference and length

by rjt (Curate)
on Oct 29, 2019 at 22:53 UTC ( [id://11108098]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
      my $x = \" VERY VERY BIG STRING .....";
      my $len = length( $$x );
    
  2. or download this
    my $string = 'Long string' x 100000;
    sub psau() { print grep { /\b$$\b/ } `ps au` } # POSIX platforms
    sub bar    { psau }
    ...
    foo($string);
    mod($string);
    psau;
    
  3. or download this
    use Devel::Size qw< size total_size >;
    
    sub size_print($\$) {
    ...
     $collection (empty)    24    88
     $collection ( one )    24  1278
     $collection ( two )    24  1302
    
  4. or download this
    use Benchmark qw<cmpthese>;
    
    my $string      = 'Long string' x 1000;
    ...
    $$ref        18937129/s           9%           --         -30%        
    + -32%
    $really_long 27185304/s          57%          44%           --        
    +  -2%
    $string      27870647/s          61%          47%           3%        
    +   --
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11108098]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-20 02:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found