From the below code I want to store the regular expression result variable contents (i.e $fh result into new file name ). How can I do it?
Is there any possible way to do get regex variable output (i.e $fh output) written in new file?
Here is my code :
use strict;
use warnings;
open my $fh,'<',"open.txt" or die "$!";
while(<$fh>)
{
$fh=s/("\d+|\d+|")\s*/$1/g;
print $fh;
}
close $fh;
Error:
readline() on unopened filehandle 1 at fr.pl line 7.
close() on unopened filehandle 1 at fr.pl line 9.
Open.txt
1
2
3
radio
vendor
version114
version115
Output:
Note: $fh has regular expression values.Now those $fh values should be stored in new file and print the same contents as like below.
radio
vendor
version
version
"\d+or\d+or"(one double quote). Then there is optional whitespace, and you replace all of that with the capture. Do you want$wordto be the altered line, or the thing inside the capture group?