#!/usr/bin/perl -w # "REGexpandSZgen" - generate the formatted hex string from a normal # ascii input string- for a REGEDIT file; to enter a REG_EXPAND_SZ # data-type entry into the MS Windows Registry. use strict; my $encme = pop(@ARGV) || ; $encme =~s% (\x{0d}|\x{0a}{1,2})\Z %%x; if($encme =~m{^("[^"]+"|\@)\=(.*)$}) { # " does not appear where "entry"= @ $encme = [$1, $2]; } my $cvtd = [ map { sprintf "%02x",ord } split('', ref $encme ? $encme->[1]:$encme) ]; if(not $ARGV[0]) { print '', (ref $encme ? "$encme->[0]=":""), "hex(2):", join(',',@$cvtd,'00'), "\n"; } else { # any prepended arg causes us to # debug / test / verify the string. print "\n IN: ",(ref $encme ? $encme->[1]:$encme),"\nOUT: " , pack("c*", map(hex, @$cvtd[0..(@$cvtd - 0x1)])) , "\n"; } __END__ This Program is Free Software, (C)2003 Soren Andersen it may be used under the same terms as Perl itself.