[28123] in Perl-Users-Digest
Perl-Users Digest, Issue: 9488 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 17 17:13:29 2006
Date: Mon, 17 Jul 2006 11:05:07 -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, 17 Jul 2006 Volume: 10 Number: 9488
Today's topics:
Re: A subroutine for gcd <tadmc@augustmail.com>
Re: Can I compare array with array? <jgibson@mail.arc.nasa.gov>
Re: Can I compare array with array? <1usa@llenroc.ude.invalid>
Re: CGI: Running a forked background process xhoster@gmail.com
Re: Module::Build / version / cpan / tail chasing <skendric@fhcrc.org>
Re: Perl equivalent of this script? <tadmc@augustmail.com>
Re: Perl equivalent of this script? <tzz@lifelogs.com>
Re: Perl integrating with PHP xhoster@gmail.com
Re: Perl integrating with PHP <tadmc@augustmail.com>
Re: Problem with ([\w ]+?) <poubelles@gmail.com>
skip path prune <weberw@adelphia.net>
skip path prune <weberw@adelphia.net>
Re: skip path prune <mumia.w.18.spam+nospam.usenet@earthlink.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 17 Jul 2006 10:37:48 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: A subroutine for gcd
Message-Id: <slrnebnbmc.vf2.tadmc@magna.augustmail.com>
gamo <gamo@telecable.es> wrote:
> This message is in MIME format.
Please do not post messages in MIME format...
> while the remaining parts are likely unreadable without MIME-aware tools.
... because parts are likely unreadable without MIME-aware tools.
> Does anyone knows how to write a sub for gcd?
That depends on what gcd means.
> Any chances that will be include in the core like sort
If it might mean Greatest Common Denominator, then there is virtually
no chance of it being included in the core.
Things that can be done with modules don't need to be in the core.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 17 Jul 2006 10:12:41 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Can I compare array with array?
Message-Id: <170720061012410986%jgibson@mail.arc.nasa.gov>
In article <Xns980280AB73156asu1cornelledu@127.0.0.1>, A. Sinan Unur
<1usa@llenroc.ude.invalid> wrote:
>
> One can actually compare arrays for equality in a single statement if
> the contents of the arrays are simple strings or numbers:
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> my @a = qw(one two three);
> my @b = qw(one two three);
> my @c = (1, 2, 3);
> my @d = (1.0, 2.0, 3.0);
>
> print 'Comparing @a and @b:', "@a" eq "@b" ? "equal\n" : "not equal\n";
> print 'Comparing @c and @d:', "@c" eq "@d" ? "equal\n" : "not equal\n";
> print 'Comparing @a and @d:', "@a" eq "@d" ? "equal\n" : "not equal\n";
>
>
> __END__
>
> Not a good idea with large arrays.
Nor is it a good idea if the elements contain spaces (or do those not
qualify as 'simple strings'? :)
#!/usr/local/bin/perl
use strict;
use warnings;
my @e = ( 'a', 'b c' );
my @f = ( 'a b', 'c' );
print 'Comparing @e and @f:', "@e" eq "@f" ? "equal\n" : "not equal\n";
__END__
Comparing @e and @f:equal
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: Mon, 17 Jul 2006 17:44:14 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Can I compare array with array?
Message-Id: <Xns98038BD607D5Fasu1cornelledu@127.0.0.1>
Jim Gibson <jgibson@mail.arc.nasa.gov> wrote in news:170720061012410986%
jgibson@mail.arc.nasa.gov:
> In article <Xns980280AB73156asu1cornelledu@127.0.0.1>, A. Sinan Unur
> <1usa@llenroc.ude.invalid> wrote:
>
>>
>> One can actually compare arrays for equality in a single statement if
>> the contents of the arrays are simple strings or numbers:
...
>> my @a = qw(one two three);
>> my @b = qw(one two three);
...
>> print 'Comparing @a and @b:', "@a" eq "@b" ? "equal\n" :
>> "not equal\n";
...
> Nor is it a good idea if the elements contain spaces (or do those not
> qualify as 'simple strings'? :)
Well, of course, I had to use a sufficiently ambiguous caution to keep
me out of trouble ;-)
Thanks for making it clear why such comparisons are bound come back and
bite you.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: 17 Jul 2006 15:28:20 GMT
From: xhoster@gmail.com
Subject: Re: CGI: Running a forked background process
Message-Id: <20060717113313.528$kR@newsreader.com>
Hal Vaughan <hal@thresholddigital.com> wrote:
> I have a web page (served up by Apache 2) where a user click a link to
> download a file. The link calls my Perl CGI script which takes the
> parameters and generates a file to download. It takes time to generate
> the file, so my idea was to fork like this:
>
...
>
> I've found, though, that the fork is not working. When I click on the
> link, I get a LONG pause and eventually the countdown page appears, but
> only after the forked program is done with it's work.
The child program is holding onto the STDOUT and STDERR that it inherited
from the parent. Apache knows that STDOUT is not yet closed, and therefore
assumes the CGI isn't done yet and holds the connection to the browser open
(or something like that.) The forked process needs to close or reopen
STDOUT/STDERR in order to cut the web browser free.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 17 Jul 2006 11:00:37 -0700
From: "sbk" <skendric@fhcrc.org>
Subject: Re: Module::Build / version / cpan / tail chasing
Message-Id: <1153159237.087231.172610@p79g2000cwp.googlegroups.com>
hi steven,
thanx! that worked
--sk
------------------------------
Date: Mon, 17 Jul 2006 09:45:23 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Perl equivalent of this script?
Message-Id: <slrnebn8k3.vf2.tadmc@magna.augustmail.com>
Paul Lalli <mritty@gmail.com> wrote:
> george.varsamopoulos@gmail.com wrote:
>> Tad McClellan wrote:
>> > You didn't even look in the Perl FAQ? That's not very nice.
>
>> I tried to "google" for it,
> Allow me to suggest that when looking for assistance with Perl, Google
> be your *last* resort, not your first.
Allow me to suggest that when looking for assistance with Perl,
posting to a Usenet newgroup be your last resort. :-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 17 Jul 2006 12:31:31 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Perl equivalent of this script?
Message-Id: <g69irlwyyzg.fsf@CN1374059D0130.kendall.corp.akamai.com>
On 17 Jul 2006, tadmc@augustmail.com wrote:
Paul Lalli <mritty@gmail.com> wrote:
> george.varsamopoulos@gmail.com wrote:
>> Tad McClellan wrote:
>>>> You didn't even look in the Perl FAQ? That's not very nice.
>>
>>> I tried to "google" for it,
>
>> Allow me to suggest that when looking for assistance with Perl, Google
>> be your *last* resort, not your first.
>
> Allow me to suggest that when looking for assistance with Perl,
> posting to a Usenet newgroup be your last resort. :-)
I don't think you worded that well, Tad. Are you saying the OP should
buy a book on Perl, look at the Perl source code, e-mail Larry Wall,
etc. before he asks for help here? I think most people on the
newsgroup wouldn't call it a last resort.
Ted
------------------------------
Date: 17 Jul 2006 15:33:21 GMT
From: xhoster@gmail.com
Subject: Re: Perl integrating with PHP
Message-Id: <20060717113814.153$UF@newsreader.com>
wesley@ispace.co.za wrote:
> Hi All, can i send variables from a php script into a perl script?
Variables, probably not. Do the variables contain data? You could send
the data contained in the variables from php to Perl. In many, many ways.
command line arguments, Environment variables, sockets (assuming php
supports this), named pipes, temp files, RDMS table entries, etc.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Mon, 17 Jul 2006 09:50:03 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Perl integrating with PHP
Message-Id: <slrnebn8sr.vf2.tadmc@magna.augustmail.com>
wesley@ispace.co.za <wesley@ispace.co.za> wrote:
> can i send variables from a php script into a perl script?
No.
You could send _values_ from a php script into a perl script though.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 17 Jul 2006 08:17:46 -0700
From: "forwax" <poubelles@gmail.com>
Subject: Re: Problem with ([\w ]+?)
Message-Id: <1153149466.629035.274530@75g2000cwc.googlegroups.com>
I finally change ([\w ]+?) for (.*) and it's working great, for now. I
will change it however for something more elegant with the
HTML::TokeParser.
That bring me to another question. I have that code for now...
$p = HTML::TokeParser->new("./$folder/${prefix}-Schedule.html") || die
"Can't open: $!";
while (my $token = $p->get_tag("a")) {
my $url = $token->[1]{href} || "-";
my $text = $p->get_trimmed_text("/td");
if ($url =~ /.*farm.*/) {
print FILE_OUT_FARM "<a href=\"$url\"> $text <\/a><br>\n";
}
else {
print FILE_OUT_PRO "<a href=\"$url\"> $text <\/a><br>\n";
}
}
and it seems that "if ($url =~ /.*farm.*/) {" doesn't work, can I use
Regex in the parser or am I missing something ?
------------------------------
Date: 17 Jul 2006 09:34:47 -0700
From: "weberw@adelphia.net" <weberw@adelphia.net>
Subject: skip path prune
Message-Id: <1153154087.371195.30460@p79g2000cwp.googlegroups.com>
How do you use the prune function to skip a printing all of the
contents of a folder? It will not print folder 3 but does print the
contents of folder 3 which I do not want printed.
#!C://Perl/bin/perl
use CGI ':standard';
use CGI::Carp 'fatalsToBrowser';
#use strict;
use warnings;
use File::Find;
my $file_count = 0;
my $dir_count = 0;
$title = "Find Files";
print header,
start_html($title),
h1($title);
find ( {
wanted => \&wanted}, 'C:/Documents and
Settings/whatever/Desktop/test');
printf "\nThere are %d files in %d directories.\n",
$file_count,
$dir_count;
sub wanted {
if (-d) {
print $File::Find::name, "\n" unless -d =~ /^folder3/;
$dir_count++;
}
elsif (-f _) {
print " <TR> <TD ALIGN=RIGHT>File name is
$File::Find::name</TD></TR><BR></BR>";
$file_count++;
}
}
end_hmtl;
------------------------------
Date: 17 Jul 2006 09:34:53 -0700
From: "weberw@adelphia.net" <weberw@adelphia.net>
Subject: skip path prune
Message-Id: <1153154093.465794.144420@h48g2000cwc.googlegroups.com>
How do you use the prune function to skip a printing all of the
contents of a folder? It will not print folder 3 but does print the
contents of folder 3 which I do not want printed.
#!C://Perl/bin/perl
use CGI ':standard';
use CGI::Carp 'fatalsToBrowser';
#use strict;
use warnings;
use File::Find;
my $file_count = 0;
my $dir_count = 0;
$title = "Find Files";
print header,
start_html($title),
h1($title);
find ( {
wanted => \&wanted}, 'C:/Documents and
Settings/whatever/Desktop/test');
printf "\nThere are %d files in %d directories.\n",
$file_count,
$dir_count;
sub wanted {
if (-d) {
print $File::Find::name, "\n" unless -d =~ /^folder3/;
$dir_count++;
}
elsif (-f _) {
print " <TR> <TD ALIGN=RIGHT>File name is
$File::Find::name</TD></TR><BR></BR>";
$file_count++;
}
}
end_hmtl;
------------------------------
Date: Mon, 17 Jul 2006 17:30:29 GMT
From: "Mumia W." <mumia.w.18.spam+nospam.usenet@earthlink.net>
Subject: Re: skip path prune
Message-Id: <VOPug.710$bP5.44@newsread1.news.pas.earthlink.net>
On 07/17/2006 11:34 AM, weberw@adelphia.net wrote:
> How do you use the prune function to skip a printing all of the
> contents of a folder? [...]
Prune is not a function but a variable. Inside your wanted
function, if you see a directory that you don't want to look
inside, set $File::Find::prune to '1' to skip its contents.
------------------------------
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 9488
***************************************