[27651] in Perl-Users-Digest
Perl-Users Digest, Issue: 9117 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 3 21:05:40 2006
Date: Mon, 3 Apr 2006 18:05:02 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 3 Apr 2006 Volume: 10 Number: 9117
Today's topics:
Re: Extract first part of a string <someone@example.com>
Re: Extract first part of a string <rvtol+news@isolution.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 03 Apr 2006 22:09:15 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Extract first part of a string
Message-Id: <f2hYf.24813$Ph4.9953@edtnps90>
Ian East wrote:
> This is a silly question that I'm sure is quite simple.
>
> What's the best way to extract the first bit of text from a string (up
> to the fist whitespace).
>
> For example,
>
> $string = "one two three";
> split(/ /, $string);
> print $_[0];
>
> This works but I'm sure but it seems kind of ugly and I'm sure there
> must be a better way.
print $string =~ /(\S+)/;
John
--
use Perl;
program
fulfillment
------------------------------
Date: Tue, 4 Apr 2006 02:51:16 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Extract first part of a string
Message-Id: <e0sn2u.1ck.1@news.isolution.nl>
A. Sinan Unur schreef:
> my $x = (split /\s/, $s)[0];
Close alternatives:
my $x = (split " ", $s, 2)[0];
my ($x) = split " ", $s, 2;
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 9117
***************************************