[26165] in Perl-Users-Digest
Perl-Users Digest, Issue: 8354 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 24 21:05:24 2005
Date: Wed, 24 Aug 2005 18:05:03 -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 Wed, 24 Aug 2005 Volume: 10 Number: 8354
Today's topics:
Re: A simple question using SPLIT <djames@thehub.com.au>
Re: Can a Perl Programmer Pick up PHP quickly? <cwilbur@chromatico.net>
Re: TimeDate conversion to string. <nobull@mail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 24 Aug 2005 23:00:07 GMT
From: Damian James <djames@thehub.com.au>
Subject: Re: A simple question using SPLIT
Message-Id: <slrndgprtl.4g9.djames@puli.home>
On Sat, 20 Aug 2005 16:07:57 GMT, Aman said:
> ...
> 1 1 808748 1081461 0 0 0 1 3 0 744 1190 850 0 1 98 1
>
> I tried using the following
>
> ($r,$b,$avm)=split(/\s/,$line);
>
> to split the first 3 rows but it does not work. Any ideas on how to
> accomplish this ? Ideally I would like to split each col. into a
> variable. Any help will be appreciated. Thanks
That's because you're matching a single whitespace character. As others,
have pointed out,
($r,$b,$avm)=split(/\s+/,$line);
is probably what you meant. Note, however, that to match only the first 3 items,
you'd probably want:
($r,$b,$avm,$rest)=split(/\s+/,$line, 4);
I believe the confusion here is because this is the (often unspoken) default
for split, so if you had done:
$_ = '1 1 808748 1081461 0 0 0 1 3 0 744 1190 850 0 1 98 1';
($r,$b,$avm)=split;
That would give the same result, but without the limit as above.
--Damian.
------------------------------
Date: Wed, 24 Aug 2005 17:08:07 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: Can a Perl Programmer Pick up PHP quickly?
Message-Id: <m2ll2r11s8.fsf@ubiquity.chromatico.net>
>>>>> "M" == Mike <mike@nospam.com> writes:
M> I have a lot of experience with Perl and a good paying job has
M> come up that requires someone to update and maintain a website
M> written in PHP.
M> Can a Perl programmer pick up PHP easily? Are there
M> similarities?
I worked in PHP for a contract job. I found the job interesting, but
PHP frustrating, because of the similarities. A lot of features in
PHP seem to have been implemented because it was a neat feature in
Perl or C++, but without any real thought as to why the feature works
as it does in Perl or C++. This also contributes a great deal to the
proliferation of builtins.
As an example: hashes and arrays are the same thing in PHP, and
there's no concept of a code block. (Callbacks require defined
functions, and don't work cleanly if you mix them with OO.) So one
function in Perl, sort, handles everything. In PHP, the array-hash
equivalence that seemed like such a nice idea and the fact that you
can't simply pass in a code block to determine how to sort things mean
that there's an enormous proliferation of functions that sort.
It's also a lot more difficult to fix the problem; in Objective-C I
was annoyed by the lack of foreach/map/grep, and so I wrote something
to hook into the runtime and fix it. In PHP I was annoyed by the lack
of AUTOLOAD, and the only thing I could do was upgrade to the latest
version, which was untenable without heavy testing.
But a good programmer should have no problem picking up PHP.
Charlton
--
cwilbur at chromatico dot net
cwilbur at mac dot com
------------------------------
Date: Wed, 24 Aug 2005 20:12:47 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: TimeDate conversion to string.
Message-Id: <deigrg$m41$1@redhat2.bham.ac.uk>
Toni Erdmann wrote:
> Tony wrote:
>
>> I'm trying to use the output of the the date/time from localtime into
>> a label.:
>>
>> ($sec,$min,$hour,$mday,$mon,$year,$wday,
>> $yday,$isdst)=localtime(time);
>> $year = ($year + 1900) - 2000;
>> $labelname = printf "REL_" . $proj[0] . "_%02d%02d%02d_%02d%02d%02d",
>
> ^^^^^^
> Do you mean "sprintf".
>
>> $hour,$min,$sec,$mon+1,$mday,$year;
>> print "$labelname\\n";
Also you should avoid putting data into the format string of sprintf()
just in case there's a '%' in there ever.
Put a '%s' in the format and then put $proj[0] as a separate item in
sprintf()'s argument list.
It may be that now you know $proj[0] does not contain '%' but getting
into the bad habit will get you burned eventually.
------------------------------
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 8354
***************************************