⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.177
Server IP:
50.6.168.112
Server:
Linux server-617809.webnetzimbabwe.com 5.14.0-570.25.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 9 04:57:09 EDT 2025 x86_64
Server Software:
Apache
PHP Version:
8.4.10
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
.cpan
/
build
/
YAML-LibYAML-0.89-0
/
t
/
View File Name :
io-handle.t
use FindBin '$Bin'; use lib $Bin; use strict; my $t = $Bin; use utf8; use Encode; use IO::Pipe; use IO::File; use TestYAML tests => 6; use YAML::XS qw/DumpFile LoadFile/;; my $testdata = 'El país es medible. La patria es del tamaño del corazón de quien la quiere.'; # IO::Pipe my $pipe = new IO::Pipe; if ( fork() ) { # parent reads from IO::Pipe handle $pipe->reader(); my $recv_data = LoadFile($pipe); is length($recv_data), length($testdata), 'LoadFile from IO::Pipe read data'; is $recv_data, $testdata, 'LoadFile from IO::Pipe contents is correct'; } else { # child writes to IO::Pipe handle $pipe->writer(); DumpFile($pipe, $testdata); exit 0; } # IO::File my $file = "$t/dump-io-file-$$.yaml"; my $fh = new IO::File; # write to IO::File handle $fh->open($file, ">") or die $!; DumpFile($fh, $testdata); $fh->close; ok -e $file, 'IO::File output file exists'; # read from IO::File handle $fh->open($file, '<') or die $!; my $yaml = do { local $/; <$fh> }; is decode_utf8($yaml), "--- $testdata\n", 'LoadFile from IO::File contents is correct'; $fh->seek(0, 0); my $read_data = LoadFile($fh) or die $!; $fh->close; is length($read_data), length($testdata), 'LoadFile from IO::File read data'; is $read_data, $testdata, 'LoadFile from IO::File read data'; END { unlink $file if defined $file; # $file will be undefined in fork child. }