All pastes #430788 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-04-09 08:05 UTC
rendered paste body
{
	syntax=>qr/asc2hex: (.+)/,
	code=> sub {
		my ($self, $said, $ascii) = @_;
		my $str = join "", map { "\\x".unpack ("H*", $_) } split "", $ascii;
		(my $val = $str) =~ s/\\x//g;
		$self->reply( $said, "Shellcode: $val $str" );
}
}

Above code is untested, but it's the only sense I could make out of it. I didn't see $_ being autoset by the bot, and your assignment of s///g in scalar context only returns the number of matches (cf. perldoc perlop). Also, the captures are stored in $1 for each s///, so you need to use those rather than the same, unchanged $ascii. From your problem, I think unpack is what you want to use. I don't have much experience with it, but the above is what I came up with, and I think it will do what you want. For instance, if $ascii is set to "hello", you should get "Shellcode 68656c6c6f \x68\x65\x6c\x6c\x6f". If you do want to split at the beginning of every even character (i.e., 0, 2, 4, ...) for some reason:
	code=> sub {
                my $val = join "", map { unpack ("H*", $_) } $ascii =~ m/.(?:.|\Z)/g;
                (my $str = $val) ~ s/(..)/\\x$1/g; print "$val $str\n";
                $self->reply( $said, "Shellcode: $val $str" );
}
Using "hello" again for $ascii, you should get the same result.

HTH,
unobe