Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: iterative foreach loop

by 1nickt (Canon)
on Nov 14, 2017 at 13:56 UTC ( [id://1203376]=note: print w/replies, xml ) Need Help??


in reply to Re^2: iterative foreach loop
in thread iterative foreach loop

That's fine, subject to the hints haukex provided.

Now that you understand the diamond operator (perlop: IO Operators) you can use a modern tool to do the busywork of opening and closing files, character encoding, removing new line characters, error handling, etc.

use strict; use warnings; use feature 'say'; use Path::Tiny; # imports path() my $filename = '/TEXT2.txt'; say for path( $filename )->lines_utf8({ chomp => 1 }); __END__

See also:

Hope this helps!


The way forward always starts with a minimal test.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2024-04-19 09:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found