in reply to $0 in perl pod, not expanding to script name

Hello spatterson,

Can you provide us a small sample of script that replicates the case that you are mentioning?

#!/usr/bin/perl use strict; use warnings; =pod =head1 DESCRIPTION This script can have 2 parameters. The name or address of a machine and a command. It will execute the command on the given machine and print the output to the screen. =cut print "Here comes the name of the script ... $0\n"; __END__ $ perl test.pl Here comes the name of the script ... test.pl

Looking forward to your update.

Seeking for Perl wisdom...on the process of learning...not there...yet!

Replies are listed 'Best First'.
Re^2: $0 in perl pod, not expanding to script name
by spatterson (Pilgrim) on Jul 16, 2018 at 08:08 UTC
    Stripped down to the minimum, my code is this: I simply want the first $0 (inside perlpod) to output the script name
    =pod Usage: C<$0> =cut $arg = shift(); if (defined($arg) && $arg eq '-h') { print `pod2text $0`; }

      In that case, just post-process it:

      =pod Usage: C<$0> =cut $arg = shift(); if (defined($arg) && $arg eq '-h') { for (`pod2text $0`) { s/\$0/$0/; print; } }