author | sl |
Tue, 10 Jun 2014 14:32:02 +0200 | |
changeset 1 | 260cb5ec6c19 |
permissions | -rw-r--r-- |
1 #
2 # Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
3 # All rights reserved.
4 # This component and the accompanying materials are made available
5 # under the terms of "Eclipse Public License v1.0"
6 # which accompanies this distribution, and is available
7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 #
9 # Initial Contributors:
10 # Nokia Corporation - initial contribution.
11 #
12 # Contributors:
13 #
14 # Description:
15 #
17 use Getopt::Long;
19 sub Usage()
20 {
21 print <<USAGE_EOF;
22 Usage
23 perl uartscript.pl --in=FileNameIn --out=FileNameOut --port=Port --baud=Baud --help
25 --in=FileNameIn : Input file name
27 --out=FileNameOut : Output file name
29 --port=Port : Serial port number
31 --baud=Baud : Baud rate of the port
33 --help : This help
34 USAGE_EOF
35 exit( 0 )
36 }
38 sub main()
39 {
40 my $help='';
41 my $input="";
42 my $output="";
43 my $port="";
44 my $baud="";
46 GetOptions(
47 'in=s' => \$input,
48 'out=s' => \$output,
49 'port=s' => \$port,
50 'baud=s' => \$baud,
51 'help' => \$help
52 );
54 if($help or ($input eq "") or ($output eq "") or ($port eq "") or ($baud eq ""))
55 {
56 Usage();
57 exit(0);
58 }
60 open(FIN, $input);
61 open(FOUT, ">$output");
63 foreach (<FIN>)
64 {
65 if (/<port>/)
66 {
67 s/<port>/$port/;
68 }
69 if (/<baud>/)
70 {
71 s/<baud>/$baud/;
72 }
73 print FOUT $_;
74 }
75 close(FIN);
76 close(FOUT);
77 }
79 main();