|The stupid question is the question not asked|
Re: win2unixby Ionitor (Scribe)
|on Jul 20, 2002 at 17:33 UTC||Need Help??|
Just a few comments on the code:
First, this appears to try to remove the first line if it isn't a perl shebang line. If you're trying to remove a blank line at the beginning, testing for whitespace would probably be easier and safer. However, if you really want to discard any 1st line that isn't a perl shebang, there's a couple problems with your regex. The pattern +? causes minimal matching of at least one character, where the character matched is immediately before the +?. In other words, here are a few things your regex will match:
In the last case, #!perl is the only thing captured by the parens in the regex. Note that your code will not match #!/usr/bin/perl.
What you probably want is:
This way, your code will match and capture #!perl (used often in Windows programs, esp. by Activestate), #!/usr/bin/perl, and #!/usr/bin/perl -w. Additionally, the new line that the period does not capture will be added back on, without a ^M.
Forgot to replace the other "+".