7 plan 'skip_all', "Scalar::Util not available" unless
8 eval 'use Scalar::Util qw(tainted) ; tainted($0) ; 1';
12 my $path = "data.txt";
13 my $data = "random junk\nline2";
16 # write something to that file
17 open(FILE, ">$path") or skip 4, "can't write to '$path': $!";
21 # read the file using File::Slurp in scalar context
22 my $content = eval { read_file($path) };
23 is( $@, '', "read_file() in scalar context" );
24 ok( tainted($content), " => returned content should be tainted" );
27 # # reconstruct the full lines by merging items by pairs
28 # for my $k (0..int($#lines/2)) {
30 # $lines[$k] = (defined $lines[$i] ? $lines[$i] : '')
31 # . (defined $lines[$i+1] ? $lines[$i+1] : '');
34 # # remove the rest of the items
35 # splice(@lines, int($#lines/2)+1);
36 # pop @lines unless $lines[-1];
38 # $_ .= $/ for @lines ;
40 # my @lines = split m{$/}, $content, -1;
41 # my @parts = split m{($/)}, $content, -1;
43 # # my @parts = $content =~ m{.+?(?:$/)?}g ;
46 # while( @parts > 2 ) {
48 # my( $line, $sep ) = splice( @parts, 0, 2 ) ;
49 # push @lines, "$line$sep" ;
52 # push @lines, shift @parts if @parts ;
54 # # ok( tainted($lines[0]), " text => returned content should be tainted" );
56 # read the file using File::Slurp in list context
57 my @content = eval { read_file($path) };
58 is( $@, '', "read_file() in list context" );
59 ok( tainted($content[0]), " => returned content should be tainted" );
61 my $text = join( '', @content ) ;
63 is( $text, $content, "list eq scalar" );
66 # ok( tainted($lines[0]), " => returned content should be tainted" );