@@ -434,13 +434,20 @@ sub Main {
434434 StartOB();
435435 print " package PPP_${Package} ;\n use strict;\n use warnings;\n " ;
436436
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 " ;
440444
445+ # Initial code from the command line, if any
441446 print $opts {EVAL }, " \n " if $opts {EVAL };
442447
448+ # The input file
443449 ProcessFile( $opts {INPUT_FILENAME } );
450+
444451 my $script = EndOB(); # The generated Perl script
445452
446453 if ( $opts {DEBUG } ) {
@@ -479,6 +486,24 @@ =head1 OPTIONS
479486
480487Output to B<filename > instead of STDOUT.
481488
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+
482507=item -e, --eval B<statement >
483508
484509Evaluate the B<statement > before any other Perl code in the generated
@@ -492,6 +517,14 @@ =head1 OPTIONS
492517
493518Usage help.
494519
520+ =item --man
521+
522+ Full documentation
523+
524+ =item -?, --usage
525+
526+ Shows just the usage summary
527+
495528=back
496529
497530=head1 COPYRIGHT
0 commit comments