maxamillionk has asked for the wisdom of the Perl Monks concerning the following question:
How can I assign the string to the $version variable without using the '$&' ?my $file = '/etc/redhat-release'; # content of /etc/redhat-release # CentOS Linux release 7.6.1810 (Core) open(SOURCE, '<', $file); <SOURCE> =~ m/(?<=release )\d/; close SOURCE; my $version = $&; print "The version is: $version\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Read text in file and assign to variable
by haj (Vicar) on Jan 22, 2024 at 13:12 UTC | |
by maxamillionk (Acolyte) on Jan 24, 2024 at 00:31 UTC | |
by Athanasius (Archbishop) on Jan 24, 2024 at 07:58 UTC | |
by maxamillionk (Acolyte) on Jan 25, 2024 at 00:04 UTC | |
by kcott (Archbishop) on Jan 24, 2024 at 15:36 UTC | |
|
Re: Read text in file and assign to variable
by kcott (Archbishop) on Jan 22, 2024 at 14:04 UTC |