SPUG: Help with this error

Tim Maher tim at consultix-inc.com
Thu Oct 7 16:05:37 CDT 2004

On Thu, Oct 07, 2004 at 01:29:37PM -0700, Luis Medrano wrote:
> list,
> This how it works
> $temp is the line of the file I'm processing and when they
> fines the line what contains this "*.jpg". it brakes.
> $temp=$file[5221]; ## this contains *.jpg
> if ($linea=~m/$temp/){ ## and here is where it brakes.
> Luis

You need to "quote" the metacharacters that result from the
expansion of $temp, so they are interpreted as literals when
doing the match against $linea; \Q \E are for this:

if ($linea=~m/\Q$temp\E/){ ## and here is where it brakes.

But I don't understand what you're doing.  How could "*.jpg" ever
match a line number, which is what you say is in $linea?

| Tim Maher, CEO     (206) 781-UNIX      (866) DOC-PERL     (866) DOC-UNIX |
| tim(AT)Consultix-Inc.Com  http://TeachMePerl.Com  http://TeachMeUnix.Com |
| Watch for my upcoming book: "Minimal Perl for Shell Users & Programmers" |
| Classes! 10/4: UNIX Fundamentals  11/30: Perl  12/6: Shell & Utilities   |

More information about the spug-list mailing list