I couldn't understand what exactly "W" do.
my $x = "this is my string";
print unpack("W",substr($x,0,1));
Prints: 116
my $x = "this is my string";
print unpack("W",$x);
Still Prints: 116
I couldn't understand what exactly "W" do.
my $x = "this is my string";
print unpack("W",substr($x,0,1));
Prints: 116
my $x = "this is my string";
print unpack("W",$x);
Still Prints: 116
From perldoc: W An unsigned char value (can be greater than 255).
Both of your examples return the same thing because your unpack argument "W"
only consumes one character. Try "W*"
instead.