in reply to Re^2: Problem using value of variable in a regular expression
in thread Problem using value of variable in a regular expression

See perldoc perldata
  • Comment on Re^3: Problem using value of variable in a regular expression

Replies are listed 'Best First'.
Re^4: Problem using value of variable in a regular expression
by Anonymous Monk on Jul 30, 2010 at 10:45 UTC
    Thanks for the reply. I wasn't aware of the interpolation in perl. The problem with searching a solution for such a query is that one has to know the name of the concept behind the issue(here it is "interpolation") to get quickly to the answer. But then if one knew the concept, he/she wouldn't be facing the problem in the first place.
      Well, interpolation of control chars is a major feature of many programming languages, not just perl. Surely you've seen something like printf("Hello, World!\n"); before?

      I agree though, finding your way around perl's extensive documentation can be a scary thought. I suggest you look at perlintro if you haven't already, and from there take some time each day to at least skim over the other perl tutorials. http://perldoc.perl.org/ is a very convenient way of reading the docs and the tutorials are listed here.

      Good luck

      The problem with searching a solution for such a query is that one has to know the name of the concept behind the issue(here it is "interpolation") to get quickly to the answer. But then if one knew the concept, he/she wouldn't be facing the problem in the first place.

      Yes, that's indeed a problem. That's why places like perlmonks, usenet and various IRC channels exist.

      One appraoch that I'm eager to try out for Perl 6 is to write a tool that, given some piece of code, points you to the applicable documentation, and also tells you which possible usage of a character it is (for example the slash can be numeric division, or it can be the start of a regex).

      In an ideal world, given the string

      my $x = "\*E"

      It would tell you that 'my' is a declarator (and point you to the docs), = is assignment (+ pointer to docs), "..." is a quote (+ pointer to docs", and \ introduces an escape sequence (+ pointer to docs).

      For Perl 6 I know how to obtain the parse tree, but the docs are too sparse to make it useful right now. For Perl 5 it's hard to get the parse tree.

      But it's on my list of long-term projects to hack on (and some of these projects done from time to time).

      Perl 6 - links to (nearly) everything that is Perl 6.

        I like your idea. That could be very useful. You could try it with something like PPI. That is what Perl::Critic uses.

        Update: Link fixed.

      There are a lot of concepts in any programming language that are not easily searchable. Think operator precedence, how to represent array or hash constants, what happens to the loop variable after the loop.

      For all of these concepts I'm always glad I have a perl book beside me. The index at the end of the book and especially the circumstance that all special characters are listed in it, helps tremendously.

      I don't see a reason why such an index could not be implemented into the perldoc system, but until someone makes the editorial effort a book index is the fastest way to find your way around a language you haven't been properly introduced to ;-)

        I don't see a reason why such an index could not be implemented into the perldoc system,
        It's not a matter of just whether something is possible. Even if it's possible (and I think it certainly is - no C or Perl internals knowledge required), someone actually has to step up to the plate and actually do it.