On 3/2/06, Angus <[EMAIL PROTECTED]> wrote:
snip
> In my code below I tried to split the variable
> $dhcp{$hostname}->{ip} into 4 separate octets but that failed, I then tried
> to match the last 1 to 3 characters in $dhcp{$hostname}->{ip} but that also
> failed.   Can anyone tell me how I might do this?
snip

This one took me a moment.  The split would have worked but for the
fact that the period character has special meaning to a regex.  It
means "match any character".  The split line should look like:

my(@octets) = split /\./, $dhcp{$hostname}->{ip};

Never use variables named $var1, $var2, etc.  That is what arrays are for.

The reason the regex didn't work is that you never captured anything
(the parenthesis were in the wrong place):

my ($range) = $dhcp{$hostname}->{ip} =~ /(\d{1,3})$/;

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to