Learning Perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Learning Perl
# 1  
Old 11-20-2010
Learning Perl

Folks! Anyone please explain the behavior of this program step by step. Thanks.
Code:
#! /usr/bin/perl
$testfile = "./testfile2";
for ( $i = 1, $i <= 5, $i++) {
  open ($FILE, ">", $testfile);
  print ($FILE "Output 1 \n");
  close ($FILE);
}
print "The value of (4 * 2) / 2 is ";
print (4 * 2) / 2;
print ("\Output 2 \n");


Last edited by Scott; 11-21-2010 at 07:03 AM.. Reason: Code tags, please...
# 2  
Old 11-20-2010
This program opens file named "./testfile2" for writing.
five times it writes: "Output 1 \n" to this file. Note that it doesn't append to it because of this: ">" it wipes all data and then writes to it. if you want to append to it use: ">>".
The last three lines are trivial.
This User Gave Thanks to majid.merkava For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

PERL-CGI learning

Hello All, I am actually learning PERL and more interested to learn CGI script too. Can any suggest a forum or weblink which is more helpful for a dummy CGI developer. Thanks (6 Replies)
Discussion started by: posix
6 Replies

2. Shell Programming and Scripting

Should I focus efforts on learning Perl or develop skills in awk, sed, etc

Good afternoon, I am not trying to start a debate. Please don't take it that way. I'm not trying to make this a Perl versus Bash scripts thing. I have been writing shell scripts for several years. I am not 100%, but I seem to get the job done. I would like to start focusing on spending... (11 Replies)
Discussion started by: brianjb
11 Replies

3. Shell Programming and Scripting

What do people think of the "Beginning Perl" book for learning Perl?

Seems like it's written out pretty well for a beginner to learn, any thoughts or recommendations for other books? I'd post the link but I can't do that yet. The book is called "Beginning Perl" by Simon Cozens (2 Replies)
Discussion started by: budfoxcat
2 Replies

4. UNIX for Dummies Questions & Answers

learning unix

Hi, i have started to learn unix (on and off for the past few months) and am wishing to move into that area in the administration field of it. I have been working in the help desk area (desktop support - windows based) for about 2.5 years and moved into a team leading role for 1 year in which i... (1 Reply)
Discussion started by: donnieDarko
1 Replies

5. Shell Programming and Scripting

Good learning perl Book

Can anyone suggest a good pearl book?:) (2 Replies)
Discussion started by: nygenka
2 Replies

6. UNIX for Dummies Questions & Answers

Pls guide me in learning in Perl Module and packages

Hi, It is very urgent. Pls guide me in learning Perl Module and the Packages. Eventhough i tried in the google, I didnt get upto my expectations. Pls guide me how to create , build Module and the package. Many Thanks. (3 Replies)
Discussion started by: Yamini Thoppen
3 Replies

7. Shell Programming and Scripting

Learning Perl 3rd Edition

Does anyone know where I might be able to download the exercises from the learning perl 3rd edition book. Any URL's would be valuable! Thanks:confused: (1 Reply)
Discussion started by: bilal_aa
1 Replies

8. Shell Programming and Scripting

Learning CGI using Perl

hi everyone, i am learning CGI using Perl, but i am having problem to compile and run the scripts. the thing is that, when i want to compile my scripts i have to get connected to the internet and have to upload the scripts to a server and then only i can compile and run my scripts. so, can... (2 Replies)
Discussion started by: shifan
2 Replies

9. UNIX for Dummies Questions & Answers

learning on my own

can i do this? i am learning this on my own..and from the book..simple unix i am not sure if the syntax would work if statement then statement do or for or while statement done else statement fi.... I dont know how else to explain that...I hope I... (2 Replies)
Discussion started by: jonas27
2 Replies
Login or Register to Ask a Question

Featured Tech Videos