[12667] in Perl-Users-Digest
Perl-Users Digest, Issue: 76 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 8 11:07:17 1999
Date: Thu, 8 Jul 1999 08:05:12 -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 Thu, 8 Jul 1999 Volume: 9 Number: 76
Today's topics:
Alarm broken in 5.004_04 !!?!!?? <ralawrence@my-deja.com>
Re: Alarm broken in 5.004_04 !!?!!?? (Malcolm Hoar)
Autodecrementing strings. <lbenfie1@avwb001.aveley.ford.com>
Re: Connection problem using Perl DBI and IIS4 pascal_essiembre@my-deja.com
Re: errors with #!/usr/bin/env perl -w <tchrist@mox.perl.com>
Fail in make test when installing DBD for postgresql <nospam@nospam.nospam>
Re: finding relative path between two files (Abigail)
Re: Floating Point Number With Time Function <troyknight@troyknight.eurobell.co.uk>
Re: Floating Point Number With Time Function <tchrist@mox.perl.com>
Re: Floating Point Number With Time Function (John Borwick)
Hot novel by CS professor, includes perl code (Andrew Burt)
How do YOU format your << data? <iansmith@pepper.ncinter.net>
How to force the CGI to end when the browser stop loadi <alain.borgo@ratp.fr>
Re: I need to hide the source <wallenborn@phys.chem.ethz.ch>
Re: Is PERL the way to create a pop-up window ? <tchrist@mox.perl.com>
Re: Is PERL the way to create a pop-up window ? (Andreas Fehr)
Keeping a script active (john)
Language-Suck-O-Meter ? (John Robson)
Re: Newbie: Get all directories in a directory: (Rory C-L)
Re: Perl Debugger recommendation sought <rolm@my-deja.com>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 08 Jul 1999 12:29:50 GMT
From: Richard Lawrence <ralawrence@my-deja.com>
Subject: Alarm broken in 5.004_04 !!?!!??
Message-Id: <7m25jk$9m1$1@nnrp1.deja.com>
Consider this bit of code within a larger program:
sub check_site_is_valid
{
my $socket;
eval
{
local $SIG{ALRM} = sub { die "alarm\n" };
alarm 5;
$socket = IO::Socket::INET->new( PeerAddr => $[0],
PeerPort => $_[1],
Proto => "tcp",
Type => SOCK_STREAM,
Timeout => 5 ) or return 0;
alarm 0;
};
if ($@)
{
die unless $@ eq "alarm\n";
printf "timeout of connection\n";
return 0;
}
return 1;
}
One one machine this code works fine and does what I want it to do. Its
running 5.005_03 (redhat 6). I get:
looking up 195.130.146.75 (port 1500)
195.130.146.75 (1500) is down!
looking up 195.205.22.5 (port 21)
195.205.22.5 (21) is up!
looking up 202.103.63.88 (port 21)
timeout of connection
looking up 138.253.85.33 (port 21)
138.253.85.33 is down!
...and so on...
On another machine running Perl 5.004_05 (Redhat 5.2 and the one where
the code will be live) I get:
looking up 195.130.146.75 (port 1500)
195.130.146.75 (1500) is down!
looking up 195.205.22.5 (port 21)
195.205.22.5 (21) is up!
looking up 202.103.63.88 (port 21)
Alarm clock
$
Why on earth does one version of perl be happy with this bit of code
and the other not?
Rich
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 08 Jul 1999 13:51:26 GMT
From: malch@malch.com (Malcolm Hoar)
Subject: Re: Alarm broken in 5.004_04 !!?!!??
Message-Id: <7m2acu$k0m174_002@nntp1.best.com>
In article <7m25jk$9m1$1@nnrp1.deja.com>, Richard Lawrence <ralawrence@my-deja.com> wrote:
>Consider this bit of code within a larger program:
>Why on earth does one version of perl be happy with this bit of code
>and the other not?
I ran into the same (or very similar) problem at a client site
last week. The problem seems to be with eval() rather than alarm().
As best as I can tell, a Perl binary build with a badly broken
eval() was included with one of the Redhat distributions (5.2?).
Can you post the output from 'perl -V'?
If it includes:
Characteristics of this binary (from libperl):
Locally applied patches:
MAINT_TRIAL_4 - 5.004_05 maintenance trial 4
Built under linux
Compiled at Sep 10 1998 02:16:22
I know for a certain fact that eval() is broken. It seems to
be some kind of scoping problem. I have not been able to
establish exactly which other (if any) builds are so afflicted.
My client installed a clean stable Perl build and all the
problems went away.
HTH
--
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| Malcolm Hoar "The more I practice, the luckier I get". |
| malch@malch.com Gary Player. |
| http://www.malch.com/ Shpx gur PQN. |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: Thu, 08 Jul 1999 14:58:17 +0000
From: Lee Benfield <lbenfie1@avwb001.aveley.ford.com>
Subject: Autodecrementing strings.
Message-Id: <3784BC89.852F9684@avwb001.aveley.ford.com>
Silly question (probably...),
Anyone know why the behaviour for autoincrement and autodecrement
don't tie up when used on strings?
eg:
$a = "aa";
print $a++."," for (1 .. 20);
print $a--."," for (1 .. 20);
You're making certain assumptions about ordering for the increment
to work, so why aren't those assumptions just applied similarily for
the decrement?
Just one of those little nagging questions.
(Ok abigail, I give up, which FAQ did I miss? *8)
Lee.
------------------------------
Date: Thu, 08 Jul 1999 14:07:04 GMT
From: pascal_essiembre@my-deja.com
Subject: Re: Connection problem using Perl DBI and IIS4
Message-Id: <7m2b9t$c3b$1@nnrp1.deja.com>
I'm still trying to get the Sybase Error logs from
our client and the IIS logs don't say much, but
here is what I got from the Perl error log when
my specific problem occurs. I always get one of
the two following errors. The second one
appearing a lot more frequently than the first.
***
'D:\inetpub\wwwroot\blacksheep\cgi-bin\sshrc\pdf_r
esgrant.pl' error message at: 1999/07/08 09:50:49
DBD::Sybase initialisation failed: Usage:
DBI::_setup_handle(sv, imp_class, parent,
imp_datasv) at c:/perl/site/lib/DBI.pm line 657.
(in cleanup) dbih_getcom handle
'DBI::dr=HASH(0x3de41b0)' is not a DBI handle (has
no magic) at c:/perl/site/lib/DBI.pm line 481.
(in cleanup) dbih_getcom handle
'DBI::dr=HASH(0x3de41b0)' is not a DBI handle (has
no magic) at c:/perl/site/lib/DBI.pm line 482.
at db.sub line 45
***
'D:\inetpub\wwwroot\blacksheep\cgi-bin\sshrc\pdf_r
esgrant.pl' error message at: 1999/07/08 09:52:31
Usage: DBI::_install_method(class, meth_name,
file, attribs=Nullsv) at c:/perl/site/lib/DBI.pm
line 300.
BEGIN failed--compilation aborted at db.sub line
24.
***
Again, I only get those when having multiple
connections to the remote Sybase database. Worst,
everything works fine when runnning the CGIs from
the promt.
I'll post the Sybase errors (if any) as soon as I
get them from the client (I hope I will).
In the meantime, I hope this means something to
you.
Thank you,
Pascal Essiembre (pessiembre@netscape.net)
In article
<slrn7o7qlb.ued.abigail@alexandra.delanet.com>,
abigail@delanet.com wrote:
> Pascal Essiembre (pessiembre@netscape.net) wrote
on MMCXXXVI September
> MCMXCIII in
<URL:news:n2Pg3.23579$Xr4.199771@c01read02-admin.s
ervice.talkway.com>:
> %% Hi,
> %%
> %% I have connection problems when multiple
users try to connect at the
> %% same time to a Sybase database using Perl DBI
through IIS4.
>
> Did you check the Sybase errorlog? Did you check
your servers errorlog?
> Do you have something more substantial than "my
query just stops"?
>
> Abigail
> --
> package Just_another_Perl_Hacker; sub print
{($_=$_[0])=~ s/_/ /g;
> print }
sub __PACKAGE__ { &
> print (
__PACKAGE__)} &
>
__PACKAGE__
> (
)
>
> -----------== Posted via Newsfeeds.Com,
Uncensored Usenet News ==----------
> http://www.newsfeeds.com The Largest
Usenet Servers in the World!
> ------== Over 73,000 Newsgroups - Including
Dedicated Binaries Servers ==-----
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 8 Jul 1999 08:39:42 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: errors with #!/usr/bin/env perl -w
Message-Id: <3784b82e@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
rjk@linguist.dartmouth.edu (Ronald J Kimball) writes:
:#!/usr/bin/env perl -w
:env: perl -w: Permission denied
...
:So, what is the proper way to specify command line options when using
:env in the shebang line of a Perl script?
What I've always done for this unique case is of course:
#!/usr/bin/env perl
BEGIN { $^W = 1 }
--tom
--
If you want to see useful Perl examples, we can certainly arrange to have
comp.lang.misc flooded with them, but I don't think that would help the
advance of civilization. :-) --Larry Wall in <1992Mar5.180926.19041@netlabs.com>
------------------------------
Date: Thu, 8 Jul 1999 22:04:23 +0800
From: "Calvin" <nospam@nospam.nospam>
Subject: Fail in make test when installing DBD for postgresql
Message-Id: <7m2b12$7h7$1@hfc.pacific.net.hk>
Hi,
I have installed DBI1.12 and Postgresql6.3.2 and now trying to install
DBD for postgresql (DBD::Pg). But in the procedure of "make test", i got
some error messages. What does this means??
$make test
PERL_DL_NONLAZY=1
/usr/bin/perl -I./blib/arch -I./blib/lib -I/usr/lib/perl5/i386 -linux/5.0040
4 -I/usr/lib/perl5 test.pl
DBI->data_sources .............. ok
DBI->connect ...................... ok
$dbh->{Name} .................... ok
$dbh->ping .......................... ok
$dbh->do ............................. ok
NOTICE: there is more than one operator < for types
NOTICE: unknow and unknow. You will have to retype this query
DBD::Pg::db table_info failed: ERROR: using an explicit cast
Can't call method "fetchrow_array" without a package or object reference at
test.pl line 90.
Database handle destroyed without explicit disconnect.
Database handle destroyed without explicit disconnect.
make: *** [test_dynamic] Error 29
The content of the test.pl file is as following. I remarked line90 which i
think there is a problem.
#!/usr/bin/perl -w
# $Id: test.pl,v 1.23 1999/06/16 19:01:28 mergl Exp $
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'
######################### not tested explicitly
#
# AutoCommit
# commit
# rollback
# Active
# Statement
# attributes
# err
# pg_auto_escape
# quote
# type_info_all
#
######################### We start with some black magic to print on
failure.
BEGIN { $| = 1; }
END {print "test failed\n" unless $loaded;}
use DBI ':sql_types';
$loaded = 1;
use strict;
######################### End of black magic.
# when your database is running on a remote host
# just extend both database names below like:
# $dbmain = 'template1 host=my_host port=my_port';
my $dbmain = 'template1';
my $dbname = 'pgperltest';
my ($dbh0, $dbh, $sth);
#DBI->trace(2); # make your choice
######################### drop, create and connect to test database
my $data_sources = join(" ", DBI->data_sources('Pg'));
( $data_sources =~ "dbi:Pg:dbname=$dbmain" )
and print "DBI->data_sources ........ ok\n"
or print "DBI->data_sources ........ not ok: $data_sources\n";
( $dbh0 = DBI->connect("dbi:Pg:dbname=$dbmain", "", "") )
and print "DBI->connect ............. ok\n"
or die "DBI->connect ............. not ok: ", $DBI::errstr;
my $Name = $dbh0->{Name};
( $dbmain eq $Name )
and print "\$dbh->{Name} ............. ok\n"
or print "\$dbh->{Name} ............. not ok: $Name\n";
( 1 == $dbh0->ping )
and print "\$dbh->ping ............... ok\n"
or die "\$dbh->ping ............... not ok: ", $DBI::errstr;
$dbh0->{PrintError} = 0; # do not complain when dropping $dbname
$dbh0->do("DROP DATABASE $dbname");
( $dbh0->do("CREATE DATABASE $dbname") )
and print "\$dbh->do ................. ok\n"
or die "\$dbh->do ................. not ok: ", $DBI::errstr;
$dbh = DBI->connect("dbi:Pg:dbname=$dbname", "", "") or die $DBI::errstr;
######################### create table
$dbh->do("CREATE TABLE builtin
bool_ bool,
char_ char,
char12_ char(12),
char16_ char(16),
varchar12_ varchar(12),
text_ text,
date_ date,
int4_ int4,
int4a_ int4[],
float8_ float8,
point_ point,
lseg_ lseg,
box_ box
)");
$sth = $dbh->table_info;
my @infos = $sth->fetchrow_array;
#
# The above line is line 90
#
$sth->finish;
( join(" ", @infos[2,3]) eq q{builtin TABLE} )
and print "\$dbh->table_info ......... ok\n"
or print "\$dbh->table_info ......... not ok: ", join(" ", @infos),
"\n";
my @names = $dbh->tables;
( join(" ", @names) eq q{builtin} )
and print "\$dbh->tables ............. ok\n"
or print "\$dbh->tables ............. not ok: ", join(" ", @names),
"\n";
######################### test various insert methods
# insert into table with $dbh->do($stmt)
$dbh->do("INSERT INTO builtin VALUES(
't',
'a',
'Edmund Mergl',
'quote \\\\ \'\' this',
'Edmund Mergl',
'Edmund Mergl',
'08-03-1997',
1234,
'{1,2,3}',
1.234,
'(1.0,2.0)',
'((1.0,2.0),(3.0,4.0))',
'((1.0,2.0),(3.0,4.0))'
)") or die $DBI::errstr;
# insert into table with $dbh->prepare() with placeholders and
$dbh->execute(@bind_values)
( $sth = $dbh->prepare( "INSERT INTO builtin
( bool_, char_, char12_, char16_, varchar12_, text_, date_, int4_, int4a_,
float8_, point_, lseg_, box_ )
VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )
" ) )
and print "\$dbh->prepare ............ ok\n"
or die "\$dbh->prepare ............ not ok: ", $DBI::errstr;
( $sth->execute (
'f',
'b',
'Halli Hallo',
'but not \164\150\151\163',
'Halli Hallo',
'Halli Hallo',
'06-01-1995',
5678,
'{5,6,7}',
5.678,
'(4.0,5.0)',
'((4.0,5.0),(6.0,7.0))',
'((4.0,5.0),(6.0,7.0))'
) )
and print "\$dbh->execute ............ ok\n"
or die "\$dbh->execute ............ not ok: ", $DBI::errstr;
$sth->execute (
'f',
'c',
'Potz Blitz',
'Potz Blitz',
'Potz Blitz',
'Potz Blitz',
'05-10-1957',
1357,
'{1,3,5}',
1.357,
'(2.0,7.0)',
'((2.0,7.0),(8.0,3.0))',
'((2.0,7.0),(8.0,3.0))'
) or die $DBI::errstr;
# insert into table with $dbh->do($stmt, @bind_values)
$dbh->do( "INSERT INTO builtin
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )",
{},
'y',
'z',
'Ene Mene Mu',
'Ene Mene Mu',
'Ene Mene Mu',
'Ene Mene Mu',
'14-10-1957',
5432,
'{6,7,8}',
6.789,
'(5.0,6.0)',
'((5.0,6.0),(7.0,8.0))',
'((5.0,6.0),(7.0,8.0))'
) or die $DBI::errstr;
my $pg_oid_status = $sth->{pg_oid_status};
( $pg_oid_status ne '' )
and print "\$sth->{pg_oid_status} .... ok\n"
or print "\$sth->{pg_oid_status} .... not ok: $pg_oid_status";
my $pg_cmd_status = $sth->{pg_cmd_status};
( $pg_cmd_status =~ /^INSERT/ )
and print "\$sth->{pg_cmd_status} .... ok\n"
or print "\$sth->{pg_cmd_status} .... not ok: $pg_cmd_status";
( $sth->finish )
and print "\$sth->finish ............. ok\n"
or die "\$sth->finish ............. not ok: ", $DBI::errstr;
######################### test various select methods
# select from table using input parameters and and various fetchrow methods
$sth = $dbh->prepare("SELECT * FROM builtin where int4_ < ?") or die
$DBI::errstr;
my $number = '10000';
( $sth->bind_param(1, $number, SQL_INTEGER) ) # needs use DBI ':sql_types';
and print "\$sth->bind_param ......... ok\n"
or die "\$sth->bind_param ......... not ok: ", $DBI::errstr;
$sth->execute or die $DBI::errstr;
my @row_ary = $sth->fetchrow_array;
( join(" ", @row_ary) eq q{1 a Edmund Mergl quote \ ' this Edmund Mergl
Edmund Mergl 08-03-1997 1234 {1,2,3} 1.234 (1,2) [(1,2),(3,4)]
(3,4),(1,2)} )
and print "\$sth->fetchrow_array ..... ok\n"
or print "\$sth->fetchrow_array ..... not ok: ", join(" ", @row_ary),
"\n";
my $ary_ref = $sth->fetchrow_arrayref;
( join(" ", @$ary_ref) eq q{0 b Halli Hallo but not this Halli Hallo
Halli Hallo 06-01-1995 5678 {5,6,7} 5.678 (4,5) [(4,5),(6,7)]
(6,7),(4,5)} )
and print "\$sth->fetchrow_arrayref .. ok\n"
or print "\$sth->fetchrow_arrayref .. not ok: ", join(" ", @$ary_ref),
"\n";
my ($key, $val);
my $hash_ref = $sth->fetchrow_hashref;
( join(" ", (($key,$val) = each %$hash_ref)) eq q{char12_ Potz Blitz} )
and print "\$sth->fetchrow_hashref ... ok\n"
or print "\$sth->fetchrow_hashref ... not ok: key = $key, val =
$val\n";
# test various attributes
my @name = @{$sth->{NAME}};
( join(" ", @name) eq q{bool_ char_ char12_ char16_ varchar12_ text_ date_
int4_ int4a_ float8_ point_ lseg_ box_} )
and print "\$sth->{NAME} ............. ok\n"
or print "\$sth->{NAME} ............. not ok: ", join(" ", @name),
"\n";
my @type = @{$sth->{TYPE}};
( join(" ", @type) eq q{16 1042 1042 1042 1043 25 1082 23 1007 701 600 601
603} )
and print "\$sth->{TYPE} ............. ok\n"
or print "\$sth->{TYPE} ............. not ok: ", join(" ", @type),
"\n";
my @pg_size = @{$sth->{pg_size}};
( join(" ", @pg_size) eq q{1 -1 -1 -1 -1 -1 4 4 -1 8 16 32 32} )
and print "\$sth->{pg_size} .......... ok\n"
or print "\$sth->{pg_size} .......... not ok: ", join(" ", @pg_size),
"\n";
my @pg_type = @{$sth->{pg_type}};
( join(" ", @pg_type) eq q{bool bpchar bpchar bpchar varchar text date int4
_int4 float8 point lseg box} )
and print "\$sth->{pg_type} .......... ok\n"
or print "\$sth->{pg_type} .......... not ok: ", join(" ", @pg_type),
"\n";
# test binding of output columns
$sth->execute or die $DBI::errstr;
my ($bool, $char, $char12, $char16, $vchar12, $text, $date, $int4, $int4a,
$float8, $point, $lseg, $box);
( $sth->bind_columns(undef, \$bool, \$char, \$char12, \$char16, \$vchar12,
\$text, \$date, \$int4, \$int4a, \$float8, \$point, \$lseg, \$box) )
and print "\$sth->bind_columns ....... ok\n"
or print "\$sth->bind_columns ....... not ok: ", $DBI::errstr;
$sth->fetch or die $DBI::errstr;
( "$bool, $char, $char12, $char16, $vchar12, $text, $date, $int4, $int4a,
$float8, $point, $lseg, $box" eq
q{1, a, Edmund Mergl, quote \ ' this , Edmund Mergl, Edmund Mergl,
08-03-1997, 1234, {1,2,3}, 1.234, (1,2), [(1,2),(3,4)], (3,4),(1,2)} )
and print "\$sth->fetch .............. ok\n"
or print "\$sth->fetch .............. not ok: $bool, $char, $char12,
$char16, $vchar12, $text, $date, $int4, $int4a, $float8, $point, $lseg,
$box\n";
my $gaga;
( $sth->bind_col(5, \$gaga) )
and print "\$sth->bind_col ........... ok\n"
or print "\$sth->bind_col ........... not ok: ", $DBI::errstr;
$sth->fetch or die $DBI::errstr;
( $gaga eq q{Halli Hallo} )
and print "\$sth->fetch .............. ok\n"
or print "\$sth->fetch .............. not ok: $gaga\n";
$sth->finish or die $DBI::errstr;
# select from table using input parameters
$sth = $dbh->prepare( "SELECT * FROM builtin where char16_ = ?" ) or die
$DBI::errstr;
my $string = q{quote \ ' this};
$sth->bind_param(1, $string) or die $DBI::errstr;
# $dbh->{pg_auto_escape} = 1;
# is needed for $string above and is on by default
$sth->execute or die $DBI::errstr;
$sth->{ChopBlanks} = 1;
@row_ary = $sth->fetchrow_array;
( join(" ", @row_ary) eq q{1 a Edmund Mergl quote \ ' this Edmund Mergl
Edmund Mergl 08-03-1997 1234 {1,2,3} 1.234 (1,2) [(1,2),(3,4)]
(3,4),(1,2)} )
and print "\$sth->{ChopBlanks} ....... ok\n"
or print "\$sth->{ChopBlanks} ....... not ok: ", join(" ", @row_ary),
"\n";
my $rows = $sth->rows;
( 1 == $rows )
and print "\$sth->rows ............... ok\n"
or print "\$sth->rows ............... not ok: $rows\n";
$sth->finish or die $DBI::errstr;
######################### test blobs
#my $lobject = '/tmp/gaga';
#
#my $data = "testing large objects using blob_read";
#open(FD, ">$lobject") or die "can not open $lobject";
#print(FD $data);
#close(FD);
#
#$dbh->do("CREATE TABLE lobject ( id int4, loid oid )") or die $DBI::errstr;
#$dbh->do("INSERT INTO lobject (id, loid) VALUES (1,
lo_import('$lobject') )") or die $DBI::errstr;
#
#unlink $lobject;
#
#$sth = $dbh->prepare("SELECT loid FROM lobject WHERE id = 1") or die
$DBI::errstr;
#$sth->execute or die $DBI::errstr;
#my $lobj_id = $sth->fetchrow_array;
#my $blob = $sth->blob_read($lobj_id, 0, 0);
#( $data eq $blob )
# and print "\$sth->blob_read .......... ok\n"
# or print "\$sth->blob_read .......... not ok: >$blob<\n";
#
#$sth->finish or die $DBI::errstr;
######################### disconnect and drop test database
# disconnect
( $dbh->disconnect )
and print "\$dbh->disconnect ......... ok\n"
or die "\$dbh->disconnect ......... not ok: ", $DBI::errstr;
$dbh0->do("DROP DATABASE $dbname");
$dbh0->disconnect;
print "test sequence finished.\n";
######################### EOF
--
Best regards
Calvin
http://www.geocities.com/SiliconValley/Code/9129/
------------------------------
Date: 8 Jul 1999 07:51:11 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: finding relative path between two files
Message-Id: <slrn7o97l7.vhd.abigail@alexandra.delanet.com>
Jenda Krynicky (Jenda@McCann.cz) wrote on MMCXXXVII September MCMXCIII in
<URL:news:1107_931433096@prague_main>:
$$ On 6 Jul 1999 17:55:27 -0500, abigail@delanet.com (Abigail) wrote:
$$ > Neale Morison (nmorison@ozemail.com.au) wrote on MMCXXXV September
$$ > MCMXCIII in <URL:news:cNng3.3153$A55.21785@ozemail.com.au>:
$$ > !! Is there anything substantially different to your code in the code below?
$$ > !!
$$ > !! sub find_relative_path2 ($$) {
$$ > !! my @f = split m {/}, shift;
$$ > !! pop @f;
$$ > !! my @s = split m {/}, shift;
$$ > !! while (@f && @s && $f [0] eq $s [0]) {shift @f; shift @s}
$$ > !! join q {/}, ('..') x @f, @s or ('.');
$$ > !! }
$$ >
$$ >
$$ > Nope, they are the same.
$$ >
$$ > Abigail
$$
$$ OK, so why the obfuscation?
What obfuscation?
$$ I think of myself as a seasoned perl monger, but still it took me a few moments to find out what the heck are you
$$ doing.
$$
$$ Why
$$ q q..q
$$ instead of
$$ '..'
$$ ?
Why not?
Abigail
--
perl -wle '(1 x $_) !~ /^(11+)\1+$/ && print while ++ $_'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Thu, 8 Jul 1999 14:08:49 +0100
From: "Troy Knight" <troyknight@troyknight.eurobell.co.uk>
Subject: Re: Floating Point Number With Time Function
Message-Id: <7m27m1$c8b$1@aub.eurobell.net>
Tom Christiansen <tchrist@mox.perl.com> wrote in message
news:378392df@cs.colorado.edu...
> [courtesy cc of this posting mailed to cited author]
>
> In comp.lang.perl.misc,
> "Troy Knight" <troyknight@troyknight.eurobell.co.uk> writes:
> :Is there a way to return the time to a certain amount of decimal places.
It
> :is done on the submitted page of Altavista but I think they use a
different
> :language. Help Appreciated.
>
> Yes. It's in the FAQ. You know, the one that comes with Perl.
> The one that's a regular man page. The one that's sitting
> on your very own system.
I did not get the faq's with the perl distribution (Activestate version),
but have downloaded it now.
> Please read it.
I have, the only questions regarding dates are:
How do I find the week-of-the-year/day-of-the-year?
How can I compare two dates and find the difference?
How can I take a string and turn it into epoch seconds?
How can I find the Julian Day?
How do I find yesterday's date?
Does Perl have a year 2000 problem? Is Perl Y2K compliant?
:-)
> --tom
> --
> You are the sponsor for the account andrew (Andrew Hume).
------------------------------
Date: 8 Jul 1999 08:00:11 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Floating Point Number With Time Function
Message-Id: <3784aeeb@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
"Troy Knight" <troyknight@troyknight.eurobell.co.uk> writes:
:I did not get the faq's with the perl distribution (Activestate version),
:but have downloaded it now.
Was there some mistake in your distribution or its installation, or just
a misunderstanding? I cannot verify it for myself, as I remain untainted,
having never touched the Dark Side in my life, but surely someone else of
a greyer alignment might check it. If what you're saying is true, then
this is unconscionable. The FAQs are part of the standard documentation
that comes with Perl. Without them, Perl is virtually useless. Plus it
guarantees that you'll get a tongue-lashing when you ask about such
things in these parts.
--tom
--
Basically, avoid comments. If your code needs a comment to be understood,
it would be better to rewrite it so it's easier to understand. --Rob Pike
------------------------------
Date: Thu, 8 Jul 1999 13:48:30 GMT
From: John.Borwick@sas.com (John Borwick)
Subject: Re: Floating Point Number With Time Function
Message-Id: <3784ab5f.5590478@newshost.unx.sas.com>
On Thu, 8 Jul 1999 14:08:49 +0100, "Troy Knight"
<troyknight@troyknight.eurobell.co.uk> wrote:
>> "Troy Knight" <troyknight@troyknight.eurobell.co.uk> writes:
>> :Is there a way to return the time to a certain amount of decimal places.
>It
>> :is done on the submitted page of Altavista but I think they use a
>different
>> :language. Help Appreciated.
>I did not get the faq's with the perl distribution (Activestate version),
>but have downloaded it now.
the faqs should be in your perl\html\lib\pod directory, where perl is
your root perl directory.
for printing out a certain number of digits, i think you'll want to
use sprintf. look at the docs. you might need to review printf as
well.
hope this helps,
--
John Borwick
------------------------------
Date: Thu, 08 Jul 1999 14:50:07 GMT
From: y2k@tech-soft.com (Andrew Burt)
Subject: Hot novel by CS professor, includes perl code
Message-Id: <zU2h3.3491$Pt1.14@wormhole.dimensional.com>
Granted, not _much_ perl code, but... hey, I thought folks might be
interested in a novel that's just out, Noontide Night. Have a look at
http://www.noontidenight.com.
It has many attributes you don't see every day...
* A science fiction author who knows i++ from ++i
* Programmers as main characters, scary realism
(including code that's relevant to the story)
* Built in expiration date
And the attributes you'd want in any novel -- dynamic characters facing
tough challenges in vivid settings speckled with thought-provoking ideas,
like what we all might be doing next January (yes, it is a Y2K novel),
not to mention a fun quiz on the web site -- okay, okay, I have to admit
I'm a teensy bit biased, having written it. Excuse my proud-father
behavior. But readers do seem to like it, Amazon.com keeps selling out
(publisher's keeping more on the way); and I have copies on hand for signing.
Before you let loose with flames, I thought I'd offer a few notes on it:
* Not trying to make money - all profits donated to the American
Red Cross; doing this to encourage preparedness (and thus minimize
panic).
* Not trying to create work - I'm busy enough; besides, everyone's
got all their problems just about solved, right? :-)
* No raptures, second comings, or other "biblical" material or agendas;
no black helicopters or U.N. takeovers of the world.
* No unrealistic solutions -- no tiny band of hackers saves the world,
no genius writes an "antidote" to the Y2K "virus" (ugh!), etc.
* Yes, since this _is_ fiction I've chosen a rather serious Y2K
scenario to play "what if?" with, but I've treated it realistically;
even come up with some interesting/scary possibilities... Just a
bunch of multidimensional characters in a compelling story.
* Yes, this is the only Y2K novel (that I know of) by someone with
significant programming experience (twelve years professor of
computer science, twenty years hacking together complex software
like Unix kernels, data warehouses, computer security systems,
AIs, and yes, I've done Y2K remediation work, as well as discussed
the situation with others doing remediation work inside many
organizations), and who also has fiction writing experience (I've
had dozens of science fiction short stories published, am president
of a couple writers' groups, and have won some minor awards).
* Also includes a non-fiction article so readers can learn how to
judge the matter for themselves.
Actually, posting to this group in the hopes of you buying books isn't my
goal -- you've all made up your minds here, I expect. What I'm really
hoping is that you might spread the word to the _unaware_, who are the
real audience I'm trying to reach. My desire is to reach people through
the vehicle of fiction who otherwise have tuned out or missed the Y2K
problem, that getting prepared can be done inexpensively and is a good
idea anyway, etc. Well, mainly to tell a good story (the first job
of fiction is entertainment), but if there's any underlying motive,
it's basic preparedness. Not that programmers won't get a kick out of
my speculations about what they'll be doing next January... :-)
I think the book itself is a decent read, and the folks within the science
fiction community who've read it have said some nice things--
Entertaining and provocative.
*
Ed Bryant,
Two-time Nebula Winner
So good you'll hope the Y2K bug
really does screw up the world.
*
Michael A. Burstein,
Campbell Award Winner
You've done a better job
than Michael Crichton
would have.
*
Prof. Mia Molvray,
Oklahoma University
Andrew Burt...by all reports is
one of the world's true mensches.
*
Asimov's SF Magazine
--so I don't think I'm out in left field asking you to pass the URL along
to anyone you think could benefit. A lot of folks seem to get a laugh out
of the Y2K quiz.
Flames and whatnot to y2k@noontidenight.com; orders to www.noontidenight.com :-)
--
Andrew Burt, Ph.D. http://www.noontidenight.com y2k@noontidenight.com
"Oh, what sad times are these when passing
ruffians can say 'Ni' at will to old ladies."
------------------------------
Date: Thu, 08 Jul 1999 14:42:59 GMT
From: Ian Smith <iansmith@pepper.ncinter.net>
Subject: How do YOU format your << data?
Message-Id: <TN2h3.551$s73.13857@typ21b.nn.bcandid.com>
Keywords: gelatin
Ok... I need some advice on Perl5 style. I have lost sleep on this
problem and have decided to ask the Perl community to help. When I
write a Perl program to produce web code, I like to format my multi-
line print starements like this...
print <<EOF;
<BLINK><HR>This is my first wuh-wuh-wuh page.</HR>
<A HREF="LINK">LINK</A>
EOF
But when I have to nest the code, it looks ugly.
foreach $filehandle (@outputs)
{
if ($browser =~ /mozilla/)
{
print <<EOF;
<HR> This is my first wuh-wuh-wuh page.</HR>
<A HREF="LINK">LINK</A></BLINK>
EOF
}
}
So... anyone as picky as me have a nice-looking solution to this
terrible monster? Anyone else use Perl to brute-force solutions
to the Discover magazine puzzles? :-)
--
$p=3;do{print substr('er"t ,na urklt sohr
aceheP"J',$p-1,1);$p=19*$p%29;}until $p==3;
------------------------------
Date: Thu, 08 Jul 1999 16:57:58 +0100
From: Alain BORGO <alain.borgo@ratp.fr>
Subject: How to force the CGI to end when the browser stop loading data ?
Message-Id: <3784CA86.1C719C20@ratp.fr>
Hello,
I have a CGI written in Perl (ActivePerl port for Win32) wich go
through a tree and print informations for selected files.
For some good reasons, I sometimes stop the loading within my browser
(Netscape 4.03fr). But the CGI is still running on the server (Windows
NT 4 / IIS 4).
Can I trap something within the CGI to end the script if the browser
stop loading the data ?
Thanks for help.
--
A bientōt.
---------------------------------------------------------------------------------
Je ne suis pas sūr d'avoir raison mais je suis sūr d'avoir essayé
d'avoir raison.
--
A bientōt.
---------------------------------------------------------------------------------
Je ne suis pas sūr d'avoir raison mais je suis sūr d'avoir essayé
d'avoir raison.
------------------------------
Date: 08 Jul 1999 15:05:47 +0200
From: Ernst-Udo Wallenborn <wallenborn@phys.chem.ethz.ch>
Subject: Re: I need to hide the source
Message-Id: <uilncr47h0.fsf@bacon.ethz.ch>
rdosser@my-deja.com writes:
> I need to hide a decryption algorithm for confidential data. That's
> probably not in the FAQ.
Don't do this.
Any cryptoperson will tell you: A good cryptoalgorithm has
none of its security in the secrecy of the algorithm
and all of it in the secrecy of the key. Why? If a key
is corrupted, you can simply choose a new one.
So if your algorithm is so weak that you have to hide
it: use a stronger algorithm.
--
Ernst-Udo Wallenborn
Laboratorium fuer Physikalische Chemie
ETH Zuerich
------------------------------
Date: 8 Jul 1999 08:23:24 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Is PERL the way to create a pop-up window ?
Message-Id: <3784b45c@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc, "cd156" <cd156@att.net> writes:
:I know that most of us are annoyed by pop-up windows, but I have a situation
:where a pop-up window would be an advantage.
I certainly hope you've read
http://language.perl.com/misc/div-www.html
There's an important update about the Section 508 of the Rehabilitation Act
that Dan Lewart just sent me.
--tom
--
"The road to hell is paved with melting snowballs."
--Larry Wall in <1992Jul2.222039.26476@netlabs.com>
------------------------------
Date: Thu, 08 Jul 1999 14:34:06 GMT
From: backwards.saerdna@srm.hc (Andreas Fehr)
Subject: Re: Is PERL the way to create a pop-up window ?
Message-Id: <3784b68a.33100696@news.uniplus.ch>
On 8 Jul 1999 08:23:24 -0700, Tom Christiansen <tchrist@mox.perl.com>
wrote:
> [courtesy cc of this posting mailed to cited author]
> ...
>
>I certainly hope you've read
>
> http://language.perl.com/misc/div-www.html
>
Hey, cool link on your page! Did you check it with
http://validator.w3.org/ ;)
Andreas
------------------------------
Date: Thu, 08 Jul 1999 13:31:03 GMT
From: john@nospam.co.uk (john)
Subject: Keeping a script active
Message-Id: <3785a6d7.19014861@news.freeuk.net>
Is there any perl code
that would make the script
look 'active' whilst there is
a delay (uses agent.pm) so
that the server does not 'kill'
the script off?
John
------------------------------
Date: 8 Jul 1999 14:43:41 GMT
From: as646@FreeNet.Carleton.CA (John Robson)
Subject: Language-Suck-O-Meter ?
Message-Id: <7m2det$1n2@freenet-news.carleton.ca>
Could someone tell me where is the 'Language-Suck-O-Meter' site that used
to be on the old host of The Perl Journal (www.tpj.com) ??
Ever since TPJ was taken over by EarthWeb and hosted on the the
itknowledge.com/tpj/ , some of the cool links were gone.
I miss the language-suck-meter ... I used it to show my boss and
colleagues live feedback on how cool Perl is in comparison to other languages.
Could someone at EarthWeb put it back ? Or could someone out there take
it over and tell me where it is ?
------------------------------
Date: 8 Jul 1999 13:06:00 GMT
From: campbell-lange@easynet.co.uk (Rory C-L)
Subject: Re: Newbie: Get all directories in a directory:
Message-Id: <campbell-lange-0807991405420001@campbell-lange.easynet.co.uk>
In article <3783722C.D07288A8@soft-mountain.com>, Rafael Garcia-Suarez
<rgz@soft-mountain.com> wrote:
> -d "filename" tests if the file "filename" is a directory, but looks in the
> *current* directory to find "filename". So, if you don't chdir, test fails (as
> the file doesn't exists). You have to prefix "filename" with $dir.
Thanks Rafael. This works:
sub lookin
{
$dir = shift;
opendir DIR, $dir or die "Can't open $dir $^E \n";
my @inside = map { ($dir . $_ . ':') } readdir DIR;
@inside = grep { -d and !/format/i } @inside; #!->eliminate certain dirs#
closedir DIR;
foreach my $f (@inside)
{
lookin($f);
push @directories, $f;
}
return @directories;
}
Interestingly, your
> print "$_\n" and &deepdir($_) foreach @dirs;
doesn't work at all on Macperl!
Also, I'd like to mix grep and match along the lines of your
> @dirs = grep { !/^\.\.?$/ && ($_ = "$pdir$_") && -d } readdir DIR;
so that I don't overload @inside (your @dirs)...
I'm working on that now!
Thanks for your help
Rory
--
Rory Campbell-Lange
The Campbell-Lange Workshop
------------------------------
Date: Thu, 08 Jul 1999 12:50:32 GMT
From: RoLm <rolm@my-deja.com>
Subject: Re: Perl Debugger recommendation sought
Message-Id: <7m26qj$a5r$1@nnrp1.deja.com>
In article <37845CAC.9CAD5A6C@COMPANY.com>,
kevinp@COMPANY.com wrote:
> 'lo all.
>
> I'm looking for a debugger for messing with Perl currently, and I was
> wondering if someone could recommend something for the PC. A GUI
> debugger would be preferred, but if not that, then a stable command
> line GUI would be a good second-best.
>
> I've had a look at the ActiveState Perl Debugger, but I couldn't drill
> down through objects with enough ease for it to be suitable. I need
> something that can deal with objects easily, allows the setting of
> breakpoints in multiple files for execution, and allows watching on
> the contents of structures as well.
dosen't ActiveState's PD do all that? **boggled**
RoLm
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V9 Issue 76
************************************