Hi, 
What is going on with the [] at the end of the regrex?
Thnx,
Dave G.


I so understand s///  however... I am little confused with following: 

#!/usr/bin/perl -w

$s = "long string of stuff";


($r = $s) =~ s/l\w+/[]gsx;

print $r;


__END__


File "untitled 15"; Line 6:  Substitution replacement not terminated.
-----

# Delete (most) C comments.
   $program =~ s {
   /\*     # Match the opening delimiter.
   .*?     # Match a minimal number of characters.
   \*/     # Match the closing delimiter.
} []gsx;

# This is a variation on the s///; operator, which replaces
# the thing between the first two slashes with the thing between
# the last two slashes. Perl lets you choose something other than
# a slash, if you want. This regex matches C comments, by looking
# for "/*" (the '*' is a wildcard, so you have to 'escape' it by
# putting a backslash in front of it) -- followed by as few characters
# as possible (.* means "anything, zero or more times, '?' means
# "do this only until the "next thing" comes up). The "next thing" in
# this regex is "*/" - the closing delimiter of C comments. Again, you
# have to escape the splat, so that Perl doesn't treat it specially.
#
# after the "[]", the 'g' means "match globally", that is, look
# for as many matches as you can.
# the 's' means treat the input as a single line. That is, don't
# stop looking for a match when you hit a newline.
# the 'x' means "let me have comments in my regex."

*====================================================*
*   Cora Connection Your West African Music Source   *  
*   http://www.coraconnection.com/                   *  
*   Resources, Recordings, Instruments & More!       *
*====================================================*

Reply via email to