[8445] in Perl-Users-Digest
Perl-Users Digest, Issue: 2062 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 10 07:09:41 1998
Date: Tue, 10 Mar 98 04:00:28 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 10 Mar 1998 Volume: 8 Number: 2062
Today's topics:
Re: c.l.p.mod and TPI (A. Deckers)
Re: c.l.p.mod and TPI <dformosa@st.nepean.uws.edu.au>
Finding perl version with script <menno@cyberdude.com>
Re: Finding perl version with script <Tony.Curtis+usenet@vcpc.univie.ac.at>
Re: Help wanted (David Waring)
Help with embedding Perl in C <gowda@slip.net>
How do i create an arbetrary length string of spaces? <mjmeans@goodnet.com>
Re: How do i create an arbetrary length string of space (John Stanley)
Re: How do i create an arbetrary length string of space <Tony.Curtis+usenet@vcpc.univie.ac.at>
Re: How do i create an arbetrary length string of space <etmgero@etm.ericsson.se>
How do you reduce the size of DBM files? <charles.nahhas@ans.alcatel.co.uk>
Re: Interrupt HELP <qdtcall@esb.ericsson.se>
Looking for program that reverses email addresses <pvr@itworks.be>
Re: Looking for program that reverses email addresses <Tony.Curtis+usenet@vcpc.univie.ac.at>
One silly question <bonzo@ionsys.com>
Re: Parsing environment variables <jim.gillespie@ssmb.com>
Re: PERL32 / mail / NT40 <Harald.Joerg@mch.sni.de>
Re: Relational arrays (Bart Lateur)
RFC on code using fork() (Alex Krohn)
S: Perl for Win32 Build 315" / "Perl for ISAPI" for MIP <busch.pad@sni.de>
Re: Since when is localtime(0) no longer 1970??? (John Stanley)
Re: Since when is localtime(0) no longer 1970??? (courtesy)
Re: Speed of sort routine vs. one-by-one compare (123 (Abigail)
Trouble With DBM / DBMX Functionality <johan@nielsencorp.com>
Re: use Module vs. no Module ??? (Martin Vorlaender)
Re: Using regex to initial cap a name (Vincent Fatica)
Re: Using regex to initial cap a name <Tony.Curtis+usenet@vcpc.univie.ac.at>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 10 Mar 1998 07:06:26 GMT
From: alain.deckers@man.ac.uk (A. Deckers)
Subject: Re: c.l.p.mod and TPI
Message-Id: <slrn6g9pji.m6h.alain.deckers@nessie.mcc.ac.uk>
>Subject: Re: c.l.p.mod and TPI
Why is this being discussed in clpm? It belongs in news.groups.
(followups)
Alain
------------------------------
Date: 10 Mar 1998 10:23:05 GMT
From: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: c.l.p.mod and TPI
Message-Id: <889525385.976597@cabal>
[..news.groups added...]
In <6e20l2$5g1$1@cyprus.atlantic.net> chip@mail.atlantic.net (Chip Salzenberg) writes:
>According to stanley@skyking.OCE.ORST.EDU (John Stanley):
>>Quoting from the proposed charter:
>>
>>]In addition, the moderators will reject any article:
>>]
>>]+ which contains an advertisement or commercial solicitation
>>] of any sort; (EXCEPTION: The Perl Insitute may post
>>] commercials that its board deems to be of general interest
>>] to the Perl community, such as announcements of upcoming
>>] Perl-oriented conferences.)
>It says that ads must be posted by TPI. It does NOT say that such ads
>must have originated with or otherwise involve the affairs of TPI people.
Then why is the bord of TPI acting as defacto moderators? We already have
a moderation panel, it should be there job to decide what is or is not
apporate to a newsgroup.
--
Please excuse my spelling as I suffer from agraphia see the url in my header.
Never trust a country with more peaple then sheep.
Support NoCeM http://www.cm.org/
I'm sorry but I just don't consider 'because its yucky' a convincing argument
------------------------------
Date: Tue, 10 Mar 1998 09:47:44 -0000
From: "Menno M Jansz" <menno@cyberdude.com>
Subject: Finding perl version with script
Message-Id: <889523633.24645.0.nnrp-06.9e981d17@news.demon.co.uk>
Please could someone tell me how I can retrieve the perl version using a
script.
Thanks, Menno
------------------------------
Date: 10 Mar 1998 12:14:14 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Finding perl version with script
Message-Id: <7xd8fu6bnd.fsf@beavis.vcpc.univie.ac.at>
Re: Finding perl version with script, Menno
<menno@cyberdude.com> said:
Menno> Please could someone tell me how I can retrieve the
Menno> perl version using a script.
perl -V
perl -v
perl -e 'print "$]\n";'
perl -MEnglish -e 'print "$PERL_VERSION\n";'
man perlvar
man perlrun
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, AT | http://www.vcpc.univie.ac.at/
"Everything I am, I learned on the back of cereal boxes" ~ RJ, "Over the Hedge"
------------------------------
Date: 10 Mar 1998 08:37:40 GMT
From: dwaring@nwsr.com (David Waring)
Subject: Re: Help wanted
Message-Id: <dwaring-1003980039130001@blv-lx103-ip13.nwnexus.net>
In article <6dr657$nau$1@skytrain.asahi-net.or.jp>, "ITC"
<itccars@twics.com> wrote:
> As a beginner to Perl, I have a problem. I am contacted with TWICS
> (http://www.twics.com). In my first CGI script in Perl, the line;
> $name = <SCRIPT> does not seem working. Similarly, the line;
>
> print("\n"); or print("\t"); don't work.
>
If you could be more explict here I think we could help. I'll take a stab.
Are you trying to print a response back to a web page? If so you will need
to include a content type line. Also remember that in response to a form
you MUST send something back to the web browser otherwise it gets all
confused and pouts about some internal server error (even though the
script will run fine without it).
print "Content-type: text/html\n\n";
print "any html you want after this";
as for the first question,
$name=<SCRIPT> will put the first line of SCRIPT into $name
try
open (SCRIPT,"myscript"); #open the file myscript for reading hereafter you can
# refer to it as SCRIPT
@theScript=<SCRIPT>; #read it into an array, one line in each array element
close (SCRIPT)
It would be perfectly acceptable to post all 7 lines of your code. It
would really help if you spent a little more time and space explaining
your problem
David
------------------------------
Date: 10 Mar 1998 08:21:29 GMT
From: Sudhir Gowda <gowda@slip.net>
Subject: Help with embedding Perl in C
Message-Id: <6e2t69$8fh$1@owl.slip.net>
Hi,
I am trying to write a C program, which require to call
some perl script inside it. What is the best way to do it.
I did some reading on embedding perl interpreter in C article
in perl faq. the reason for this is to pass the C variables to perl
and get the results of the perl into C.
for example:
main () {
.....
c code
perl code( about 40 lines)
c code
}
Any help is appericated.
thanks
sudhir
------------------------------
Date: Mon, 09 Mar 1998 23:04:31 -0700
From: "Mark J. Means" <mjmeans@goodnet.com>
Subject: How do i create an arbetrary length string of spaces?
Message-Id: <3504D7EF.5AC564D1@goodnet.com>
ie. $x contains a number. I need to set $y to $x spaces.
If $x = 5, then $y gets set to " ".
------------------------------
Date: 10 Mar 1998 07:01:50 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: How do i create an arbetrary length string of spaces?
Message-Id: <6e2ogu$6dg$1@news.orst.edu>
In article <3504D7EF.5AC564D1@goodnet.com>,
Mark J. Means <mjmeans@goodnet.com> wrote:
>ie. $x contains a number. I need to set $y to $x spaces.
>
>If $x = 5, then $y gets set to " ".
perldoc perlop -- look for the binary "x" operator.
------------------------------
Date: 10 Mar 1998 09:37:51 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: How do i create an arbetrary length string of spaces?
Message-Id: <7xwwe3ym8w.fsf@beavis.vcpc.univie.ac.at>
Re: How do i create an arbetrary length string of spaces?,
Mark <mjmeans@goodnet.com> said:
Mark> ie. $x contains a number. I need to set $y to $x
Mark> spaces. If $x = 5, then $y gets set to " ".
man perlop
Multiplicative Operators
Binary "x" is the repetition operator.
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, AT | http://www.vcpc.univie.ac.at/
"Everything I am, I learned on the back of cereal boxes" ~ RJ, "Over the Hedge"
------------------------------
Date: Tue, 10 Mar 1998 11:41:34 +0100
From: Geert Roovers <etmgero@etm.ericsson.se>
Subject: Re: How do i create an arbetrary length string of spaces?
Message-Id: <350518DE.60B3@etm.ericsson.se>
Mark J. Means wrote:
>
> ie. $x contains a number. I need to set $y to $x spaces.
>
> If $x = 5, then $y gets set to " ".
$y = " " x $x;
(yes, that really works)
HTH Geert
------------------------------
Date: 10 Mar 1998 10:38:14 GMT
From: "charlie nahhas" <charles.nahhas@ans.alcatel.co.uk>
Subject: How do you reduce the size of DBM files?
Message-Id: <01bd4c10$75b7a800$6b793ec2@Charles.Nahhas.ANS.alcatel.co.uk>
I am writing a perl script which uses a DBM file to store and retrieve
data.
I want to limit the size of the file.
When the file reaches a certain size, (the sum of the size of the .pag and
.dir files > file_max_size) I delete the earliest records using
delete($RECORD{earliest}). I then set a variable to be able to identify the
next earliest record.
I then check the size of the file again and if it is less than
file_max_size, the loop exits, otherwise, the deleting step is repeated.
When the file reaches file_max_size, the records are deleted as expected,
but the file size does not decrease. So the scripts gets stuck in the loop,
deleting all the records until the file is empty. Even when the file is
empty, the size of the file is still the size it was when it started
deleting the records.
I have tried closing the file after each delete, and checking the size when
the file is closed.
I have tried copying the file to a hash, deleting the file and then
creating a new file and copying the hash back in.
I have tried using the undef instead of the delete.
None of the above seem to work and I am reluctant to use the length()
function on all the keys and values as this would have a negative effect on
the performance of the script as the files will be quite big.
Has anyone had this problem, and if so, what are the ways around it? Is it
a problem with the operating system? (I am on HP-UX 10.20).
Below is the section of the script that I have described. However, I do not
think the problem is here but in the way the DBM files work.
I have not used DBMs before so any help or advice will be well appreciated.
Thanks in advance. Charlie.
#these lines would be at the head of the script.
$filename='./DBMfilename';
$filemaxsize=10000;
#check file size
$size_file1= -s($filename.'.dir');
$size_file2= -s($filename.'.pag');
$filesize=$size_file1+$size_file2;
print("current size:$filesize\n");
while ($filesize > $filemaxsize)
{
#open file
dbmopen(%RECORD,$filename,undef);
$redundant_period=$RECORD{'EARLIEST-TIME'};
#remove record with redundant period
delete $RECORD{$redundant_period};
$entry_exist=0;
while((!$entry_exist)&&(&is_valid($redundant_period)))
{
#increment earliest time record
$next_period=&increment_time($redundant_period);
if ($RECORD{$next_reference})
{
#data exists, set as new earliest time
$RECORD{'EARLIEST-TIME'}=$next_period;
$entry_exist=1;
}
else
{
# no data for this period, try next period
$redundant_period=$next_period;
}
}
#copy the file to a hash....
%tmp_store=%RECORD;
#...close the file....
dbmclose(%RECORD);
#....delete the file....
unlink($filename);
#....create a new file and.....
dbmopen(%UPDATE,$filename,0644);
#....copy the hash back in.
%UPDATE=%tmp_store;
undef(%tmp_store);
dbmclose(%UPDATE);
#check file size again
$size_file1= -s($filename.'.dir');
$size_file2= -s($filename.'.pag');
$filesize=$size_file1+$size_file2;
print("new size:$filesize\n");
}
------------------------------
Date: 10 Mar 1998 10:02:55 +0100
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: Interrupt HELP
Message-Id: <isafayj4u8.fsf@godzilla.kiere.ericsson.se>
mcai3ph2@ist4.co.umist.ac.uk (PH) writes:
> If some data comes asynchronously from the PC's serial port,
> how can a Perl script notice this?
In the same way a C++, Lisp or COBOL program can, I guess (i.e., that
doesn't seem to be a Perl question, try asking in a PC-hardware group
or something).
--
Calle Dybedahl, UNIX Sysadmin
qdtcall@esavionics.se http://www.lysator.liu.se/~calle/
------------------------------
Date: Tue, 10 Mar 1998 10:24:36 +0000
From: Patrick Van Renterghem <pvr@itworks.be>
Subject: Looking for program that reverses email addresses
Message-Id: <350514E3.32F4@itworks.be>
Hello,
First of all, I would like to mention that this question does not have
anything to do with SPAMming.
We have a long list of subscribers for our Eye on IT newsletter, and we
would like to regularly manipulate this list of email addresses to see
where the subscribers come from, and break them down by domain name.
Hence, we are looking for a program that reverses email addresses, and
turns e.g. pvr@itworks.be into be-itworks-pvr, from where we can take
further action to count similar occurrences, etc. The email adress can
be embedded in lines like
Patrick Van Renterghem <pvr@itworks.be>
pvr@itworks.be (Patrick Van Renterghem)
...
We expect that this kind of routine has been written hundreds of times,
and we would appreciate a Perl code snippet to get us going,
as we are not so experienced in Perl (if you would have this in C,
we would also welcome it).
Many thanks for helping us out.
Patrick Van Renterghem - pvr@itworks.be - but I guess you knew that
--
---
I.T. Works bvba
IIC-K13, Technologiepark 3 - URL: http://www.itworks.be/
9052 Gent (Belgium) - E-Mail: info@itworks.be
Phone: +32 (0)9 241.56.13 - Fax: +32 (0)9 241.56.56
Daily News, Weekly Newsletter, Timely Reports, Unique Seminars
PGP Fingerprint: 97AB 9BC3 7587 3093 0646 5831 936A 27DA
---
------------------------------
Date: 10 Mar 1998 12:12:08 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
To: pvr@itworks.be
Subject: Re: Looking for program that reverses email addresses
Message-Id: <7xg1kq6bqv.fsf@beavis.vcpc.univie.ac.at>
Re: Looking for program that reverses email addresses,
Patrick <pvr@itworks.be> said:
Patrick> program that reverses email addresses, and turns
Patrick> e.g. pvr@itworks.be into be-itworks-pvr, from where
Patrick> we can take further action to count similar
Patrick> occurrences, etc. The email adress can be embedded
Patrick> in lines like
use the Mail::Address module, this will do the dirty work at
least of parsing the address into identifiable bits.
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, AT | http://www.vcpc.univie.ac.at/
"Everything I am, I learned on the back of cereal boxes" ~ RJ, "Over the Hedge"
------------------------------
Date: Tue, 10 Mar 1998 00:56:15 -0500
From: Bonzo <bonzo@ionsys.com>
Subject: One silly question
Message-Id: <3504D5FE.F60D4C1@ionsys.com>
I would like to learn perl/cgi but i have a lot of other stuff to
learn on my plate. I would like to make a cgi script that would be a
fairly nice message board, nothing fancy. How long would u say it
would take a moderate computer person with "skills" in basic,
javascript, java, and vb (yes i know it sucks)?
Thanks for your time.
Bonzo
------------------------------
Date: 10 Mar 1998 11:06:00 +0000
From: James Gillespie <jim.gillespie@ssmb.com>
Subject: Re: Parsing environment variables
Message-Id: <biiiupm955z.fsf@ssmb.com>
epa@datcon.co.uk (Ed Avis) writes:
> I'm reading filenames from a config file. I'd like to allow the
> user to specify environment variables as part of these pathnames.
How much control do you have over the config file? I've done
something similar for a script I've written by writing the config file
as a perl module. This gives environment variables pretty much for
free, and some fiddling with packages allows you to use variables from
the main program. In skeleton form:
File "main":
----8<--------8<----
#!/usr/bin/perl -w
require 5.004;
use strict;
use Env qw(FOO);
use vars qw($FOO @ISA @EXPORT $bar);
@ISA = qw (Exporter);
@EXPORT = qw ($bar);
$bar = shift;
# Read the config module. Leave it until now so that it can use
# program variables; use "require" and "import" instead of "use" so
# that it is read at runtime and not compile time.
require config; import config;
print "Directory is: $config{directory}\n";
----8<--------8<----
The main program makes itself an Exporter, and makes $bar
available for import.
File "config.pm":
----8<--------8<----
package config;
require Exporter;
@ISA = (Exporter);
@EXPORT = qw(%config);
use Env qw (FOO);
import main;
%config = (directory => "$FOO/$baz",
);
1;
----8<--------8<----
The config module imports all available variables from the main
program, and makes a hash available for import.
This is untested but based on working code - if it doesn't work
double check for typos. If you want to check the value of $FOO in the
config module, you can just write some perl to do it!
A guru will be along in a moment to tell us why this is a Bad
Idea.
Jim
--
Jim.Gillespie@ ,'_ I always pack better when I'm pissed,
USA.net / -.--. ___ and Gatwick always seems nicer when
+44 171 721 2672 _\_x \__`--'_,-' you've got a hangover
/ /\\ \--'_-\\ -- Chris Paine
'94 Super III \__/ `---' \__/
------------------------------
Date: Tue, 10 Mar 1998 10:11:29 +0100
From: Harald Joerg <Harald.Joerg@mch.sni.de>
To: Edwin_van_Stam@nl.compuware.com
Subject: Re: PERL32 / mail / NT40
Message-Id: <350503C1.90545E7@mch.sni.de>
[mailed and posted]
Edwin J. van Stam wrote:
> I need some source coding with which I can create a mail from a
> perlscript. Ok, on unix boxes you have the sentmail option, but that's
> not available on NT 4.0.
>
> Is there any way to sent responses by mail, with usage of Perl? I know
> the existence of a MAIL:: module, but that's also Unix oriented, I'm
> afraid.
This question has been asked so often that a special heading has been
made for it in the Perl for Win32 FAQ:
<URL:http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html>:
Section 4.5: "What's the equivalent of sendmail for Win32?"
--
Oook,
--haj--
------------------------------
Date: Tue, 10 Mar 1998 09:51:34 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Relational arrays
Message-Id: <35050470.706829@news.tornado.be>
baboulen@aol.com (Baboulen) wrote:
>I'm trying to 'connect' two lists.
>DISK PHYSICAL SIZE ....
>disk1 c0t0d0 4Go ....
>disk2 c1t0d0 2Go ....
>..... ...... ... ....
>VOL DISK .....
>name1 disk3 .....
>name2 disk2 .....
>..... ..... .....
>I want to join LIST1 and LIST2 on DISK name.
>
>How should i do ?
Whenever you think "database", think "hash". Basically, one hash for
each table. The key for the hash should always be the selection key for
your database table.
In practice, this means that you should aim to populate your hashes like
this:
$physical{'disk1'} = 'c0t0d0';
$size{'disk1'} = '4Go';
$vol{'disk1'} = 'name1';
Now you can look up any property for the disk 'disk1'.
Now it's just a matter of populating these hashes from the lists.
Assuming you have two tab-delimited text files, that are opened on
handles LIST1 and LIST2, this could be:
while(<LIST1>{
chomp;
($disk,$physical,$size) = split /\t/;
$physical{$disk} = $physical;
$size{$disk} = $size;
#to get a list of all keys:
$name{$disk} ='';
}
while(<LIST2>{
chomp;
($name,$disk) = split /\t/;
$name{$disk} = $name;
}
Note that a hash and a scalar of the same name don't interfere. I happen
to think their purpose is clear this way.
Now you can generate your final list:
$\="\n"; $, = "\t";
foreach $disk (sort keys %name) {
print $name{$disk},$disk,$physical{$disk},$size{$disk};
}
There you have it.
You could also, using a Perl-5-ism, associate each record with a hash,
and therefore generate one large hash of record hashes. This is left up
to you as an exercise. Along these lines:
$record{'disk3'}{'name'} = 'name1';
$record{'disk1'}{'physical'} = 'c0t0d0';
where 'disk3' and 'disk1' are the keys of the %record hash, and 'name'
and 'physical' are record field names.
HTH,
Bart.
------------------------------
Date: Tue, 10 Mar 1998 06:13:40 GMT
From: alex@gossamer-threads.com (Alex Krohn)
Subject: RFC on code using fork()
Message-Id: <3504d7f3.24938097@coburg>
Hi,
I'm relatively new to programming with multiple processes, but would
appreciate any comments on what I've got so far (if I'm doing things
right. =).
Basically, what I want to do is go through a list of links in a flat
file database and see if they return a 200 status. I'm using the LWP
module to do this, and I want to use fork to be able to spawn multiple
processes. I didn't notice a big as a performance increase as I
thought. Is this because of how lwp works, or was I just expecting too
much?
Actually, after looking over the code, do I need a seperate user agent
for each child?
Thanks for any help!
Alex
# -------------------------------------------------------
$| = 1; # Must flush output.
local ($ua) = new LWP::UserAgent;
open (DB, "<$db_file_name") or &cgierr("error in verify_links. unable
to open db file: $db_file_name. Reason: $!");
@lines = <DB>;
close DB;
print "Checking ", $#lines+1, " links. Please be patient: \n";
local (@data, $children);
LINE: foreach $line (@lines) {
if ($line =~ /^$/) { next LINE; }
if ($line =~ /^#/) { next LINE; }
chomp ($line);
(@data) = &split_decode($line);
# Only check http links..
if ($data[$db_url] !~ /^http/) { next LINE; }
# Only let up to $db_max_children loose at once..
if ($children > $db_max_children) {
wait;
}
# Spawn a child to check a link.
&spawn ($data[0], $data[$db_url]);
}
# Hang around until all the children are done..
while ($children > 0) {
wait;
}
sub spawn {
# -----------------------------------------------------
my ($key, $url) = @_;
my ($pid);
if (!defined($pid = fork)) {
&cgierr ("cannot fork: $!");
}
elsif ($pid) {
$children++;
return;
}
else {
&check_link ($key, $url);
exit;
}
}
sub check_link {
# -----------------------------------------------------
my ($key, $url) = @_;
my ($req) = new HTTP::Request ('HEAD', $url);
my ($res) = $ua->request($req);
$code = $res->code;
print qq|Checking key: $key . . .|;
if ($res->is_success) {
print qq|Success ($code).\n|;
}
else {
print qq|Failure ($code).\n|;
}
}
------------------------------
Date: Mon, 09 Mar 1998 08:36:23 +0100
From: Michael Busch <busch.pad@sni.de>
Subject: S: Perl for Win32 Build 315" / "Perl for ISAPI" for MIPS
Message-Id: <35039BF7.392DF06D@sni.de>
Hello,
I am looking for "Perl for Win32 Build 315" and "Perl for ISAPI" for
MIPS.
ActiveWare does not longer support these Plattform, but perhaps someone
has compiled the sourcecode by himself.
I have got version 5.001 of "Perl for Win32" from the NT Resource Kit.
Please answer me if someone has got "Perl for ISAPI" for this version.
Best Regards,
Michael Busch
-----------------
X-no-archive: yes
------------------------------
Date: 10 Mar 1998 06:08:26 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Since when is localtime(0) no longer 1970???
Message-Id: <6e2lcq$4ar$1@news.orst.edu>
In article <3504D243.80167A@blaxxun.com>,
Michael Schilli <mschilli@blaxxun.com> wrote:
>While this used to be january 1st, 1970, localtime(0) is nowadays
>
> (0 0 16 31 11 69 3 364 0)
>
>Am I in a galactic wormhole? Help!
perldoc -f localtime
You are posting from a timezone that is 8 hours different than GMT. It
is logical to assume that localtime(0) might be 8 hours different.
------------------------------
Date: 10 Mar 1998 06:05:09 GMT
From: Bob Shair (courtesy) <rmshair@delphi.itg.uiuc.edu>
Subject: Re: Since when is localtime(0) no longer 1970???
Message-Id: <6e2l6l$gdp$1@vixen.cso.uiuc.edu>
Michael Schilli <mschilli@blaxxun.com> wrote:
> While this used to be january 1st, 1970, localtime(0) is nowadays
> (0 0 16 31 11 69 3 364 0)
> Am I in a galactic wormhole? Help!
No, you're in the Pacific time zone.
(0 0 18 31 11 69 3 364 0)(I'm in the Central)
--
Bob Shair rmshair@delphi.itg.uiuc.edu
Open Systems Specialist Champaign, Illinois
/* Opinions expressed are mine... go get your own! */
------------------------------
Date: 10 Mar 1998 06:38:44 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Speed of sort routine vs. one-by-one compare (123)
Message-Id: <6e2n5k$bel$1@client2.news.psi.net>
Nick Halloway (snowe@rain.org) wrote on 1652 September 1993 in
<URL: news:Pine.SUN.3.96.980309204332.23998A-100000@coyote.rain.org>:
++
++ On Mon, 9 Mar 1998, Paul Wolf wrote:
++
++ > I don't know how Perl's sort function is constructed, but your proposed
++ > alternative is called an insertion sort, and a binary search to determine
++ > where it should be placed is certainly faster that comparing it to each of
++ > the file records.
++
++ Is there a binary insertion sort routine around?
The problem with insertion sort isn't just the number of comparisons,
it's only the number of swaps that's quadratic. Even if you find the
right place to insert instantaniously, you still need linear time
to move the records in the file *PER INSERT*.
++ I wonder if a bubble sort, that is comparing the record to each
++ record in turn, would take a long time with 50,000 records.
That would be approx 10*9 comparisons.
++ Longer than a second, say? It would be comparing records on
++ length of the first word.
Uhm, if you can do the comparison in half a nano second, and
spend another half a nano second in swapping two records, yes,
then you could do it in a second.
In general, you notice the difference between bubblesort and quicksort
around 10 reconds.
Abigail
--
perl -wle '$, = " "; sub AUTOLOAD {($AUTOLOAD =~ /::(.*)/) [0];}
print+Just (), another (), Perl (), Hacker ();'
------------------------------
Date: 10 Mar 1998 10:19:12 GMT
From: "Johan Nielsen" <johan@nielsencorp.com>
Subject: Trouble With DBM / DBMX Functionality
Message-Id: <01bd4c10$9a93b100$c9c2bfce@roskilde.nielsencorp.com>
I have a slight problem successfully using the database functionality built
into Perl5. The book that I'm using really only discusses using DB_File
and that appears to be the old implementation of DBM functionality.
What I have installed on my Sun (Solaris 2.5) is the NDBM or ODBM
implementation. In an attempt to use either of these implementation to
create a DBM file, I come up against the following error when I execute the
script.
-------
$ convert.pl -f convert.dat
Identifier "main::opt_f" used only once: possible typo at convert.pl line
10.
Argument "O_SVWST" isn't numeric in null at convert.pl line 19.
$
-------
This is the source for the script, most of which came out of a book:
-------
#!/usr/local/bin/perl -w
# Use the DBM module.
use Getopt::Long;
use NDBM_File;
# Set up the command line options.
my $ret = GetOptions ("f|filename:s");
my $filename = $opt_f || die "Usage: $0 -f filename -d database\n";
my %inventory;
# Open the input file.
open (INPUT, "$filename") || die "Can not open the file $filename : $!\n";
# Open the DBM database file.
tie(%inventory,NDBM_File,'convert.dbmx',O_RDWR|O_CREAT,0640);
# Loop through the input file and put it into the DBM database.
while (<INPUT>)
{
chomp;
# Split the line
my ($number,$type,$name,$price,$desc) = split (/\|/);
# Save the information into the DBM file.
$inventory{$number} = "${type}|${name}|${price}|${desc}";}
# Close the dbm database
untie %inventory;
# Close the input file.
close (INPUT);
-------
Can anyone help me resolve this problem?
Thanks in advance
Johan
------------------------------
Date: Tue, 10 Mar 1998 06:22:31 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: use Module vs. no Module ???
Message-Id: <3504ce17.524144494f47414741@radiogaga.harz.de>
John Porter (jdporter@min.net) wrote:
: I know that use Module LIST causes a require of Module,
: and calls Module::import( LIST );
: my question is, if I say "no Module", does it result in a
: call to a sub in Module? If so, what's it called?
Looking into strict.pm, integer.pm and lib.pm gives me the impression
that it's unimport() that gets called.
cu,
Martin
--
| Martin Vorlaender | VMS & WNT programmer
Ceterum censeo | work: mv@pdv-systeme.de
Redmondem delendam esse. | http://www.pdv-systeme.de/users/martinv/
| home: martin@radiogaga.harz.de
------------------------------
Date: Tue, 10 Mar 1998 06:02:24 GMT
From: vefatica@syr.edu (Vincent Fatica)
Subject: Re: Using regex to initial cap a name
Message-Id: <3504d58a.29152929@news.ican.net>
On Mon, 09 Mar 1998 19:48:37 -0800, Franco Finstad <ffinstad@best.com> wrote:
>I need to translate the string:
>
> lastname, firstname
>
>into:
>
> Lastname, Firstname
# g = all occurences (first letter of word)
# e = extended regex (replacement string is evaluated)
$_ = "last, first";
s/\b([a-z])/uc($1)/eg;
print $_;
- Vince
___
Vincent Fatica
Syracuse University Mathematics
vefatica@syr.edu
http://barnyard.syr.edu/~vefatica/
------------------------------
Date: 10 Mar 1998 09:30:23 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Using regex to initial cap a name
Message-Id: <7xsooraqxs.fsf@beavis.vcpc.univie.ac.at>
Re: Using regex to initial cap a name, Franco
<ffinstad@best.com> said:
Franco> I need to translate the string: lastname, firstname
Franco> into:
Franco> Lastname, Firstname
Franco>
Franco> I know this can be done elegantly using tr///; and
Franco> s///; but I haven't found a way.
man perlfaq4
How do I capitalize all the words on one line?
Not exactly what you want to do, but it's a good start.
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, AT | http://www.vcpc.univie.ac.at/
"Everything I am, I learned on the back of cereal boxes" ~ RJ, "Over the Hedge"
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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 V8 Issue 2062
**************************************