On Wed, 23 Oct 2002 22:00, Sam Ruby wrote:
> >> Index: nag.pl
> >> ===================================================================
> >> RCS file: /home/cvs/jakarta-alexandria/proposal/gump/nag.pl,v
> >> retrieving revision 1.7
> >> retrieving revision 1.8
> >> diff -u -r1.7 -r1.8
> >> --- nag.pl 11 Feb 2002 16:27:45 -0000 1.7
> >> +++ nag.pl 21 Oct 2002 07:54:42 -0000 1.8
> >> @@ -41,6 +41,7 @@
> >>
> >> # extract just the stuff from inside the XMP tag
> >> if (m! .* <XMP> \s* (.*) \s* </XMP> !xs) {
> >> + $1 || m!(<p>.*</p>)!s; # if nothing found, look for prereqs
> >> $pageData = $1;
> >> } else {
> >> $pageData = "";
> >
> > It seems like the above does not quite work as expected. I have no perl
> > knowledge but I would hazard to guess that if the first pattern does not
> > match anything it will will go to the else section. So maybe the else
> > should look like
> >
> > $pageData = m!(<p>.*</p>)!s;
> >
> > Of course I have no idea what m! or !s means so could be completely wrong
> > ;)
>
> Can you point me to a case where it does not work?
http://nagoya.apache.org/eyebrowse/ReadMsg?listName=avalon-phoenix-dev@;jakarta.apache.org&msgNo=1472
Is the result produce from your last run. So you probably can grab the source
from your box.
> I tested it on a a
> source file which failed due to a prereq, and it appeared to work for me.
>
> Quick overview of what this is (supposed) to be doing:
>
> Normally, one does matches in perl with a /regular-expression/ syntax.
> When the regular expressions contain slashes, they either must be
> escaped, or a different delimiter must be chosen. I chose the latter
> route, and used esclamation points. 's' is an option which indicates
> that the string is to be treated as a single line (in other words,
> matches can span lines).
Ahh that kinda makes sense now ;)
> Doing a match returns a true or a false. If the match string contains
> parenthesis, then a useful side effect occurs in that $1, $2, etc are
> set to the matched substring.
>
> The else clause is for the case where there is no XMP tags. The then
> clause is taken when there is such a tag (even if it is empty).
>
> || is an operator which means "or". If the first operand is true, the
>
> second operand is not evaluated.
Okays. Given that I had a play with the code. Perl v5.6.1 - it seems that the
first regex will "consume" the input (defaults to $_ ???). When the second
regex actions there is zero input to work with. SO if instead of assigning
the file to $_ you also cahce it in a var and then reassign that var to $_
prior to next match that should fix it right? ie If the following was applied
would it work ...
ndex: nag.pl
===================================================================
RCS file: /home/cvs/jakarta-alexandria/proposal/gump/nag.pl,v
retrieving revision 1.8
diff -u -r1.8 nag.pl
--- nag.pl 21 Oct 2002 07:54:42 -0000 1.8
+++ nag.pl 23 Oct 2002 12:47:40 -0000
@@ -37,15 +37,22 @@
# read the entire file
open (FILE, "$home/$project.html");
$_ = join('',<FILE>);
+ $file = $_;
close (FILE);
# extract just the stuff from inside the XMP tag
if (m! .* <XMP> \s* (.*) \s* </XMP> !xs) {
- $1 || m!(<p>.*</p>)!s; # if nothing found, look for prereqs
- $pageData = $1;
+ if( !$1 ) {
+ $_ = $file;
+ m!(<p>.*</p>)!s; # if nothing found, look for prereqs
+ $pageData = $1;
+ } else {
+ $pageData = $1;
+ }
} else {
$pageData = "";
}
--
Cheers,
Peter Donald
------------------------------------------------
| We shall not cease from exploration, and the |
| end of all our exploring will be to arrive |
| where we started and know the place for the |
| first time -- T.S. Eliot |
------------------------------------------------
--
To unsubscribe, e-mail: <mailto:alexandria-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:alexandria-dev-help@;jakarta.apache.org>