BudFloyd (7) [Avatar] Offline
#1
I'm using OSX Tiger bash shell. I keep getting the following error message without a result when I try using the fgrep example 3.5.
"Use of uninitialized value in concatenation (.) or string at -e line 1, <> line 1."
Any suggestions as to why?
tmaher (37) [Avatar] Offline
#2
Re: keep getting errors with fgrep example pg64
Sorry, there's a mistake that got past all the reviewers--the dollar sign in $9.99
needs a backslash before it in the Perl command, because variable substitution occurs before the
Q ... E metacharacters get interpreted. I'll update the Errata sheet accordingly.

-Tim
BudFloyd (7) [Avatar] Offline
#3
Re: keep getting errors with fgrep example pg64
I tried that before I posted my query. I don't get an error, but I don't get a result either. If fgrep I get the match, but not in using your script.
tmaher (37) [Avatar] Offline
#4
Re: keep getting errors with fgrep example pg64
Sorry Bud, the problem turns out to be a bit more complicated than I initially thought.

The backslash that protects the dollar sign from being recognized as a request
for interpolation of variable #9 mustn't occur within the Q ... E sequence,
because that causes it to get backslashed itself, requiring the existence of a
corresponding backslash in the input string.

The program can be corrected by temporarily interrupting the Q-quoted string as follows:

perl -wnl -e '/Q**E $Q9.99 Sale! **E/ and print;' sale

FYI, you can see where Q adds backslashes by adding this option
cluster before -wnl: -MO=Deparse

I'm sure that an earlier version of the examples on page 64 was confirmed as
working correctly, but somewhere along the way somebody (me?) thought it would
be cool to put in a dollar amount, and somehow failed to adequately re-test all the
commands. 8-{ (Believe me, I've tried really hard to thoroughly test and re-test
everything, but inevitably a few cases have slipped by.)

My apologies for any confusion. I'll update the Errata sheet accordingly.