On Mar 21, 2013, at 15:20, Grant Grueninger <[email protected]> wrote:
> my $input = '';
> while (<>) {
> $input .= $_;
> }
______________________________________________________________________
Hey Grant,
If you're going to slurp the input into a variable, you might as well do it the
easy way:
-------------------------------------------------------------------------------------------
#! /usr/bin/env perl -0777 -nw
use strict;
s%\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))%<a
href="$1">$1</a>%g;
s%((?:[\w\-\.]+)@(?:(\[([0-9]{1,3}\.){3}[0-9]{1,3}\])|(([\w\-]+\.)+)([a-zA-Z]{2,4})))%<a
href="mailto:$1">$1</a>%g;
s%href\s*=\s*"(?![[:alnum:]/]*?:)%href="http://%g;
print;
-------------------------------------------------------------------------------------------
If you're going to process line-by-line, you might as well do it the easy way:
-------------------------------------------------------------------------------------------
#! /usr/bin/env perl -w
use strict;
while (<>) {
s%\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))%<a
href="$1">$1</a>%g;
s%((?:[\w\-\.]+)@(?:(\[([0-9]{1,3}\.){3}[0-9]{1,3}\])|(([\w\-]+\.)+)([a-zA-Z]{2,4})))%<a
href="mailto:$1">$1</a>%g;
s%href\s*=\s*"(?![[:alnum:]/]*?:)%href="http://%g;
print;
}
-------------------------------------------------------------------------------------------
In both cases the default variable ($_) is implied.
It's also nice to have consistent pattern delimiters if possible.
--
Best Regards,
Chris
--
--
You received this message because you are subscribed to the
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem,
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.