The "deep" opinions are interspersed with your original message. An in-line (pardon the "win32-ish-ness" quote escaping) could take the form:

perl -ne "BEGIN{open S, '>smf';open L, '>lgf'} chomp;if (/[01]\s*$/){print S \"$_\n\";}else{print L \"$_\n\";}" f1.txt

where your data is in f1.txt, your "0" or "1" ending lines go into "smf", and the others go into "lgf"

At 05:54 PM 2/13/04 +0530, you wrote:
Hi All,

I have a file with the following contents (temp.txt).
A1110
G1115
B1110
C1111
D1111
E1113
F1115
and so on. I have to read the contents from this file and create 2 seperate files. The 1st file contains the lines ending with 0 and 1 while the 2nd file contains the lines ending with 3 and 5. I can do this easily by creating a seperate perl script. But I have a constraint. I should not write a seperate file to do this processing.


I am calling the perl from a shell script. Is there any way of calling the Perl program "in-line" with all the required parameters? "In-line" means no seperate file containing the script.

Is it worth doing this?

Only your boss and the deadline knows for sure


Is there a better way of doing it?

As always, yes. That's the cool part about this language, but don't take more than 3 minutes... ;-)



Regards,
Vishal Vasan.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>

Reply via email to