[26163] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 8353 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 24 14:05:27 2005

Date: Wed, 24 Aug 2005 11:05:06 -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: 8353

Today's topics:
        A simple question using SPLIT <aman.lalla@sympatico.ca>
    Re: A simple question using SPLIT <for-spammers-only@web.de>
    Re: A simple question using SPLIT <joe@inwap.com>
        Can a Perl Programmer pick up PHP quickly (Mike)
        Can a Perl Programmer Pick up PHP quickly? (Mike)
    Re: Can a Perl Programmer Pick up PHP quickly? <john@castleamber.com>
    Re: Can a Perl Programmer Pick up PHP quickly? <mothra@nowhereatall.com>
        IPC::Open3 issue <rallen@bobotheclown.org>
    Re: IPC::Open3 issue <joe@inwap.com>
    Re: IPC::Open3 issue <everythingelse@bobotheclown.org>
        IPC::Open3 <rallen@bobotheclown.org>
    Re: IPC::Open3 <joe@inwap.com>
        isnan(), fpclassify() <BZ@caradhras.net>
        mod_perl 1.29: send_fh(): result status? <gorbster@nogmailspam.com>
    Re: Perl <-> C language interaction <daniel@QMiC.de>
    Re: TimeDate conversion to string. <joe@inwap.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 20 Aug 2005 16:07:57 GMT
From: Aman <aman.lalla@sympatico.ca>
Subject: A simple question using SPLIT
Message-Id: <92889EAE-1194-11DA-9011-000D935B0FEC%aman.lalla@sympatico.ca>

Hello everyone,

I am new to perl and I am trying to split a line but can't seem to get 
it to work. Basically, the line is made up of multiple whitespaces.
An example of a line is as follows and I want to split it into 
variables.

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

Aman



------------------------------

Date: Wed, 24 Aug 2005 18:08:53 +0200
From: Toni Erdmann <for-spammers-only@web.de>
Subject: Re: A simple question using SPLIT
Message-Id: <dei62m$6tb$1@news.mch.sbs.de>

Aman wrote:

> Hello everyone,
> 
> I am new to perl and I am trying to split a line but can't seem to get 
> it to work. Basically, the line is made up of multiple whitespaces.
> An example of a line is as follows and I want to split it into 
> variables.
> 
> 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
> 
> Aman
> 

($r,$b,$avm) = split( /\s+/, $line );
                          ^

Toni



------------------------------

Date: Wed, 24 Aug 2005 09:27:55 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: A simple question using SPLIT
Message-Id: <JrSdnbddvvGHPZHeRVn-gQ@comcast.com>

Aman wrote:
> Hello everyone,
> 
> I am new to perl and I am trying to split a line but can't seem to get 
> it to work. Basically, the line is made up of multiple whitespaces.
> An example of a line is as follows and I want to split it into 
> variables.
> 
> 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.

You need to re-read the docs on split().

Take note of the section in `perldoc -f split` where it says:
   As a special case, specifying a PATTERN of space (' ') will...

		-Joe


------------------------------

Date: Wed, 24 Aug 2005 16:04:26 GMT
From: mike@nospam.com (Mike)
Subject: Can a Perl Programmer pick up PHP quickly
Message-Id: <430c9a69.299231522@news.webperception.com>




------------------------------

Date: Wed, 24 Aug 2005 16:07:39 GMT
From: mike@nospam.com (Mike)
Subject: Can a Perl Programmer Pick up PHP quickly?
Message-Id: <430c9a95.299275295@news.webperception.com>


I have a lot of experience with Perl and a good paying job has come up
that requires someone to update and maintain a website written in PHP.

Can a Perl programmer pick up PHP easily? Are there similarities?


Thanks


------------------------------

Date: 24 Aug 2005 16:35:29 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Can a Perl Programmer Pick up PHP quickly?
Message-Id: <Xns96BC75CA74487castleamber@130.133.1.4>

mike@nospam.com (Mike) wrote:

> I have a lot of experience with Perl and a good paying job has come up
> that requires someone to update and maintain a website written in PHP.
> 
> Can a Perl programmer pick up PHP easily?

Depends a lot on your programming skills. But even then, learning a new 
language takes time.

> Are there similarities?

Yes, but that is more of a huge disadvantage, since some things are almost 
the same, note the almost.

But again, it depends on how much "a lot of" is, and how deep you are into 
Perl. If you hate PHP from the start, en complain for hours about it, you 
have a lot of experience with Perl :-D.

If you, on the other hand, pick up PHP in a few days, I don't want to see 
any of your Perl coding (j/k).

IMO, the best way to learn a language is to pick up a good book, and read 
it at least twice front to back, before you turn on the computer.

IMNSHO the worst way to "learn" a language is firing up your editor and 
copy paste snippets one finds online, in the documentation, and books, 
until it works (sort of).

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


------------------------------

Date: Wed, 24 Aug 2005 10:05:11 -0700
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: Can a Perl Programmer Pick up PHP quickly?
Message-Id: <430caf25$1@usenet.ugs.com>

Mike wrote:
(snipped)
>
> Can a Perl programmer pick up PHP easily? Are there similarities?
>
This should help

http://www.cs.wcupa.edu/~rkline/perl2php/

Mothra 




------------------------------

Date: Wed, 24 Aug 2005 15:21:38 GMT
From: Rocky Allen <rallen@bobotheclown.org>
Subject: IPC::Open3 issue
Message-Id: <Pine.LNX.4.61.0508241128490.8008@grn-amd64-00.grntech.net>

Hey Y'all,

Get random weird error trying to load IPC::Open3.  Dont really know where 
else to turn, cant find it on google.  Anyone seen it before?


ERROR:
IPC::Open3 version 54 required--this is only version 1.0106 at 
/usr/lib/perl5/5.8.7/Exporter/Heavy.pm line 121

the required version number goes higher each time I execute the script.

CODE:
#!/usr/bin/perl

use strict;
use warnings;
use Sys::Hostname;
use IPC::Open3

my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = 
localtime(time);
my $actyear = $year + 1900;
my $actmon = $mon + 1;
if ($mon < 10) {$actmon = "0" ."$actmon";};
if ($min < 10) {$min = "0" ."$min";};
if ($sec < 10) {$sec = "0" ."$sec";};
if ($mday < 10) {$mday = "0" ."$mday";};
if ($hour < 10) {$hour = "0" ."$hour";};
my $error ;
my @errors;
my($wtr, $rdr, $err);
#  Variables.  This section will need to be modified for each Cooperative.

my $host = hostname;
my $backupdir = '/backup/scripts/files';
my $jobstart = localtime();
my $fileformat = "contents-" . "$actyear" . "-" . "$actmon" . "-" . 
"$mday" . "_" . "$hour" . ":" . "$min" .  ":" . "$sec";
my $largefiles = '/tmp/largefiles';
my $contentsfile = "/etc/backup/$fileformat";

system("cd $backupdir ; find . -follow -size +2000000k -print > 
$largefiles");
push @errors, "could not open Filehandle to get large files: $?\n" if 
defined($error);
print "I made it here\n";A


------------------------------

Date: Wed, 24 Aug 2005 10:13:15 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: IPC::Open3 issue
Message-Id: <596dnZn4pasmN5HeRVn-3Q@comcast.com>

Rocky Allen wrote:

> ERROR:
> IPC::Open3 version 54 required--this is only version 1.0106 at 
> /usr/lib/perl5/5.8.7/Exporter/Heavy.pm line 121
> 
> the required version number goes higher each time I execute the script.
>
> use Sys::Hostname;
> use IPC::Open3
> my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = 

Those two lines are the equivalent of
   use IPC::Open3 43;
where the number changes every second.
You have a missing semicolon.

> if ($mon < 10) {$actmon = "0" ."$actmon";};
> if ($min < 10) {$min = "0" ."$min";};
> if ($sec < 10) {$sec = "0" ."$sec";};
> if ($mday < 10) {$mday = "0" ."$mday";};
> if ($hour < 10) {$hour = "0" ."$hour";};

Yuck!

   my $hhmmss   = sprintf "%02d:%02d:%02d",$hour,$min,$sec;
   my $yyyyddmm = sprintf "%04d-%02d-%02d",$year+1900,$mon+1,$day;
   my $fileformat = $yyyyddmm . "_$hhmmss";

	-Joe


------------------------------

Date: Wed, 24 Aug 2005 17:54:38 GMT
From: Rocky Allen <everythingelse@bobotheclown.org>
Subject: Re: IPC::Open3 issue
Message-Id: <pan.2005.08.24.18.06.50.53323@bobotheclown.org>

On Wed, 24 Aug 2005 10:13:15 -0700, Joe Smith wrote:

> Rocky Allen wrote:
> 
>> ERROR:
>> IPC::Open3 version 54 required--this is only version 1.0106 at 
>> /usr/lib/perl5/5.8.7/Exporter/Heavy.pm line 121
>> 
>> the required version number goes higher each time I execute the script.
>>
>> use Sys::Hostname;
>> use IPC::Open3
>> my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = 
> 
> Those two lines are the equivalent of
>    use IPC::Open3 43;
> where the number changes every second.
> You have a missing semicolon.
> 
>> if ($mon < 10) {$actmon = "0" ."$actmon";};
>> if ($min < 10) {$min = "0" ."$min";};
>> if ($sec < 10) {$sec = "0" ."$sec";};
>> if ($mday < 10) {$mday = "0" ."$mday";};
>> if ($hour < 10) {$hour = "0" ."$hour";};
> 
> Yuck!
> 
>    my $hhmmss   = sprintf "%02d:%02d:%02d",$hour,$min,$sec;
>    my $yyyyddmm = sprintf "%04d-%02d-%02d",$year+1900,$mon+1,$day;
>    my $fileformat = $yyyyddmm . "_$hhmmss";
> 
> 	-Joe

Thank you so much.  I cannot believe how foolish that was.  I knew there
must be an easier way to get the date printed, but couldnt find an obvious
method using perdoc -q time.  
Thanks again



------------------------------

Date: Wed, 24 Aug 2005 14:23:03 GMT
From: Rocky Allen <rallen@bobotheclown.org>
Subject: IPC::Open3
Message-Id: <Pine.LNX.4.61.0508241017320.6954@grn-amd64-00.grntech.net>

on my system, SLES9 I get a random error about the IPC::Open3 module 
called in the code posted below.  I thought to post to the modules group, 
but IPC::Open3 seems native to the core install.  Here is the error, 
followed by the code.  Thanks.
Rocky

ERROR:
 IPC::Open3 version 58 required --this is only version 1.01 06

#!/usr/bin/perl

use strict;
use warnings;
use Sys::Hostname;
use IPC::Open3

my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = 
localtime(time);
my $actyear = $year + 1900;
my $actmon = $mon + 1;
if ($mon < 10) {$actmon = "0" ."$actmon";};
if ($min < 10) {$min = "0" ."$min";};
if ($sec < 10) {$sec = "0" ."$sec";};
if ($mday < 10) {$mday = "0" ."$mday";};
if ($hour < 10) {$hour = "0" ."$hour";};
my $error ;
my @errors;
#  Variables.  This section will need to be modified for each Cooperative.

my $host = hostname;
my $backupdir = '/backup/scripts/files';
my $jobstart = localtime();
my $fileformat = "contents-" . "$actyear" . "-" . "$actmon" . "-" . 
"$mday" . "_" . "$hour" . ":" . "$min" .  ":" . "$sec";
my $largefiles = '/tmp/largefiles';
my $contentsfile = "/etc/backup/$fileformat";

system("cd $backupdir ; find . -follow -size +2000000k -print > 
$largefiles");
push @errors, "could not open Filehandle to get large files: $?\n" if 
defined($error);
print "I made it here\n";
open(FH, $largefiles) or $error = 1;
push @errors, "could not open Filehandle to get large files: $!\n" if 
$error;



------------------------------

Date: Wed, 24 Aug 2005 10:16:59 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: IPC::Open3
Message-Id: <ZsqdnUTNUaUGNpHeRVn-hA@comcast.com>

Rocky Allen wrote:

> ERROR:
>  IPC::Open3 version 58 required --this is only version 1.01 06

You'll get that error when the time is 58 seconds past the minute.

> use IPC::Open3
> my ($sec) = 58;

"use IPC::Open3 58;" is not good.  Fix the typo first.


------------------------------

Date: 24 Aug 2005 13:00:17 GMT
From: BZ <BZ@caradhras.net>
Subject: isnan(), fpclassify()
Message-Id: <slrndgorr1.u8i.BZ@kalypso.caradhras.net>

Hi!

I was wondering if the functionality of the C99 function isnan(),
isinf() and fp_classify() are available in perl.  

Or even better, is it possible to get printf to recognise things like
'nan' and 'inf' as floats?  They seems to be interpreted as text by
default:

[bas@matilda]~> perl -e 'printf "%e %e %e %e\n", "123", "nan", "inf", "-inf";'
1.230000e+02 0.000000e+00 0.000000e+00 -0.000000e+00


-- 
BZ


------------------------------

Date: Wed, 24 Aug 2005 12:31:57 -0400
From: Brian Gorby <gorbster@nogmailspam.com>
Subject: mod_perl 1.29: send_fh(): result status?
Message-Id: <ns2dnaUxbPEiPJHeRVn-gA@comcast.com>

I'm programming a web application that limits the number of downloads 
for clients on certain files:

 ...
unless ( $r->header_only ) {
   $r->send_fd($fh);
   $self->record_download($user_id, $file_id);
}
close($fh);

I'd like to be able to have some sort of confirmation that the file was 
sent / received in entirety before recording the download; if the 
download times out for whatever reason for the client, the download will 
not be recorded.

Is this something that's possible in general? with mod_perl?

-Brian


------------------------------

Date: Wed, 24 Aug 2005 16:52:38 +0200
From: Daniel Zinn <daniel@QMiC.de>
Subject: Re: Perl <-> C language interaction
Message-Id: <dei1r2$ukb$1@newsserver.rz.tu-ilmenau.de>

Larry Amontec wrote:

> My question: how can I interact between a perl script to a C program. I
> mean I will have pointer of structure to pass to the C program.

You want to have a look at swig  ....  http://www.swig.org/

Best regards,
Daniel 

PS: But you also can do it with a lexer/parser, etc in C/C++
-- 
PGP-Key: http://www.keyserver.net oder http://pgpkeys.pca.dfn.de 
PGP-Key-ID: DA7306B4
Fingerprint: 5FDA E78A 73CC CAE3 AE85 0778 C43E 2F0C DA73 06B4



------------------------------

Date: Wed, 24 Aug 2005 10:21:15 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: TimeDate conversion to string.
Message-Id: <ZsqdnUfNUaUEMZHeRVn-hA@comcast.com>

Tony wrote:

> $labelname = printf "REL_" . $proj[0] . "_%02d%02d%02d_%02d%02d%02d",
> 
> Why do I get the extra 1 when adding \n?

Because printf() returns true (1) when it succeeds.
The generated string is going directly to STDOUT, not to $labelname.


------------------------------

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 8353
***************************************


home help back first fref pref prev next nref lref last post