Hi Sj,

On Tue, 14 Aug 2012 10:55:13 +0100
jet speed <speedj...@googlemail.com> wrote:

> Hi All,
> 
> I have a file as below
> 
> file.txt
> 50000008449AFB7494
> 50000008449AFB749C
> 50000008449AFB779D
> 
> now i want to introduce : inbetween  as below for each of these
> entries in the file
> 
> 50:00:00:08:44:9A:FB:74:90
> 
> i did come across join function in perl, not sure how to apply
> inbetween each entries as above.
> 
> any help would be much appreciated.
> 

You can do something like this:

[CODE]
#!/usr/bin/perl

use strict;
use warnings;

my $s = '50000008449AFB749C';

my @parts = $s =~ m/(..)/g;

my $with_colons = join(':', @parts);

print "With colons = <<$with_colons>>\n";

[/CODE]

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Freecell Solver - http://fc-solve.shlomifish.org/

How many “one-liners” do I actually write? I don’t know; maybe a couple dozen
a day. But I guess I must be unusual, because as we all know, AWK was a
complete failure and vanished into obscurity since it didn’t address anyone’s
real needs. (That was sarcasm.) — “Twelve Views of Mark Jason Dominus”

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to