develooper Front page | perl.beginners | Postings from January 2002

RE: change the format of file.

Thread Previous | Thread Next
From:
Wagner-David
Date:
January 30, 2002 12:46
Subject:
RE: change the format of file.
Message ID:
113A7A0D1F47D511B92E00D0B7E03DAB0187BA90@pmail02.vikingfreight.com
	Here is a display portion of what you want to do:

#!perl -w
  while ( <DATA> ) {
     chomp;
     printf "definition1 %s\ndefinition2\ndefinition3\ndefinition4:%s\n", $_, $_;
   }
__DATA__
name1	
name2	
^------ Script ends here

Output:
definition1 name1
definition2
definition3
definition4:name1
definition1 name2
definition2
definition3
definition4:name2

	You should be able to add the fileout, etc. It is easier here to use __DATA__ vs creating a file.

Wags ;)
-----Original Message-----
From: Anand, Pankaj [mailto:Pankaj.Anand@bestbuy.com]
Sent: Wednesday, January 30, 2002 12:18
To: 'Beginners (E-mail)
Subject: change the format of file.


Hi ,
I want to make a perl script which can take the input from a file which is
in this form -
name1	
name2	

I want to change it to this format -
definition1	name1
definition2	
definition3
definition4:name1

definition1	name2
definition2	
definition3
definition4:name1

and so on

Thanx


952)324-0422



-- 
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About