Re: Adding a delimiter inbetween number characters and letter characters

From: Michele Dondi (bik.mido_at_tiscalinet.it)
Date: 01/14/05


Date: Fri, 14 Jan 2005 12:21:08 +0100

On 14 Jan 2005 00:24:40 GMT, Martin Kissner <news@chaos-net.de> wrote:

>>> 5 my $lastline="";
>>> 6 my @lastline;
[snip code]
>> Do you _really_ need this $lastline algorithmic madness?
>
>Good question. What do you think of that solution?
                                     ^^^^
                                     ^^^^

Of _that_ solution or...

>#!/usr/bin/perl
>
>use warnings;
>use strict;
>
> local $/;
> my $content = <DATA>;
> $content =~ s/\n\D//g;
> $content =~ s/(^\d+|\n\d)/$1-/g;
> print $content;
>
>__DATA__

...of _this_ solution?

Whatever, IIRC the OP just wanted to put in a delimiter between a
number of an arbitrary length at the beginning of each line and
whatever follows. Then I'd just do:

  perl -pi -e 's/^(\d+)/$1-/' file1 file2...

Michele

-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


Relevant Pages