perl.beginners
[Top] [All Lists]

Re: splitting and replacing characters

Subject: Re: splitting and replacing characters
From: John W. Krahn
Date: Mon, 09 Nov 2009 10:28:15 -0800
Newsgroups: perl.beginners


rithu wrote:
Hi,

Hello,

Please help me to split a string as follows..

my $line = "abcdefghijkl"

the expected output should be like:

ab
ef
ij


The logic is like alternate 2 characters should be removed....

$ perl -le'
my $line = "abcdefghijkl";
my @data = unpack "(a2x2)*", $line;
print for @data;
'
ab
ef
ij




John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity.               -- Damian Conway

<Prev in Thread] Current Thread [Next in Thread>