Q:

perl how to extract #define'd number from C header file

I am looking for a Perl snippet to print the number 100, contained in a C header, to the terminal.
#ifndef VERSIONS_H
#define VERSIONS_H

#define __SOFTWARE_REVISION__ 100

#endif

I am able to extract the #define line, but the number.
#!perl -w
use warnings;
use strict;
my $line;
my $file = shift @ARGV;
open my $fh, "<", $file or die $!;
while (<$fh>) {
        print if /__SOFTWARE_REVISION__/;
}
close ($fh);

A:

The regex matches for any line that contains that literal phrase, not only where it is defined.  You need to specify the line far more precisely, and to capture the needed number.  
The code also proceeds to loop through the file needlessly.
With a few more adjustments
use warnings;
use strict;
use feature qw(say);

my $file = shift @ARGV;
die "Usage: $0 filename\n" if not $file or not -f $file;

open my $fh, '<', $file or die "Can't open $file: $!";

while (<$fh>) {
    if (/^\s*#\s*define\s+__SOFTWARE_REVISION__\s+([0-9]+)/) {
        say "Software revision: $1";
        last;
    }
}
close $fh;

If the software revision can be other than integer replace [0-9]+ with \S+.
I'd suggest to work through the tutorial perlretut with reference perlre on hand.

I assume that this need comes up in a Perl program (and not that Perl is the chosen tool for this). 
Still, note that there are other, more systemic, ways to retrieve this information using the compiler (see a comment on gcc by rici for example).  
While it is better to use Perl in a Perl script rather than go out to the system, this case may be one of exceptions: it may be better to use an external command rather than parse source files, a task well known to be treacherous.

