CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
<> again...

 



Rysin
Novice

Aug 5, 2008, 7:41 AM

Post #1 of 5 (489 views)
<> again... Can't Post

Ive just returned from my travels and began reading up on the site that kevinR gave me. However I still dont understand the diamond operator.
I have a file called text.txt and it contains

Code
This 
Is
Five
Seperate
Lines

And I wrote a program to process that and print it

Code
while(<text.txt>) { 
chomp;
print "$_";
};

Why isnt this working? All help is appreciated. Thankyou.


KevinR
Veteran


Aug 5, 2008, 8:17 AM

Post #2 of 5 (488 views)
Re: [Rysin] <> again... [In reply to] Can't Post

see if this example helps"


Code
open (IN, 'text.txt') or die "$!"; 
while(<IN>) {
print;
}
close(IN);

-------------------------------------------------


Rysin
Novice

Aug 5, 2008, 8:42 AM

Post #3 of 5 (484 views)
Re: [KevinR] <> again... [In reply to] Can't Post

Thanks KevinR it works now! You dont have to if you dont want to but could you explain some of the code to me. Specifically the first line.


KevinR
Veteran


Aug 5, 2008, 9:48 AM

Post #4 of 5 (483 views)
Re: [Rysin] <> again... [In reply to] Can't Post

You can look up the open() function in the perl documentation:

http://perldoc.perl.org/functions/open.html

It will explain the open() function in detail. open() is a very basic function, if you do any file I/O you will want to know how to use it properly. There is also sysopen().
-------------------------------------------------


Rysin
Novice

Aug 5, 2008, 10:26 AM

Post #5 of 5 (478 views)
Re: [KevinR] <> again... [In reply to] Can't Post

Thanks KevinR.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives