On Mon, Nov 9, 2009 at 7:03 AM, rithu <sundh...@gmail.com> wrote: > 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.... >
Will a "for" loop work for your needs? The one below uses "substr" to extract every two characters. my $line="abcdefghijkl"; for (my $i = 0; $i < length( $line ); $i += 4) { print substr( $line, $i, 2 ), "\n"; } -- Robert Wohlfarth