HELLPPPP....
OK, I've got an IP address in a variable $address, I know because
print qq($ipaddress); gives me the address
trying to split it into it's singular octets like so... (As usernames on the system are derived from the last 2 octets of the address)
@octets = split(/./, $ipaddress);
Now from what I understand the elements in the array @octets should be accessable by $octets[0] etc..
Or
while (@octets) { print qq(Octet = $_); }
But it doesn't... Or am I way off mark...
Please help....
TIA
Simon
On Mon, 2002-09-23 at 15:00, Simon wrote:Try using the
split(/./,$ipaddress);
rather than
split(/./,$ipaddress);
The . is a regular expression character for any character and you man need to escape it using the \ character.
HELLPPPP....
OK, I've got an IP address in a variable $address, I know because
print qq($ipaddress); gives me the address
trying to split it into it's singular octets like so... (As usernames on the system are derived from the last 2 octets of the address)
@octets = split(/./, $ipaddress);
Now from what I understand the elements in the array @octets should be accessable by $octets[0] etc..
Or
while (@octets) { print qq(Octet = $_); }
But it doesn't... Or am I way off mark...
Please help....
TIA
Simon
main@lists.alug.org.uk http://www.alug.org.uk/ http://lists.alug.org.uk/mailman/listinfo/main Unsubscribe? See message headers or the web site above!
Douglas is correct but you also might find it useful to use a foreach loop to get the octets displayed. I'm not 100% sure that while loop will work.
Something like:
foreach my $octet (@octets) { print qq(Octet = $octet\n); }
instead of
while (@octets) { print qq(Octet = $_); }
Cheers,
Mat
Thanks for your help guys, working now...
On Monday 23 September 2002 5:13 pm, Mat B wrote:
Douglas is correct but you also might find it useful to use a foreach loop to get the octets displayed. I'm not 100% sure that while loop will work.
Something like:
foreach my $octet (@octets) { print qq(Octet = $octet\n); }
instead of
while (@octets) { print qq(Octet = $_); }
Cheers,
Mat