in reply to Converting ASCII to Hex

There is one slight disadvantage to merlyn's solution in the initial reply: the strings you are converting into hex numerics will probably include "\n" characters, which of course are "\x0a" -- but  unpack "H*", "\n" will produce just "a" (no leading zero), and based on your reply to merlyn, this is not what you want.

You seem to want output that consistently shows two hex digits per ASCII character, with leading zero where needed.

So use sprintf (and use ALL_CAPS for a file handle name, or else use a lexically scoped scalar variable, instead of a lower-case bare word; and don't bother holding the whole file content in an array):

use strict; open( IN, "file.txt" ) or die "file.txt: $!"; open( OUT, "out.txt" ) or die "out.txt: $!"; # or: open( my $in, "file.txt") ... while (<IN>) { # or: while (<$in> ...) $_ = join "", map { sprintf("%2.2x",ord($_)) } split //; print OUT $_, $/; }
If "map" is foreign to you, you can use a loop like the following, but you should learn to like map because in this kind of case it'll probably run faster than the for loop):
my $outstr = ""; $outstr .= sprintf("%2.2x",ord($_)) for (split //); print $outstr, $/;
For that matter, when doing a simple "in->out" text filter like this, I prefer not to use open at all -- just  while (<>) { ... print; } -- then provide the input file name as a command line arg, and redirect STDOUT to some other file.