in reply to string splitting
my $example = "stupid\texample\tfor\tyou\n"; my ($first,$rest) = split /\t/, $example, 2; # sets $first == "stupid" # and $rest == "example\tfor\tyou\n"
The third argument to split is the maximum number of parts to break the string into. If you don't want the "rest" part at all you can take that variable out of the parens but you need the parens around even a single variable so that you get the first item in the list it returns, rather than the list count. =)
If you don't want the other data and don't want to make a second variable you might do it with a regexp like this:
my $example = "stupid\texample\tfor\tyou\n"; $example =~ s/\t.*$//;
--
$you = new YOU;
honk() if $you->love(perl)
|
|---|