Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: What is the best solution to swap input data?

by Anonymous Monk
on Nov 09, 2006 at 15:04 UTC ( [id://583116]=note: print w/replies, xml ) Need Help??


in reply to Re: What is the best solution to swap input data?
in thread What is the best solution to swap input data?

Here's a substr solution that works in situ:
my $data = '123456789'; foreach (my $i = 0; $i + 1 < length $data; $i += 2) { substr($data, $i, 2) = reverse substr($data, $i, 2); } print $data, "\n"; __END__ 214365879

Replies are listed 'Best First'.
Re^3: What is the best solution to swap input data?
by Hofmator (Curate) on Nov 09, 2006 at 15:20 UTC
    That's fenLisesi's solution here in this thread, only using an assignment instead of the 4-arg form of substr.

    -- Hofmator

    Code written by Hofmator and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://583116]
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-03-28 20:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found