Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
i want to parse the "my-host-name" in a single scalar variable how do i do it i tried it this way but it didnt work$w = "host, my-host-name # My Host Name";
but the $x contained only "my". i know we can parse it like this($x) = $w =~ /^host,\s*(\w+)\s*/;
but the problem is the name "my-host-name" is not always the same way it can also be "myname" or "my_host-name" etc($x) = $w =~ /^host,\s*(\w+-\w+-\w+)\s*/;
Janitored by Arunbear - added code tags, as per Monastery guidelines
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: probelm with parsing regex
by borisz (Canon) on Nov 11, 2004 at 11:44 UTC | |
|
Re: problem with parsing regex
by Happy-the-monk (Canon) on Nov 11, 2004 at 11:44 UTC |