in reply to Re: Referencing a Backreference
in thread Referencing a Backreference

Wouldn't something like this be a lot simpler?

So true, but it can be done even simpler!

my (@ips, @names); while (<DATA>) { my ($ip, $name) = split; push @ips, $ip; push @names, $name; }
split with no arguments is like split ' ', $_, which in turn has a special meaning because of the chr(32) string. I think you can asume ip adresses and hostnames do not contain whitespace...

If order and duplicates are not very important, a hash would be really nice:
my %hash = map split, <DATA>; my @ips = keys %hash; my @names = values %hash;

U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk

Replies are listed 'Best First'.
Two splits for the price of one!
by belg4mit (Prior) on Mar 14, 2002 at 20:26 UTC
    Not such a big deal here unless it's a huge log being parsed, but probably generally not the best generic scheme.

    --
    perl -pe "s/\b;([st])/'\1/mg"