How to split files in perl
By Alvin Alexander. Last updated: June 4, Perl split function - how to read a CSV file. Use File::Basename to separate a filename from its directory. Perl 'split' function - how to process text data files. That's why it looks like there's extra whitespace. The extra space is because you're interpolating file into a single string, which by default interposes a space character between the elements. Add a comment.
Active Oldest Votes. Improve this answer. Borodin Borodin k 9 9 gold badges 67 67 silver badges bronze badges. Stefan Majewsky. Tried to run your script but nothing happens. The script starts but never finish, so I have to Ctrl-C it. It expects the input file on the command line like mine does. If you don't supply one it will hang waiting for input from the keyboard.
I did not really think about it. To have others fix bugs in my code? That's not even golf, that's straight-forward Perl how a seasoned programmer writes it. Perl split function - How to process pipe-delimited text files.
How to process a CSV file in Scala. Scala 3 opaque types: How to create meaningful type names. Scala 3 modules: How to build modular systems. Active 8 years, 10 months ago. Viewed times. Thanks for all your help. Improve this question. I have tried this code above and it only allows me to break into 5 text files when I am expecting In addition, would there be a more efficient way and shorter code to achieve same objective.
First off, always use strict; and use warnings; in the start of your script. It seems that your way of deciding what file to write to is very complicated. There's no need to slurp the file into the array