in reply to concatenating text files before reading

How should I do it in a smart and smooth way?

Can you do it in such a way that you consider dumb/rough?

  • Comment on Re: concatenating text files before reading

Replies are listed 'Best First'.
Re^2: concatenating text files before reading
by Hossein (Acolyte) on Sep 05, 2013 at 07:14 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"

      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; }

      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