You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
autodie .
Rebobinar un identificador de archivo
A veces es necesario dar marcha atrás después de leer.
# identify current position in file, in case the first line isn't a comment
my $current_pos = tell;
while (my $line = readline $fh)
{
if ($line =~ /$START_OF_COMMENT_LINE/)
{
push @names, get_name_from_comment($line);
}
else {
last; # break out of the while loop
}
$current_pos = tell; # keep track of current position, in case we need to rewind the next
line read
}
# Step back a line so that it can be processed later as the first data line
seek $fh, $current_pos, 0;
Lectura y escritura de archivos comprimidos gzip
Escribiendo un archivo comprimido
Para escribir un archivo comprimido, use el módulo IO::Compress::Gzip y cree un identificador de
archivo creando una nueva instancia de IO::Compress::Gzip para el archivo de salida deseado:
use strict;
use warnings;
use open qw( :encoding(UTF-8) :std ); # Make UTF-8 default encoding
use IO::Compress::Gzip;
my $fh_out = IO::Compress::Gzip->new("hello.txt.gz");
print $fh_out "Hello World!\n";
close $fh_out;
use IO::Compress::Gzip;
Leyendo de un archivo comprimido
Para leer un archivo comprimido, use el módulo IO::Uncompress::Gunzip y luego cree un
identificador de archivo creando una nueva instancia de IO::Uncompress::Gunzip para el archivo de
entrada:
https://riptutorial.com/es/home 18