5
5
# http://darkness.codefu.org/wordpress/2003/03/perl-scoping/
6
6
7
7
package PerlPP ;
8
- our $VERSION = ' 0.3.0-pre.2 ' ;
8
+ our $VERSION = ' 0.3.0' ;
9
9
10
10
use v5.10; # provides // - http://perldoc.perl.org/perl5100delta.html
11
11
use strict;
@@ -500,16 +500,17 @@ sub OutputResult {
500
500
# They are listed in alphabetical order by option name,
501
501
# lowercase before upper, although the code does not require that order.
502
502
503
- EVAL => [' e' ,' |eval=s' , ' ' ],
504
503
DEBUG => [' d' ,' |E|debug' , false],
504
+ DEFS => [' D' ,' |define:s%' ], # In %D, and text substitution
505
+ EVAL => [' e' ,' |eval=s' , ' ' ],
505
506
# -h and --help reserved
506
- # --man reserved
507
507
# INPUT_FILENAME assigned by parse_command_line_into()
508
508
KEEP_GOING => [' k' ,' |keep-going' ,false],
509
+ # --man reserved
509
510
OUTPUT_FILENAME => [' o' ,' |output=s' , " " ],
510
- DEFS => [' D' ,' |define:s%' ], # In %D, and text substitution
511
511
SETS => [' s' ,' |set:s%' ], # Extra data in %S, without text substitution
512
512
# --usage reserved
513
+ PRINT_VERSION => [' v' ,' |version' ],
513
514
# -? reserved
514
515
);
515
516
@@ -565,6 +566,11 @@ sub parse_command_line_into {
565
566
sub Main {
566
567
parse_command_line_into \%Opts ;
567
568
569
+ if ($Opts {PRINT_VERSION }) {
570
+ print " PerlPP version $VERSION \n " ;
571
+ return EXIT_OK;
572
+ }
573
+
568
574
# Preamble
569
575
570
576
$Package = $Opts {INPUT_FILENAME };
@@ -662,14 +668,15 @@ sub Main {
662
668
663
669
if ($result ) { # Report errors to console and shell
664
670
print STDERR $result ;
665
- exit 1 ;
671
+ return EXIT_PROC_ERR ;
666
672
} else { # Save successful output
667
673
OutputResult( \EndOB(), $Opts {OUTPUT_FILENAME } );
668
674
}
669
675
}
676
+ return EXIT_OK;
670
677
} # Main()
671
678
672
- Main( @ARGV );
679
+ exit Main( @ARGV );
673
680
674
681
__END__
675
682
# ### Documentation #######################################################
@@ -684,7 +691,7 @@ =head1 NAME
684
691
685
692
=head1 USAGE
686
693
687
- perl perlpp.pl [options] [filename]
694
+ perl perlpp.pl [options] [--] [ filename]
688
695
689
696
If no [filename] is given, input will be read from stdin.
690
697
@@ -767,6 +774,10 @@ =head1 OPTIONS
767
774
768
775
=back
769
776
777
+ =item --version
778
+
779
+ Show the version number of perlpp
780
+
770
781
=head1 DEFINITIONS
771
782
772
783
B<-D > and B<-s > items may be evaluated in any order ---
0 commit comments