@@ -434,13 +434,20 @@ sub Main {
434
434
StartOB();
435
435
print " package PPP_${Package} ;\n use strict;\n use warnings;\n " ;
436
436
437
- # TODO transfer parameters from the command line to the processed file.
438
- # Per commit 7bbe05c, %DEF is for those parameters.
439
- print " my %DEF = ();\n " ;
437
+ # Transfer parameters from the command line (-s) to the processed file.
438
+ # The parameters are in %S, by analogy with -s.
439
+ print " my %S = (\n " ;
440
+ for my $defname (keys %{$opts {DEFS }}) {
441
+ print " $defname => " , ${$opts {DEFS }}{$defname }, " ,\n " ;
442
+ }
443
+ print " );\n " ;
440
444
445
+ # Initial code from the command line, if any
441
446
print $opts {EVAL }, " \n " if $opts {EVAL };
442
447
448
+ # The input file
443
449
ProcessFile( $opts {INPUT_FILENAME } );
450
+
444
451
my $script = EndOB(); # The generated Perl script
445
452
446
453
if ( $opts {DEBUG } ) {
@@ -479,6 +486,24 @@ =head1 OPTIONS
479
486
480
487
Output to B<filename > instead of STDOUT.
481
488
489
+ =item -s, --set B<name > =B<value >
490
+
491
+ In the generated script, set C<< $S{B<name > } >> to B<value > .
492
+ The hash C<%S > always exists, but is empty if no B<-s > options are
493
+ given on the command line.
494
+
495
+ Note: If your shell strips quotes, you may need to escape them. B<value > must
496
+ be a valid Perl expression. So, under bash, this works:
497
+
498
+ perlpp -s name=\"Hello, world!\"
499
+
500
+ The backslashes (C<\" > instead of C<" > ) are required to prevent bash
501
+ from removing the double-quotes. Alternatively, this works:
502
+
503
+ perlpp -s 'name="Hello, World"'
504
+
505
+ with the whole argument to B<-s > in single quotes.
506
+
482
507
=item -e, --eval B<statement >
483
508
484
509
Evaluate the B<statement > before any other Perl code in the generated
@@ -492,6 +517,14 @@ =head1 OPTIONS
492
517
493
518
Usage help.
494
519
520
+ =item --man
521
+
522
+ Full documentation
523
+
524
+ =item -?, --usage
525
+
526
+ Shows just the usage summary
527
+
495
528
=back
496
529
497
530
=head1 COPYRIGHT
0 commit comments