Re: [LIP] Perl pack() question

Rohan Almeida <[email protected]>
Newsgroups gmane.user-groups.linux.india.programmers
Organization Sify Ltd.
Message-ID <[email protected]>
Binand Sethumadhavan wrote:

> my @octets = split (/\./, $ip);
> foreach $o (@octets) {
>     printf "%02X", $o;
> }
> 
> Is there a way to rewrite the stuff in the foreach loop using pack()? I
> am sort of unfamiliar with the pack() :)

IMHO, you're better off using printf.
But you can eliminate the foreach using the map function

map { printf "%02X", $_ } split /\./, $ip;


--
Rohan



-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.