releasing/cbrtools/perl/EnvData.bat
changeset 602 3145852acc89
equal deleted inserted replaced
600:6d08f4a05d93 602:3145852acc89
       
     1 @REM Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 @REM All rights reserved.
       
     3 @REM This component and the accompanying materials are made available
       
     4 @REM under the terms of the License "Eclipse Public License v1.0"
       
     5 @REM which accompanies this distribution, and is available
       
     6 @REM at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 @REM 
       
     8 @REM Initial Contributors:
       
     9 @REM Nokia Corporation - initial contribution.
       
    10 @REM 
       
    11 @REM Contributors:
       
    12 @REM 
       
    13 @REM Description:
       
    14 @REM 
       
    15 
       
    16 @rem = '--*-Perl-*--
       
    17 @echo off
       
    18 if "%OS%" == "Windows_NT" goto WinNT
       
    19 perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
       
    20 goto endofperl
       
    21 :WinNT
       
    22 perl -w -x -S "%0" %*
       
    23 if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
       
    24 if %errorlevel% == 9009 echo You do not have Perl in your PATH.
       
    25 if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
       
    26 goto endofperl
       
    27 @rem ';
       
    28 #!perl -w
       
    29 #line 15
       
    30 $0 =~ s|\.bat||i;
       
    31 unless (-f $0) {
       
    32     $0 =~ s|.*[/\\]||;
       
    33     for (".", split ';', $ENV{PATH}) {
       
    34 	$_ = "." if $_ eq "";
       
    35 	$0 = "$_/$0" , goto doit if -f "$_/$0";
       
    36     }
       
    37     die "`$0' not found.\n";
       
    38 }
       
    39 doit: exec "perl", "-x", $0, @ARGV;
       
    40 die "Failed to exec `$0': $!";
       
    41 __END__
       
    42 
       
    43 =head1 NAME
       
    44 
       
    45 runperl.bat - "universal" batch file to run perl scripts
       
    46 
       
    47 =head1 SYNOPSIS
       
    48 
       
    49 	C:\> copy runperl.bat foo.bat
       
    50 	C:\> foo
       
    51 	[..runs the perl script `foo'..]
       
    52 	
       
    53 	C:\> foo.bat
       
    54 	[..runs the perl script `foo'..]
       
    55 	
       
    56 
       
    57 =head1 DESCRIPTION
       
    58 
       
    59 This file can be copied to any file name ending in the ".bat" suffix.
       
    60 When executed on a DOS-like operating system, it will invoke the perl
       
    61 script of the same name, but without the ".bat" suffix.  It will
       
    62 look for the script in the same directory as itself, and then in
       
    63 the current directory, and then search the directories in your PATH.
       
    64 
       
    65 It relies on the C<exec()> operator, so you will need to make sure
       
    66 that works in your perl.
       
    67 
       
    68 This method of invoking perl scripts has some advantages over
       
    69 batch-file wrappers like C<pl2bat.bat>:  it avoids duplication
       
    70 of all the code; it ensures C<$0> contains the same name as the
       
    71 executing file, without any egregious ".bat" suffix; it allows
       
    72 you to separate your perl scripts from the wrapper used to
       
    73 run them; since the wrapper is generic, you can use symbolic
       
    74 links to simply link to C<runperl.bat>, if you are serving your
       
    75 files on a filesystem that supports that.
       
    76 
       
    77 On the other hand, if the batch file is invoked with the ".bat"
       
    78 suffix, it does an extra C<exec()>.  This may be a performance
       
    79 issue.  You can avoid this by running it without specifying
       
    80 the ".bat" suffix.
       
    81 
       
    82 Perl is invoked with the -x flag, so the script must contain
       
    83 a C<#!perl> line.  Any flags found on that line will be honored.
       
    84 
       
    85 =head1 BUGS
       
    86 
       
    87 Perl is invoked with the -S flag, so it will search the PATH to find
       
    88 the script.  This may have undesirable effects.
       
    89 
       
    90 =head1 SEE ALSO
       
    91 
       
    92 perl, perlwin32, pl2bat.bat
       
    93 
       
    94 =cut
       
    95 
       
    96 
       
    97 __END__
       
    98 :endofperl