p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Perl (http://p2p.wrox.com/forumdisplay.php?f=196)
-   -   cant go further. (http://p2p.wrox.com/showthread.php?t=90585)

zubr July 23rd, 2013 06:03 PM

cant go further.
 
Hi guys.
im a newbie. im sorry to waste your time. but i still hope to get help. im studying. can you explain to my why doesnt it work?

#!/usr/bin/perl
#openfile
open (FILEHANDLE, data.txt) or
die "it doesnt work again: $!";

while (<FILEHANDLE>) {
chomp:
print "$_\n";
}

close FILEHANDLE;

eurohttp December 20th, 2014 09:16 AM

From where did you got this script?
 
I can tell you how to open and close filehandle like this:

open(FH,"<text.txt");
@array = <FH>;
close(FH);

This is for reading. For writing change "<text.txt" to ">text.txt". For appending ">>text.txt".

Now chomp function you could use for STDIN input. You can add use foreach to list file content from array. after close(FH). If you plan to read from file it means. Its very simple.


All times are GMT -4. The time now is 09:22 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.