Scrape PHP Globals 0.1

I needed to extract all the explicitly declared global variables in a PHP script so I wrote a Perl script to do it for me. It then occured to me that maybe other people might find it useful, so I tidied it up a bit and released it on my site as Scrape PHP Globals.

It extracts all variable names occurring between “global” and a semicolon, then prints them out nicely as a new global statement.

2 Responses to “Scrape PHP Globals 0.1”

  1. John Bokma Says:

    FWIW:

    $numArgs = $#ARGV + 1;
    die($usage) if($numArgs 1) ? $ARGV[1] : 79;

    can be rewritten as:

    my $filename = shift; # get first argument
    ( $filename eq ‘–help’ or $filename eq ‘-h’ ) and die $usage;
    my $cols = shift; # get second argument
    defined $cols or $cols = 79;

    HTH,
    John Bokma

  2. John Bokma Says:

    Somehow WordPress ate up the Perl code I posted :-(

Leave a Reply

You must be logged in to post a comment.