okamoto@hpcc01.HP.COM (Jeff Okamoto) (02/07/91)
I'm working right now on ways to let my perl scripts take advantage of the features in the latest patchlevels, yet still run correctly on older versions. This subroutine will correctly handle the .h versus .ph suffixes, and the change of the error message in do from $! to $@. If you have __LINE__, this fragment will print out the correct line number. If you don't have it, you'll have to enter a line number yourself. I don't see a portable way around this.... Doubtless this can be improved. sub dorequire { local($include) = shift(@_); local($line) = shift(@_); print "Line is $line\n"; eval 'require "$include";'; if ($@ =~ /^syntax error/) { # Require is not present $include =~ s/.ph$/.h/; do "$include" || die "Can't do $include: $!"; } else { die "$@"; } } &dorequire("sys/hpuxname.ph", __LINE__); &dorequire("sys/hpuxname.ph", 666); exit 0; -- \ oo The New Number Who, \____|\mm Jeff Okamoto //_//\ \_\ HP Corporate Computing & Services /K-9/ \/_/ okamoto@ranma.corp.hp.com /___/_____\ ----------- (415) 857-6236