Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: perl parsing

by Laurent_R (Canon)
on Oct 04, 2017 at 06:27 UTC ( [id://1200644]=note: print w/replies, xml ) Need Help??


in reply to perl parsing

You've been given a solution that presumably works fine, but I would like to comment with a side note.
my @file = `cat text.txt`;
Calling the system or shell for reading the file is really poor practice in Perl (except possibly for command-line one-liners). Perl offers all the tools to do that with much better control on what happens and what to do if something goes wrong.

Look at the way poj opens and reads the file in pure Perl, that's much better.

Replies are listed 'Best First'.
Re^2: perl parsing
by AppleFritter (Vicar) on Oct 04, 2017 at 12:11 UTC

    There's also File::Slurp, which is quite useful if you want to read an entire file in one go:

    use File::Slurp; my @file = read_file('text.txt');
      Please, don't recommend broken modules.

      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1200644]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-25 20:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found