Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Open Source > Perl
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Perl section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old July 23rd, 2013, 06:03 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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;
Reply With Quote
  #2 (permalink)  
Old December 20th, 2014, 08:16 AM
Registered User
Points: 6, Level: 1
Points: 6, Level: 1 Points: 6, Level: 1 Points: 6, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2014
Location: Busovaca, BIH
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to eurohttp Send a message via Skype™ to eurohttp
Default 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.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off



All times are GMT -4. The time now is 01:13 PM.


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