in reply to Re: Problem in extracting alphanumeric string from file
in thread Problem in extracting alphanumeric string from file

Thank you so much ... I am Starter with perl.. Learnt today - The =~ operator does not work with arrays or hashes. Thanks Again.
  • Comment on Re^2: Problem in extracting alphanumeric string from file

Replies are listed 'Best First'.
Re^3: Problem in extracting alphanumeric string from file
by stevieb (Canon) on Aug 19, 2015 at 13:41 UTC

    It doesn't work on the hash or array container, but does work with their scalar elements:

    use warnings; use strict; my %hash = (one => 1, two => 2); for my $key (keys %hash){ print "$key\n" if $key =~ /one/; } my @array = qw(one two three); for my $elem (@array){ print "$elem\n" if $elem =~ /one/; }
Re^3: Problem in extracting alphanumeric string from file
by rahulme81 (Sexton) on Aug 19, 2015 at 09:09 UTC
    Sorry while testing I found one issue - if I increase the strings that gives me only first match. For tuesday this prints only TD20.2.7.8
    MONDAY MD21.2.7.8 TUESDAY # Driver Code = TD20.2.7.8 TD20.2.7.8 TD20.2.7.7 TD20.2.7.9 WEDNESDAY # Driver Code = WD20.2.7.8 WD30.2.7.8 WD30.2.7.9 FRIDAY # Driver Code = FD20.2.7.8 FD40.2.7.8
      Achieved - condition changed to next if ! /^(\w*){4}(\.\d*){3}/;