Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

A couple minor comments. First, your loop through the file - if you found what you want, you probably should break out. Second, rather than foreach, you probably want while - no point in reading in a huge file and then looping through it.

Then I have to wonder why you're looking through the file at all. You only need to check the first line. And you probably should make the same check that perl does - that it starts with "#!" and has "perl" somewhere in the line:

open( my $input, "<", $file ) or return; # can't read, can't test. P +erhaps mark as a failure? my $line = <$input>; return unless $line =~ /^#!\s*(.*perl\S*)/; my $desired_interpreter = $1 close( $input );

Now I've captured the perl that this file wants to use, so we can use it in the system command.

If you want to support pathological cases where there is leading cruft, you'll need to scan the rest of the file looking for the #!.*perl line, and then use the -x option to the perl interpreter - but I don't think that doing this in an automated manner is wise. So I suggest just looking at the first line, and discarding the rest.

In reply to Re: Perl test - Make sure all perl files will compile by Tanktalus
in thread Perl test - Make sure all perl files will compile by skx

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2021-11-27 12:34 GMT
Find Nodes?
    Voting Booth?

    No recent polls found