Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: rotate a vector with a regex?

by frozenwithjoy (Curate)
on Nov 20, 2012 at 22:00 UTC ( #1004807=note: print w/ replies, xml ) Need Help??

in reply to rotate a vector with a regex?

Are you interested in the end product or do you want all intermediates?

This will give you the end product:

#!/usr/bin/env perl use strict; use warnings; use feature 'say'; my $string = "12345"; $string = substr( $string, 1 ) . substr( $string, 0, 1 ); say $string; __END__ 23451

EDIT: Just realized you were asking for something else. Oops. I think AnomalousMonk is correct about it not being possible this way. Regarding the errors, you need to specify the second capture group since the second set of parentheses you have are part of the lookahead. This gets rid of the warnings:

$ perl -WE '$string = "12345"; $string =~ s/(.)(?=(.))/$2$1/g; say $st +ring' 213243545

Comment on Re: rotate a vector with a regex?
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2015-11-27 09:20 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (722 votes), past polls