[comp.lang.perl] eval failures - in a commented line

ijk@cbnewsh.att.com (ihor.j.kinal) (06/22/91)

While trying to extend cgrep', I ran into an interesting problem.
The eval part of the program failed [silently].  Since I had made a number
of changes, I tried commenting them out, to no avail.  Finally, by deleting
lines, I determined the failure was within a commented line that
had a print format:
#	print \$ary[\$ind], "\n";
	
By deleting the "\n", then program then seemed to work as before.

Is this a bug, or what???
This is the latest PERL, on a HP 855.

Thanks,
Ihor Kinal
att!cbnewsh!ijk
[I'm just starting, so forgive me if this is dumb.
NOTE: what I'm trying to do is to stop the context display if there
are blank lines within the context:i.e, using blank lines as 
deliminators.  I've eliminated text in the beginning prior to a blank
line before the display line, and now want
to only display those elements of the ary up to the first blank line.]

df@sei.cmu.edu (Dan Farmer) (06/22/91)

In article <foo>, ijk@cbnewsh.att.com (ihor.j.kinal) writes:
[...]
> Is this a bug, or what???
> This is the latest PERL, on a HP 855.

  "the latest PERL"?  This is a dangerous thing to say, given
the frequency of larry's updates... :-)

 -- d

lwall@jpl-devvax.jpl.nasa.gov (Larry Wall) (06/25/91)

In article <1991Jun21.194148.24804@cbnewsh.att.com> ijk@cbnewsh.att.com (ihor.j.kinal) writes:
: While trying to extend cgrep', I ran into an interesting problem.
: The eval part of the program failed [silently].  Since I had made a number
: of changes, I tried commenting them out, to no avail.  Finally, by deleting
: lines, I determined the failure was within a commented line that
: had a print format:
: #	print \$ary[\$ind], "\n";
: 	
: By deleting the "\n", then program then seemed to work as before.
: 
: Is this a bug, or what???

It's what.

You're obviously evaluating this in a double-quote context, or you
wouldn't be backwhacking the dollar signs.  (It's also obvious that
you're not using double quotes to get the double-quote context, or you
WOULD be backwhacking the double quotes.)  Recall that double-quote
context also interpolates things like \n.  Recall also that comments
run to the next newline, and you'll see that the second double quote
above is on the next line after the comment, if the newline gets
interpolated too early, which it is.  It doesn't matter without the
comment, since Perl can have newlines embedded in a quote.  To fix it,
put \\n instead.

Larry