App-NoPAN
view release on metacpan or search on metacpan
inc/File/Slurp.pm view on Meta::CPAN
sysseek( $read_fh, tell( $read_fh ), SEEK_SET ) ||
croak "sysseek $!" ;
}
}
else {
# a regular file. set the sysopen mode
my $mode = O_RDONLY ;
$mode |= O_BINARY if $args{'binmode'} ;
#printf "RD: BINARY %x MODE %x\n", O_BINARY, $mode ;
# open the file and handle any error
$read_fh = gensym ;
unless ( sysopen( $read_fh, $file_name, $mode ) ) {
@_ = ( \%args, "read_file '$file_name' - sysopen: $!");
goto &_error ;
}
inc/File/Slurp.pm view on Meta::CPAN
}
# handle the read error
@_ = ( \%args, "read_file '$file_name' - sysread: $!");
goto &_error ;
}
# fix up cr/lf to be a newline if this is a windows text file
${$buf_ref} =~ s/\015\012/\n/g if $is_win32 && !$args{'binmode'} ;
# this is the 5 returns in a row. each handles one possible
# combination of caller context and requested return type
my $sep = $/ ;
$sep = '\n\n+' if defined $sep && $sep eq '' ;
# caller wants to get an array ref of lines
# this split doesn't work since it tries to use variable length lookbehind
inc/File/Slurp.pm view on Meta::CPAN
# in atomic mode, we spew to a temp file so make one and save the original
# file name.
$orig_file_name = $file_name ;
$file_name .= ".$$" ;
}
# set the mode for the sysopen
my $mode = O_WRONLY | O_CREAT ;
$mode |= O_BINARY if $args->{'binmode'} ;
$mode |= O_APPEND if $args->{'append'} ;
$mode |= O_EXCL if $args->{'no_clobber'} ;
#printf "WR: BINARY %x MODE %x\n", O_BINARY, $mode ;
# open the file and handle any error.
$write_fh = gensym ;
unless ( sysopen( $write_fh, $file_name, $mode ) ) {
@_ = ( $args, "write_file '$file_name' - sysopen: $!");
inc/File/Slurp.pm view on Meta::CPAN
}
}
sysseek( $write_fh, 0, SEEK_END ) if $args->{'append'} ;
#print 'WR before data ', unpack( 'H*', ${$buf_ref}), "\n" ;
# fix up newline to write cr/lf if this is a windows text file
if ( $is_win32 && !$args->{'binmode'} ) {
# copy the write data if it was passed by ref so we don't clobber the
# caller's data
$buf_ref = \do{ my $copy = ${$buf_ref}; } if $data_is_ref ;
${$buf_ref} =~ s/\n/\015\012/g ;
}
#print 'after data ', unpack( 'H*', ${$buf_ref}), "\n" ;
# get the size of how much we are writing and init the offset into that buffer
( run in 1.120 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )