Re: splitting and replacing characters

2009-11-09 Thread tom smith
On Mon, Nov 9, 2009 at 8:30 PM, tom smith wrote: > > On Mon, Nov 9, 2009 at 10:56 AM, Jim Gibson wrote: > >> However, here is a shortened form using regular expression: >> >> my @output = $line =~ m{ \G (..) .. }gx; >> >> Verify how either of these works when you do not have a multiple of 2 >> c

Re: splitting and replacing characters

2009-11-09 Thread tom smith
On Mon, Nov 9, 2009 at 10:56 AM, Jim Gibson wrote: > However, here is a shortened form using regular expression: > > my @output = $line =~ m{ \G (..) .. }gx; > > Verify how either of these works when you do not have a multiple of 2 > characters in your input. > > It has other problems too: use

Re: splitting and replacing characters

2009-11-09 Thread John W. Krahn
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 f

Re: splitting and replacing characters

2009-11-09 Thread Robert Wohlfarth
On Mon, Nov 9, 2009 at 7:03 AM, rithu 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 on

Re: splitting and replacing characters

2009-11-09 Thread Jim Gibson
On 11/9/09 Mon Nov 9, 2009 5:03 AM, "rithu" scribbled: > Hi, > > 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 split would not be th