faqts : Computers : Programming : Languages : Perl

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

4 of 15 people (27%) answered Yes
Recently 1 of 10 people (10%) answered Yes

Entry

Perl: File: Line: Read: All: How to read all lines in given text file(s) from command line?

Dec 24th, 2004 19:34
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 25 December 2004 - 04:35 am -------------------

Perl: File: Line: Read: All: How to read all lines in given text file
(s) from command line?

Use the '<>' diamond operator.

This operator gets its data from the file(s) you specified on the
command line.

---
---

Steps: Overview:

 1. -Create a Perl file (e.g. 'test.pl') containing this text

--- cut here: begin --------------------------------------------------

while( <> ) {
 print $_;
}

--- cut here: end ----------------------------------------------------

 2. -On the MSDos command line type the command

      perl <your perl filename> <your text file1> <your text file 
2> ... <your text file last>

     e.g.

      perl test.pl ddd1.txt ddd2.txt

 3. -The script will then print all lines in all this text files
     respectively

---
---

Internet: see also:

---



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