in reply to Regular Expression

I cannot reproduce your problem here. On my machine I ran this code:

use strict; use warnings; my $line = 'Width = 32'; if($line =~ m/^Width[\s]*\=[\s]*(\d+)$/) # to match Width { print "Width found: $1\n" } elsif ($line =~ m/^Descr[\s]*-[\s]*[\w]+$/) # to match Descr { print 'Descr found' } else { printf "Garbage found: \"%s\" \n",$line; }

And it prints out Width found: 32

If it doesn't match for you, maybe $line contains some non-printable characters (maybe because the file is stored in UTF-16?)

To find out, you can use something like

use Data::Dumper; $Data::Dumper::Useqq = 1; print Dumper $line;