habicamasuchi
Technical User
I am having trouble using unpack instead of split. I know that unpack is quite a bit faster than split and therefore would rather use unpack. The particulars:
open(FILE,"file") or die "No such file";
open(OUT,">outfile";
while(<FILE>) {
$form = unpack("x145 A1", $_);
next unless ($form eq "O");
$_ = unpack("A1000", $_);
@data = unpack("C*",$_);
The problem is with this last line. I want to split the string (which is 2000 characters long) so that each character will be a element of the array. split(//) works but is really slow. unpack("C*",$_) works but gives me the numerica ASCII values instead of the actual characters. How do I get unpack to split the string into individual characters?
open(FILE,"file") or die "No such file";
open(OUT,">outfile";
while(<FILE>) {
$form = unpack("x145 A1", $_);
next unless ($form eq "O");
$_ = unpack("A1000", $_);
@data = unpack("C*",$_);
The problem is with this last line. I want to split the string (which is 2000 characters long) so that each character will be a element of the array. split(//) works but is really slow. unpack("C*",$_) works but gives me the numerica ASCII values instead of the actual characters. How do I get unpack to split the string into individual characters?