Just capture the match! You can get rid if the zero-width assertion at the same time:
my $file = '/etc/redhat-release'; # content of /etc/redhat-release # CentOS Linux release 7.6.1810 (Core) open(SOURCE, '<', $file); my ($version) = <SOURCE> =~ m/release (\d)/; close SOURCE; print "The version is: $version\n";
In reply to Re: Read text in file and assign to variable
by haj
in thread Read text in file and assign to variable
by maxamillionk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |