On Thu, Feb 07, 2002 at 09:56:37AM +0000, Simon wrote:
Now my problem is, for some reason, in my virtual user table, there are space and tab's, how do I get the split to recognise the tab as well as the space char?
my @fields = split(" ", $_); # Break it down, this is the original and sees the space ok...
my @fields = split(" ", $_) || split("<ascii for tab?", $_); # Break it down, is this anywhere close ?
try just
my @fields = split;
which is equivalent to:
my @fields = split /\s+/, $_;
which will split $_ on one or more white space characters.
you could also write:
while(<VUT>) { my($alias, $user) = split; next unless $user eq $username; print "Alias for $username is $alias\n"; }
which saves you having to define @fields. The chomp is unnecessary here, as the split will remove the line feed from the end.