Hello,

2 questions on below example from Perl cookbook,

1)Never seen while being used inside of qutation while being assign to $code(on line 11) In this case, what is $code in line 17?

2)do not understand this line s{\\Q$in\\E}{$out}g at line 17
I looked up \Q and see that it means Quote metacharacters till \E
What does "quoting metacharacters" mean? I understand what metacharacter is(special character such as $ or ^) but just what is quoting metachracter mean??

\Q -- Quote (de-meta) metacharacters till \E.
1 #!/usr/bin/perl -w 2 # fixstyle - switch first set of <DATA> strings to second set 3 # usage: $0 [-v] [files ...] 4 use strict; 5 my $verbose = (@ARGV && $ARGV[0] eq '-v' && shift); 6 if (@ARGV) { 7 $^I = ".orig"; # preserve old files 8 } else { 9 die warn "$0: Reading from stdin\n" if -t STDIN; 10 } 11 my $code = "while (<>) {\n"; 12 # read in config, build up code to eval 13 while (<DATA>) { 14 chomp; 15 my ($in, $out) = split /\s*=>\s*/; 16 next unless $in && $out; 17 $code .= "s{\\Q$in\\E}{$out}g"; 18 $code .= "&& printf STDERR qq($in => $out at \$ARGV line \$. +\\n)" 19 if $verb +ose; 20 $code .= ";\n"; 21 } 22 $code .= "print;\n}\n"; 23 eval "{ $code } 1" || die; 24 __END__ 25 analysed => analyzed 26 built-in => builtin 27 chastized => chastised 28 commandline => command-line 29 de-allocate => deallocate 30 dropin => drop-in 31 hardcode => hard-code 32 meta-data => metadata 33 multicharacter => multi-character 34 multiway => multi-way 35 non-empty => nonempty 36 non-profit => nonprofit 37 non-trappable => nontrappable 38 pre-define => predefine 39 preextend => pre-extend 40 re-compiling => recompiling 41 reenter => re-enter 42 turnkey => turn-key

In reply to script fixstyle from cookbook by convenientstore

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.