in reply to Re: concatenating text files before reading
in thread concatenating text files before reading

I can write many lines of code to do it, but I'm sure there is a better and smarter way of doing it. That's why I asked for help:)

First thing I learned about Perl: "There are more than 1000 ways of doing it"

  • Comment on Re^2: concatenating text files before reading

Replies are listed 'Best First'.
Re^3: concatenating text files before reading
by Anonymous Monk on Sep 05, 2013 at 07:17 UTC

    I can write many lines of code to do it, but I'm sure there is a better and smarter way of doing it. That's why I asked for help:) First thing I learned about Perl: "There are more than 1000 ways of doing it"

    If you remove the newlines then it all fits on one line -- I sure would like to see how you would do it

Re^3: concatenating text files before reading
by Anonymous Monk on Sep 05, 2013 at 09:40 UTC
    my $textref = cat_files_ref( ... ); sub cat_files_ref { use File::Slurp; my $buffer = ""; for my $file ( @_ ){ read_file( $bin_file, buf_ref => \$buffer, { binmode => ':raw' } ) ; } return \$buffer; } sub cat_files_ref { use Path::Tiny; my $buffer = ""; for my $file ( @_ ){ $buffer .= path( $file )->realpath->slurp_raw; } return \$buffer; } sub cat_files_ref { use IO::All; my $content; for my $file ( @_ ){ $content << io($file); } return \$content; }