473,403 Members | 2,183 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

doubt on while

I have been studying programming perl. There I have come across a code something as below:

Expand|Select|Wrap|Line Numbers
  1.  while (<FILE>) {
  2.     print if /http:/;
  3.     print if /ftp:/;
  4.     print if /mailto:/;
  5.     # What next?
  6. }
Can u please tell me what is FILE there?

cheers,
pavan.
Jun 2 '08 #1
2 1121
nithinpes
410 Expert 256MB
FILE is the file handler for the file that you are reading. When you want to process a file, you have to change/redirect the input stream/ output stream to the file. For this purpose, a file-handle is created when you use open() function.
Expand|Select|Wrap|Line Numbers
  1. open(FILE,"data.txt") or die "opening file failed";
  2.  
When you assign this file-handle within angular brackets to an array
Expand|Select|Wrap|Line Numbers
  1. @data=<FILE>;
  2.  
The array would contain entire content of file with each line in file as each element in the array(as '\n' is the default input record separator)
When you assign it to a scalar, it would contain the first line of file:
Expand|Select|Wrap|Line Numbers
  1. $data=<FILE>;
  2.  
In your code, while(<FILE>) {} loop will iterate through the file, one line at a time.



I would suggest you to go through Files and Data
Jun 2 '08 #2
If you want some basic stuff about files, check [DELETED]
Jul 8 '08 #3

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

Similar topics

4
by: RK | last post by:
Hi, In my application, I need to copy data from an Excel file into a SQL table. The article related to this can be found at http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B306572 ...
138
by: ambika | last post by:
Hello, Am not very good with pointers in C,but I have a small doubt about the way these pointers work.. We all know that in an array say x,x is gonna point to the first element in that...
6
by: Luca | last post by:
I have a doubt: is it dangerous to create widgets out of the main thread, or it is dangerous to call methods of a widgets out of the thread which created it? or both? TIA Perry
3
by: orium69 | last post by:
Hi everyone! I have a doubt, when I free an alloced memory, how does the compiler know how many bytes I have alloced forward the pointer. eg: int *coiso; coiso=(int...
11
by: krishnamaddi | last post by:
Hi Friends, I am having some doubt. I want to print an ASP Page, for this i need to use java script. the problem is while printing if the line is too big, i can't print those data properly . i am...
77
by: muttaa | last post by:
Hello all, My doubt is going to be so primitive that i ask you all to forgive me beforehand.... Here's the code snippet: int main() { int x=5;
6
by: edu.mvk | last post by:
Hi, in the below statement : class A { int *i; A(){ };
5
by: meenu_susi | last post by:
doubt regarding select box....urgent in the below code i am getting data from database..according to the condition.. i want the available data in database to get displayed in selectbox.. for...
51
by: deepak | last post by:
Hi, For the program pasted below, scanf is not waiting for the second user input. Can someone suggest reason for this? void main() { char c;
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.