On Wed, Nov 14, 2001 at 11:17:57PM -0500, Uri Guttman wrote:
> perl -ne 
>'/^#!.*perl/i..1&&(/^\\s*[^#]|^\\s*#\\s*(include|define|(ifn?|un)def|else|elif|endif)/)&&print'

Doesn't print anything.

Attached are the two files I'm running it against.  The first is for
#1, the second for #2.


-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl6 Quality Assurance     <[EMAIL PROTECTED]>       Kwalitee Is Job One
the chair. it wants to die. oh no! she sees me! she attacks!
#!./perl -l

# There's a bug in -P where the #! line is ignored.  If this test
# suddenly starts printing blank lines that bug has been fixed.

print "1..3\n";

#define MESS "ok 1\n"
print MESS;

#ifdef MESS
        print "ok 2\n";
#else
        print "not ok 2\n";
#endif

open(TRY,">Comp.cpp.tmp") || die "Can't open temp perl file.";

($prog = <<'END') =~ s/X//g;
X$ok = "not ok 3\n";
X#include "Comp.cpp.inc"
X#ifdef OK
X$ok = OK;
X#endif
Xprint $ok;
END
print TRY $prog;
close TRY;

open(TRY,">Comp.cpp.inc") || (die "Can't open temp include file.");
print TRY '#define OK "ok 3\n"' . "\n";
close TRY;

print `$^X "-P" Comp.cpp.tmp`;
unlink "Comp.cpp.tmp", "Comp.cpp.inc";
Some stuff that's not Perl

This CPP directive should not be read.
#define BARMAR 1

#perl

Still not perl.

#!

still not perl

#!/something/else

still not perl

#!/some/path/that/leads/to/perl -l

# The -l switch should be applied from the #! line.
# Unfortunately, -P has a bug whereby the #! line is ignored.
# If this test suddenly starts printing blank lines that bug is fixed.

#define FOO "ok 1\n"

#ifdef BARMAR
#   define YAR "not ok 2\n"
#else
#   define YAR "ok 2\n"
#endif

print "1..2\n";
print FOO;
print YAR;

Reply via email to