Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

First char out of a string & surprises with errors on chop reverse $string (that doesn't work!)

by eduardo (Curate)
on Dec 26, 2001 at 21:41 UTC ( [id://134428]=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl -w
    
    use strict;
    ...
                   'Using Unpack'          => \&using_unpack,
                   'Using Reverse & Chop'  => \&using_reverse_chop,
                   });
    
  2. or download this
    [earino@localhost earino]$ ./first_char.pl
    Can't modify reverse in chop at ./first_char.pl line 27, near "$string
    +;"
    Execution of ./first_char.pl aborted due to compilation errors.
    [earino@localhost earino]$
    
  3. or download this
    return chop reverse scalar $str;
    
  4. or download this
    #!/usr/bin/perl -w
    
    use strict;
    ...
                   'Using Unpack'          => \&using_unpack,
                   'Using Reverse & Chop'  => \&using_reverse_chop,
                   });
    
  5. or download this
    Benchmark: running Using Regexp, Using Reverse & Chop, Using Split, Us
    +ing Substring, Using Unpack, each for at least 5 CPU seconds...
    Using Regexp:  5 wallclock secs ( 5.39 usr + -0.01 sys =  5.38 CPU) @ 
    +207251.30/s (n=1115012)
    Using Reverse & Chop:  4 wallclock secs ( 5.23 usr +  0.00 sys =  5.23
    + CPU) @ 255457.74/s (n=1336044)
    Using Split:  5 wallclock secs ( 5.25 usr +  0.01 sys =  5.26 CPU) @ 9
    +7116.92/s (n=510835)
    Using Substring:  5 wallclock secs ( 5.25 usr + -0.02 sys =  5.23 CPU)
    + @ 1009882.22/s (n=5281684)
    Using Unpack:  5 wallclock secs ( 5.27 usr +  0.01 sys =  5.28 CPU) @ 
    +260676.33/s (n=1376371)
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-20 03:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found