diff --git a/lic.pl b/lic.pl index b2cde88..b4fc094 100755 --- a/lic.pl +++ b/lic.pl @@ -34,7 +34,8 @@ sub version { } my $license; -my $head = 0; +my $opt_head = 0; +my $opt_vars = 0; my @substs = (); my $file; @@ -48,7 +49,10 @@ for my $arg (@ARGV) { exit; } elsif ($arg eq "-H" || $arg eq "--head") { - $head = 1; + $opt_head = 1; + } + elsif ($arg eq "-v" || $arg eq "--vars") { + $opt_vars = 1; } elsif (!defined $license) { $license = $arg; @@ -64,7 +68,7 @@ unless (defined $license) { } # license headers use .head extension -if ($head == 1) { +if ($opt_head == 1) { $license .= ".head"; } @@ -103,6 +107,13 @@ while (<$input>) { chomp; my $line = $_; + if ($opt_vars == 1) { + for my $key ($line =~ /\{\{\s*([^}]+)\s*\}\}/g) { + print $key, "\n"; + } + next; + } + foreach my $subst (@substs) { my ($key, $val) = @$subst; $line =~ s/\{\{\s*\Q$key\E\s*\}\}/$val/g;