lhp@nereida:~/Lperl/src/inline$ ./file.pl | cat -n 1 #!/usr/bin/perl -w 2 use strict; 3 use Inline 'C'; 4 5 my $p = shift || $0; 6 my $size = shift || 0; 7 my $x = lee_fich($p, $size); 8 print $x; 9 __END__ 10 __C__ 11 12 SV * lee_fich(char * name, STRLEN size) { 13 PerlIO *fp; 14 SV *insv; /* my $sv; */ 15 16 ENTER; /* { #abrir bloque */ 17 save_item(PL_rs); /* local $/; */ 18 sv_setsv(PL_rs, &PL_sv_undef); /* $/ = undef */ 19 fp = PerlIO_open(name,"r"); /* open fp, $name */ 20 insv = newSV(size); 21 sv_gets(insv, fp, 0); /* $sv = <fp>; */ 22 PerlIO_close(fp); 23 LEAVE; /* } #cerrar bloque */ 24 //return newRV_noinc(insv); 25 return (insv); 26 }
Casiano Rodríguez León