473,473 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

perl help

6 New Member
i dont have a good experience with a perl..

and i need anyone to help me to

Describe what this program does with explanation plz :

Expand|Select|Wrap|Line Numbers
  1. @files = (‘‘f1.txt’’, ‘‘f2.txt’’, ‘‘f3.txt’’);
  2. foreach $file (@files) {
  3. open (FILE, ‘‘$file’’) || die ‘‘Cannot open $file\n’’;
  4. $lines = <FILE>;
  5. close FILE;
  6. open (FILE, ‘‘>>out’’);
  7. print FILE $lines;
  8. close FILE;
  9. }
plz ASAP

Best Regards
Dec 7 '07 #1
8 951
eWish
971 Recognized Expert Contributor
When posting code here at TSDN please use the [CODE][/CODE] rather than the Bold Tags.

Regards,

Kevin
Dec 7 '07 #2
eWish
971 Recognized Expert Contributor
Your code opens an array of files, reads the contents and appends the output file with the conents of the other files.

--Kevin
Dec 7 '07 #3
qtrsniper
6 New Member
does it print all lines in the files or not ??

and thanx for reply me
Dec 7 '07 #4
eWish
971 Recognized Expert Contributor
appends the output file with the conents of the other files.
Yes it does. Please read my previous post.
Dec 7 '07 #5
qtrsniper
6 New Member
Sorry for disturbing :)

actually i've read your previuos reply

but i have another answer from my lectrurer which is :

the program appends the first line from each files.

and now i get confuse which one is the right answer ??

Thanx .
Dec 7 '07 #6
eWish
971 Recognized Expert Contributor
Sorry, it is early. He is correct. It does read the first line only. Have you tried to run the code yourself? If you want it to print the entire contents then you can assign it to an array instead.

--Kevin
Dec 7 '07 #7
qtrsniper
6 New Member
OK ..
i've alreay tried this code..

what is the logic behind this answer. ?
can you explain why it appends the first line only for each file.plz??
Dec 7 '07 #8
KevinADC
4,059 Recognized Expert Specialist
Why don't you aks your teacher/instructor/lecturor these questions?
Dec 7 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: dpackwood | last post by:
Hello, I have two different scripts that do pretty much the same thing. The main perl script is on Windows. It runs and in the middle of it, it then calls out another perl script that then...
9
by: Martin Foster | last post by:
Hi. I would like to be able to mimic the unix tool 'uniq' within a Perl script. I have a file with entries that look like this 4 10 21 37 58 83 111 145 184 226...
4
by: Firewalker | last post by:
Hey guys, I am newbie to perl. I am trying to deal with dates ( such trying to find what the date would be after month). Is therea function or date class( I am a java programmer, I couldnt find...
1
by: smsabu2002 | last post by:
Hi, I am facing the build problem while installing the DBD-MySql perl module (ver 2.9008) using both GCC and CC compilers in HP-UX machine. For the Build using GCC, the compiler error is...
0
by: Kirt Loki Dankmyer | last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of different switches, but I can't get it to compile....
2
by: shruti | last post by:
hiii all I'm tryin to call a perl script from a C program in following 2 ways- 1.By callin system function. But there's some problem because the system function is not able to executeany...
6
by: surfivor | last post by:
I may be involved in a data migration project involving databases and creating XML feeds. Our site is PHP based, so I imagine the team might suggest PHP, but I had a look at the PHP documentation...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.