Gourab Sengupta Gourab Sengupta - 1 year ago 71
Perl Question

identifying the forward slash

Suppose I have 3 variables.

my $val1 = './f1/abc.txt'; #f1 is the folder where abc.txt resides.

my $val2 = './f1/def.txt';

my $val3 = 'gh.txt';

I am facing an issue while reading the './f1/' part.

if ($val1 =~ m/^a.*\.txt$/ or $val2 =~ m/^d.*\.txt$/) { print $val3; }

this doesn't work with the folder name. Please help.

Answer Source

You can find the forward slashes in "./f1/" with this escape sequence:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download