Vladimir Jebelev wrote:
> 
> Thank you kindly, it solved my problem with lex/yacc code and I am already
> enjoing a 400 times speed increase - as compared to Parse::Yapp or byacc -
> generated code! Next thing to learn is how to return nice hashes back from
> the C code :)

Vladimir,

Did you see the message I sent to the list this morning on creating
hashes? Here it is again:

--------------------------8<----------------------------
use Inline C => DATA;

$hash_ref = my_new_hash(100);
foreach $key (keys %$hash_ref) {
    print "$key => $hash_ref->{$key}\n";
}

__END__

__C__

SV* my_new_hash(int size) {
    int i;
    HV* hash = newHV();
    for (i = 0; i < size; i++) {
        hv_store_ent(hash, newSVpvf("string #%d", i), 
                     newSViv(i), 0);
    }
    return newRV_noinc((SV*) hash);
}
--------------------------8<----------------------------

Brian

-- 
perl -le 'use Inline C=>q{SV*JAxH(char*x){return newSVpvf
("Just Another %s Hacker",x);}};print JAxH+Perl'

Reply via email to