sbsv1/abld/group/perlprep.bat
changeset 607 378360dbbdba
parent 599 fa7a3cc6effd
equal deleted inserted replaced
591:22486c9c7b15 607:378360dbbdba
       
     1 @rem
       
     2 @rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 @rem All rights reserved.
       
     4 @rem This component and the accompanying materials are made available
       
     5 @rem under the terms of "Eclipse Public License v1.0"
       
     6 @rem which accompanies this distribution, and is available
       
     7 @rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 @rem
       
     9 @rem Initial Contributors:
       
    10 @rem Nokia Corporation - initial contribution.
       
    11 @rem
       
    12 @rem Contributors:
       
    13 @rem
       
    14 @rem Description:
       
    15 @rem
       
    16 @echo off
       
    17 
       
    18 REM a basic perl preprocessor
       
    19 
       
    20 if exist %0.bat perl -x %0.bat %1 %2 %3 %4 %5
       
    21 if exist %0 perl -x %0 %1 %2 %3 %4 %5
       
    22 GOTO End
       
    23 
       
    24 #!perl
       
    25 
       
    26 use strict;
       
    27 
       
    28 die "Usage:\nPERLPREP [infile] [outfile]\n" unless @ARGV==2;
       
    29 
       
    30 my ($INFILE, $OUTFILE)=map lc $_, @ARGV;
       
    31 die "Can't find $INFILE\n" unless -e $INFILE;
       
    32 
       
    33 if ($INFILE=~/\.(bat|cmd|pm|pl)$/io) {
       
    34 	open INFILE,$INFILE or die "Can't open $INFILE: $!\n";
       
    35 	my $FileText='';
       
    36 	while (<INFILE>) {
       
    37 		s/(perl)(\.exe)?\s+-w/$1$2/io;		# remove perl -w switch - has to be first switch
       
    38 		s/use\s+strict;\s*\n//oe;	# remove use strict; statement
       
    39 		$FileText.=$_;
       
    40 	}
       
    41 	close INFILE or die "Can't close $INFILE: $!\n";
       
    42 	open OUTFILE,">$OUTFILE" or die "Can't open $OUTFILE: $!\n";
       
    43 	print OUTFILE $FileText;
       
    44 	close OUTFILE or die "Can't close $OUTFILE: $!\n";
       
    45 }
       
    46 else {
       
    47 	system "copy $INFILE $OUTFILE";
       
    48 }
       
    49 
       
    50 
       
    51 __END__
       
    52 
       
    53 :End
       
    54 
       
    55 
       
    56 
       
    57 
       
    58