>>>>> "AB" == Alex Brelsfoard <[EMAIL PROTECTED]> writes:

  AB>     I have a quick (hopefully) question on how to do a simple switch
  AB> statement.  Let me show you what I am trying to do:

what switch statement? s/// is substitute. perl has no switch operator
nor statement.

  AB> I would like to switch '[link http://www.domain.com/page.html]' to '<a
  AB> href="http://www.domain.com/page.html";>.
  AB> Here's what I was trying to do:
  AB> $message =~ s/\[link .*?\]/<a href=\"$1\">/gs;

you don't need /s unless . needs to match a newline. since the part
after link is a blank (you check for only a single blank and that is not
the best way) and a url, you won't need to have . match newlines.

the\ before " in the replacement side is not needed. " isn't the
delimiter so it doesn't need escaping.

  AB> But I don't think that $1 is being populated until the line is
  AB> entirely processed.  Can anyone think of a way to do this in one
  AB> line?  Or do I have to split this up into two lines?

question: what populates $1 (and friends)?

answer: grabbed parts of a regex.

question: do you see any grabbed parts?

answer: no, i don't.

solution: put () around the match part that you want in $1.

uri

-- 
Uri Guttman  ------  [EMAIL PROTECTED]  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to