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

Grabbing Adjacent Chars In A String - Re: Capturing with look-ahead

by metadoktor (Hermit)
on Mar 04, 2002 at 15:57 UTC ( [id://149146]=note: print w/replies, xml ) Need Help??


in reply to Capturing with look-ahead

I suspect that this question is related to the current Perl Review golfing challenge, but here is a solution to your problem. I could give you a regex-based solution but it would be more complicated and probably less efficient.

#!/usr/local/bin/perl -w use strict; my @x; $_="blah"; for my $i (0..length($_)-2) { $x[$i]=substr($_,$i,1).substr($_,$i+1,1); } print "@x\n";
produces...
bl la ah

metadoktor

"The doktor is in."

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (7)
As of 2024-03-19 03:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found