develooper Front page | perl.beginners | Postings from March 2011

Re: transposing %d values to %x output

Thread Previous | Thread Next
From:
Shawn H Corey
Date:
March 29, 2011 16:57
Subject:
Re: transposing %d values to %x output
Message ID:
4D9271C7.1030207@gmail.com
On 11-03-29 07:50 PM, Noah Garrett Wallach wrote:
> Hi there,
>
> s/(\d+)\.(\d+)\.(\d+)\.(\d+)/$1:$2:$3:$4::0/
>
> so is there a slick, easily readable way to get the value $1, $2, $3, $4
> to be rewriten as %x instead of a %d?

s/(\d+)\.(\d+)\.(\d+)\.(\d+)/sprintf('%x:%x:%x:%x::0',$1,$2,$3,$4)/e;

See:
`perldoc -f sprintf`
`perldoc perlre` and search for /\/e/


-- 
Just my 0.00000002 million dollars worth,
   Shawn

Confusion is the first step of understanding.

Programming is as much about organization and communication
as it is about coding.

The secret to great software:  Fail early & often.

Eliminate software piracy:  use only FLOSS.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About