Hello,
I have a very unfunny problem, on which i am working for hours.

I need to find out if a string contains an other specified string.
I want to use pattern-matching.
I canīt get a match together which make this. Look at my examples,
none of the Matchings using vars works. If I replaces the vars to normal
strings it works like it should.
I am using perl 5.6 on a aix 4.3.3.

Thanks for help!
############################################ cut
#################################################
#!/usr/bin/perl -w

my $hund= "hund m-a-u-s katze k.a.t.z.e. maus xyz 1234";
my $dings1 = "hund";
my $dings2 = "m-a-u-s";
my $dings3 = "k.a.t.z.e.";
my $dings4 = "xyz";
my $dings5 = "123";

if ( $dings1 =~ /\Q$hund/) {
        print "$dings1 in \$hund";}

if ( $dings1 =~ /\Q${hund}/) {
        print "$dings1 in \$hund";}

if ( $dings3 =~ /${hund}/) {
        print "$dings3 in \$hund";}

if ( $dings3 =~ /\Q${hund}/) {
        print "$dings3 in \$hund";}

if ( $dings5 =~ /$hund/) {
        print "$dings5 in \$hund";}

if ( $dings1 =~ /\Q$hund/) {
        print "$dings1 in \$hund";}

if ( $dings1 =~ /.*\Q${hund}\E.*/) {
        print "$dings1 in \$hund";}

if ( $dings3 =~ /\${hund}/) {
        print "$dings3 in \$hund";}

if ( $dings3 =~ /.*\Q${hund}/) {
        print "$dings3 in \$hund";}

if ( $dings5 =~ /.*$hund.*/) {
        print "$dings5 in \$hund";}

if ( $dings4 =~ /.*$hund.*/) {
        print "$dings5 in \$hund";}
###################################### EOF
#############################################


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to