hex represenation from string in perl



Hi,

I have a file with the following contents

1111
1100
1001
..
..
..

I read it into an array and want to represent it as hex.

so I want the output to read

f
c
9
..
..
..

Any suggestions ?

thanks,
Newbie

-------------------------
#!usr/bin/perl

$file_name= <~/values>;
open(file_handler,$file_name);
@arr_file_content= <file_handler>;
close (file_handler);

print ("@arr_file_content");

foreach $v (@arr_file_content){
chomp;
printf("%0x\n",int($v));
}

this doesn't work,

-----------------

.



Relevant Pages

  • RE: looking for duplicate array values
    ... : On Oct 5, Charles Farinella said: ... And then you should chomp $_ before going further; ... I would eliminate @array and keep $sku. ... Prev by Date: ...
    (perl.beginners)
  • Re: Regular Expressions with arrays
    ... I am trying to read a file and compare each line in the file. ... push (@array, $_); ... chomp; ... next if $prev; ...
    (perl.beginners)
  • Conversion of hexadecimal value to valid text
    ... I have a Byte array that holds hexadecimal values (ASCII e.g. byte value is ... hex 54 for the letter T). ... Prev by Date: ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Big endian convention in Ruby
    ... if the array holding this is ... messageHex[0].hex.to_i this will ensure that it is a integer in hex. ... Unpack directly to Integers, as shown above. ... It works perfectly fine with in give the loop 64 times.. ...
    (comp.lang.ruby)
  • Re: byte data manipulation
    ... Read in the input hex file, stripping of the preamble and checksum ... and putting the bytes (2 chars) into array_1. ... explains why you need the array. ...
    (comp.lang.c)