pattern matching with string variable? 
Author Message
 pattern matching with string variable?

# Hello,
#
#   question: if  $string  is a string variable for  pattern matching  
#                i.e. $string = "/x/ && /y/"
#             How I use $string for test pattern matching?
#                i.e. if ($_ =~ $string) {....} ????
#
# Small example:
# =============
# Input line
  $_ = "cat dog bird";

# Suppose a logical structure for construct a pattern matching
# here example: /dog/ && /bird/


  $pat1 =~ s/\/\//\/ && \//;                         # substitute // by / && /
  print "pattern 1: ",$pat1,"\n";

# other pattern


  $pat2 =~ s/\/\//\/ && \//;                         # substitute // by / && /
  print "pattern 2: ",$pat2,"\n";

# test for pattern matching
# here, I don't understand: How I use "$pat1" and "$pat2"?

  if ($pat1) {print $_,"\n";}  # ????

  if ($pat2) {print $_,"\n";}  # ????

# Thank you
#
# Gilles Ratel



Thu, 12 Oct 1995 19:58:21 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. pattern matching with a string variable?

2. Pattern Match - substitute a string after the match

3. pattern matching with non-existence of a string

4. Variable inside pattern matching

5. Help on pattern matching, string size

6. RE match for negative variable pattern

7. Matching variable patterns

8. variable interpolation and pattern matching

9. variable interpolation within a pattern match

10. Perl not setting pattern match variables when in an eval

11. loops, conditional expressions, and pattern match variables

12. Pattern Matching & Saving Value of Original Variable

 

 
Powered by phpBB® Forum Software