RE: Read a single line in a file.




----Original Message-----
From: Umesh T G [mailto:umesh.perl@xxxxxxxxx]
Sent: Friday, July 29, 2005 3:47 PM
To: beginners@xxxxxxxx
Subject: Read a single line in a file.


Hello List,

I have a file with multiple lines. I want to read only the first line.
and a particular word in that line.

For eg:
File.txt

apple,grape,orange,banana
some other lines
continued.

So I want only the word grape here. How to get it?

--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Hi ,

Follow the below procedure , may solve your problem. But be more prsice
with your problems.

----
Open( READ,"<File.txt"); --> open the file in read mode

$line=<READ>;

$line=~ /^[a-z]*,([a-z]*),.*/; ---> captures the second word of the
line.

Print "desired word is $1 \n";

---


Is this what u want ?

--
Arjun



Confidentiality Notice

The information contained in this electronic message and any attachments to this message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or Mailadmin@xxxxxxxxx immediately
and destroy all copies of this message and any attachments.
.



Relevant Pages

  • RE: IDS Recommendation
    ... CONFIDENTIALITY NOTICE: This email and any attachments are for the ... exclusive and confidential use of the intended recipient. ... Our security group currently is not doing this...but our CIO ...
    (Security-Basics)
  • RE: Xp Home
    ... >The connection is for my proxy, ... CONFIDENTIALITY NOTICE: This email and any attachments are for the ... exclusive and confidential use of the intended recipient. ...
    (Focus-Microsoft)
  • RE: Outbound Port scans, ports 3800+
    ... >ports 3800 and higher. ... >CONFIDENTIALITY NOTICE: ... If the reader of this message is not the intended recipient, ... send/receive up to 3MB attachments. ...
    (Security-Basics)
  • Replcaing printf by print
    ... Does replacing printf by print make any difference in the program? ... Confidentiality Notice ... The information contained in this electronic message and any attachments to this message are intended ... you are not the intended recipient, please notify the sender at Wipro or Mailadmin@xxxxxxxxx immediately ...
    (perl.beginners)
  • Networking-perl problem
    ... I have to gather data from external devices and process it. ... Confidentiality Notice ... The information contained in this electronic message and any attachments to this message are intended ... you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately ...
    (perl.beginners)