The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




Thread: help xml
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 10-07-2008
summer_cherry summer_cherry is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,092
perl

hi try below perl scirpt
say the script name is a.pl, below command can address your issue.

Quote:
perl a.pl 2233


Code:
format STDOUT_TOP =
<Comp>
        <main>
.
format STDOUT =
		<hlp fs="@<<<<" es="@<<<<">
		$text1     $text2  
			<std no="@<<<"/>
			$text3
			<id="@<<"/>
			$text4
		</hlp>
.
$file=shift;
open(FH,"<$file") or die "Can not open file";
while(<FH>){
	@arr=split(" ",$_);
	$text1=$arr[0];
	$text2=$arr[0]+1;
	$text3=$file;
	$text4=$arr[1];
	write;
}
print "        </main>\n";
print "</Comp>\n";
close(FH);