[10696] in Perl-Users-Digest
Perl-Users Digest, Issue: 4288 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 24 16:46:44 1998
Date: Tue, 24 Nov 98 13:00:30 -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, 24 Nov 1998 Volume: 8 Number: 4288
Today's topics:
Bind won't take variables <mdudley@execonn.com>
Re: Bind won't take variables (Larry Rosler)
CGI-Scripts <HeikoR@vossnet.de>
Re: CGI-Scripts (BenJamin Prater)
Re: copy a file - How? <r28629@email.sps.mot.com>
Re: Crypt and decrypt string (brian d foy)
Re: crypt (brian d foy)
custom tarfile for upgrade/install of perl (J.D. Laub)
Re: Efficiency of infinite loop and sleep (as a replace (Andrew M. Langmead)
Re: Efficiency of infinite loop and sleep (as a replace (Larry Rosler)
Re: Help Desk Perl, CGI and HTTP (Erik)
Re: Hiding "To:" field (Tad McClellan)
Re: Hiding "To:" field (brian d foy)
Re: Hiding "To:" field <r28629@email.sps.mot.com>
Re: in need of some help <r28629@email.sps.mot.com>
Re: Mailprog <r28629@email.sps.mot.com>
Re: mkDir Question (Martien Verbruggen)
More Problems with "Rename()" <wcase@mediaone.net>
Opinion Please: DB to start with <jjarrett@ecpi.com>
Re: Opinion Please: DB to start with (BenJamin Prater)
Re: Opinion Please: DB to start with (Adam Turoff)
Parsing solution needed... (BenJamin Prater)
Probably a simple question about hashes <harper2@gte.net>
Re: Probably a simple question about hashes (Erik)
Re: Probably a simple question about hashes <uri@fastengines.com>
Re: Probably a simple question about hashes <Allan@due.net>
Re: Probably a simple question about hashes (Larry Rosler)
Re: Probably a simple question about hashes <geir_sjurseth@dell.com>
Re: Probably a simple question about hashes <r28629@email.sps.mot.com>
Re: Probably a simple question about hashes <Allan@due.net>
Question about $_ <gbc1@axe.humboldt.edu>
Re: Question from a mega-geek (brian d foy)
Range operator (Kathy Passarella)
Re: Returning to a previous URL from a CGI script (Matthew Bafford)
Re: Stupid question: Script never terminates? (Erik)
Trying to write perl script that zips file <abukar@insidewire.com>
Re: Why doesn't something work? (Bart Lateur)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 24 Nov 1998 13:57:09 -0500
From: Marshall Dudley <mdudley@execonn.com>
Subject: Bind won't take variables
Message-Id: <365B0185.15435BBF@execonn.com>
I am wanting to to do a simple compare and replace operation using
regular expressions and the bind operator. Here is the expression:
$line =~ s$case/$find/$replace/$global;
Where $case is either an "i" or blank, and $global is either "g" or
blank. This line will not compile, it gives a:
Bareword found where operator expected at ./searchnr.pl line 49, near
"s$case/$find/$replace"
Unquoted string "replace" may clash with future reserved word at
./searchnr.pl line 49.
Well $replace is not an unquoted string, and it is certainly is not a
bareword! Anyway I assume that the problem is that the bind is assuming
that the "$" is an end of line marker, so all the "$"s are being lost.
So I do this:
$compare = "s$case/$find/$replace/$global";
$line =~ $compare;
Well this version compiles but does nothing. It never finds the $find
substring, and does not replace it with the $replace string.
So I try this variation:
$find =~ s/$find/$replace/;
Interestingly enough it DOES compile, whereas the first example above
does not. But it also does not work, but gives me that there is an
undefined variable in that line when I try to run it (all variables are
defined, I can print them out after it says that it is undefined).
Is there any way to get perl to do a search and replace using variables
instead of hard coded patterns? I must be able to search according to
criteria given at the time of execution.
Any assistance would be greatly appreciated for a workaround on this.
Thanks,
Marshall
------------------------------
Date: Tue, 24 Nov 1998 11:56:35 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Bind won't take variables
Message-Id: <MPG.10c4af4ddacc011898988e@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <365B0185.15435BBF@execonn.com> on Tue, 24 Nov 1998 13:57:09
-0500, Marshall Dudley <mdudley@execonn.com> says...
> I am wanting to to do a simple compare and replace operation using
> regular expressions and the bind operator. Here is the expression:
>
> $line =~ s$case/$find/$replace/$global;
>
> Where $case is either an "i" or blank, and $global is either "g" or
> blank. This line will not compile, it gives a:
I hope that by 'blank' you mean null ("") not space (" ").
... <SNIP> of lots of flailing around ...
> Is there any way to get perl to do a search and replace using variables
> instead of hard coded patterns? I must be able to search according to
> criteria given at the time of execution.
Indeed there is.
Your attempt to use $case after 's' is totally wrong. It can go either
at the end, where you are trying to put 'g' optionally, or within the
$find string as '(?i)' (without the quotes, of course).
The way to achieve your goal is to use 'eval' to generate the regex at
run time. This is fairly expensive, so best not done in a tight loop.
eval "\$line =~ s/$find/$replace/$case$global";
You will, of course, have to escape metacharacters properly in '$find',
but all should go well.
BTW: There is no newsgroup 'comp.lan.perl', and I have removed it.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 24 Nov 1998 21:03:57 +0100
From: "Heiko" <HeikoR@vossnet.de>
Subject: CGI-Scripts
Message-Id: <73f3kb$ljl$1@news.vossnet.de>
Hi there!
I4m working on my own CGI-Scripts but I can4t find a server on which I can
freely execute my own scripts. So, are there any servers like that
available?
Bye bye,
Heiko
------------------------------
Date: 24 Nov 1998 14:37:02 -0600
From: ben@sofnet.com (BenJamin Prater)
Subject: Re: CGI-Scripts
Message-Id: <365b17b7.3849111@news.sofnet.com>
Heiko,
Run it on your own box!
If you are running Windows, grab Xitami at tucows.com and you'll be
set to go!
Ben
On Tue, 24 Nov 1998 21:03:57 +0100, "Heiko" <HeikoR@vossnet.de> wrote:
>Hi there!
>
>I4m working on my own CGI-Scripts but I can4t find a server on which I can
>freely execute my own scripts. So, are there any servers like that
>available?
>
>Bye bye,
> Heiko
>
>
------------------------------
Date: Tue, 24 Nov 1998 12:56:31 -0500
From: Tk Soh <r28629@email.sps.mot.com>
To: "L. Birdwell" <airman@inreach.com>
Subject: Re: copy a file - How?
Message-Id: <365AF341.403B8230@email.sps.mot.com>
[posted to c.l.p.m and copy emailed]
L. Birdwell wrote:
>
> I am trying to copy a .gif file from one directory on my server to a new
> one I am creating. I can create the directory fine, but I don't know how
> to copy a file to it???
> I am trying:
>
> open (FILE, ">$path/images/main_bnr.gif");
> print FILE main_bnr.gif; (Where main_bnr.gif is in same dir as cgi
> program)
> close (FILE);
>
> This seems to create a file in the /images directory, but is only a very
> small file and not the whole graphics file I am trying to transfer.
use File::Copy;
HTH.
-TK
------------------------------
Date: Tue, 24 Nov 1998 14:17:24 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Crypt and decrypt string
Message-Id: <comdog-ya02408000R2411981417240001@news.panix.com>
In article <365AA90F.13EAB347@istat.it>, giuseppe.carone@istat.it posted:
> I need some procedure for crypt and decrypt some variable in perl
> script. The crypt bultin function crypt bat don't decript the string.
> Can somone help me ?
crypt() is one way. you have to guess the plaintext, crypt the
guess, and compare the crypt-ed versions.
you might consider a different encryption scheme if you need to recover
the plaintext.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Tue, 24 Nov 1998 14:15:55 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: crypt
Message-Id: <comdog-ya02408000R2411981415550001@news.panix.com>
In article <365A522D.58DAC070@viper.net>, Todd Smith <tbsmith@viper.net> posted:
> i've seen the encryption algorithim for crypt written in C, but since
> perl is my strong point, has anyone seen a version of the algorithim in
> Perl?
Perl has a crypt() builtin function, if you need one (or you on a
system which is paranoid?).
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Tue, 24 Nov 1998 20:26:39 GMT
From: jdl@iasi.com (J.D. Laub)
Subject: custom tarfile for upgrade/install of perl
Message-Id: <365b173f.0@mirage.iasi.com>
Some sites offer tarfiles containing binaries - untar & you're off &
running. I've got 15 practically identical HP machines to upgrade
to 5.005_02, and I'd like to avoid having to run tedious installs on
all the boxes. The tarfile approach seems good, but I need to use a
custom tarfile that includes some compiled modules (like DBD::Oracle).
I was wondering if anyone knows a good way to create such a tarfile.
Shown below is the best set of shell commands I've been able to come
up with off the top of my head; feedback is most welcome. Should
significant changes be suggested via email only, I'll post a recap of
the final version.
####### START BUILD OF PERL TARFILE
REAL_PREFIX=/usr/local
TMP_PREFIX=/tmp/perl_install
FILE_LIST=/tmp/FILE_LIST
TARFILE=/tmp/ah_perl_bndl_`date +'%Y%b%d'`.tar
mkdir $TMP_PREFIX
# build & install everything I want in the tarfile into $TMP_PREFIX
# build & install everything I want in the tarfile into $REAL_PREFIX
find $TMP_PREFIX ! -type d -print \
| sed "s^$TMP_PREFIX^.$REAL_PREFIX^" >| $FILE_LIST # leading "."
cd /
tar cvf $TARFILE .$FILE_LIST # leading "."
xargs tar rvf $TARFILE < $FILE_LIST
rm -rf $TMP_PREFIX $FILE_LIST
####### END BUILD OF PERL TARFILE
Questions:
* Is there a better way to create the tarfile, or maybe even a better
way to accomplish my upgrade goal?
* Old modules/files that perl no longer needs, like the perl5.00404
executable itself, will still exist after the tarfile is
installed. Is there a way to identify these before the install so
I can remove them?
* Are there any other lurking problems in my plan?
* Is the latest thinking that /usr/local should be avoided?
--
J.D. Laub (Laubster) |"I think you're very, very, very, very, very,
jdl@iasi.com |very, very, very, very, ..." - Flying Lizards
------------------------------
Date: Tue, 24 Nov 1998 19:27:15 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Efficiency of infinite loop and sleep (as a replacement for cron/at)
Message-Id: <F2xy1G.5L2@world.std.com>
bradley@iinet.net.au (Bradley K. Farrell) writes:
>1. is "for(;;)" better then "while()" ?
They compile into the same opcodes, so there will be no difference in
performance (if that is what you are asking.)
>2. does the sleep function conserve CPU cycles ?
Yes, it takes the process entirely out of the run queue, so the kernel
won't even begin to consider it for timeslicing. There are some issues
in that the process will hang around in memory longer, (until all the
pages get so stale tht they get swapped out.) and the extra word for
the pager to swap the pages out rather than just overwriting them if
the process left and started again (like for a cron task.)
>3. is there a better way to do all this ?
> (in this instance I define "better" as "having a lesser impact on
> my ISP" :)
I honestly feel that they would be be better off allowing you to
access cron. In all honesty though, My list of defeciencies above are
in all likelyhood going to have no practical impact on the
server. (The infinate loop and sleep does have some negative
repercussions for you. What happens when the server is rebooted or
your program crashes?)
Some reasons for their rule may be business decisions. For an ISP that
chages by the hit or by the minute of online time, how do you charge
the user for time spent in a cron process or in a program not
associated with a login or a hit on the HTTP server?
--
Andrew Langmead
------------------------------
Date: Tue, 24 Nov 1998 11:42:52 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Efficiency of infinite loop and sleep (as a replacement for cron/at)
Message-Id: <MPG.10c4ac134c01466f98988d@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <365be158.57973955@news.m.iinet.net.au> on Tue, 24 Nov 1998
17:43:56 GMT, Bradley K. Farrell <bradley@iinet.net.au> says...
...
> Problem: I wanted to use cron/at/batch to do some automated file
> renaming, but my ISP will not give users access to these commands.
>
> My solution: I have written a small perl script to do the renaming for
> me. It uses an infinite while loop and the sleep function. (Code
> follows at end of post).
>
> Next problem: My ISP is reluctant to let users run such scripts
> because they feel it will chew up CPU cycles.
>
> Intended solution: I would like to show my ISP that my perl script (or
> something similar) is CPU efficient. I therefore seek comment
> regarding my code, particularly my choice of the "infinite while with
> sleep" construction. eg:
>
> 1. is "for(;;)" better then "while()" ?
They are identical.
> 2. does the sleep function conserve CPU cycles ?
Yes.
> 3. is there a better way to do all this ?
> (in this instance I define "better" as "having a lesser impact on
> my ISP" :)
Not AFAIK. (When this last came up here, someone pointed out that the
absolute time of the operation would drift because of the time consumed
in performing the functions once a day, but this is simple to fix.)
You might try an experiment on your own system, using 'time' to capture
elapsed real time and 'times' to capture CPU and system time. I think
you will be able to show your ISP that the resources used are trivial
(essentially, one entry in the process table).
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 24 Nov 1998 17:31:37 GMT
From: eln@cyberhighway.net (Erik)
Subject: Re: Help Desk Perl, CGI and HTTP
Message-Id: <73eqhp$gvk$2@news.cyberhighway.net>
In article <365A580E.5C38A6B8@imag.com>,
Richard Fraser <rifraser@imag.com> writes:
> At the risk asking the wrong news group
You did.
> Is a public domain suite of code, which could be used by a Help Desk, to
> log, document and close support calls?
This is a sentence fragment. You may be missing a word somewhere.
> I envisage some perl code, using the cgi calls to create and manage the
> data from a varitey of hard ware platforms. I have seen similar using
> Louts/Notes, but I am looking for something which runs on SGI/SUN/HP,
> with SGI/HP/SUN/PC/NT clients.
If you want to find a script, rather than write one, this newsgroup is not
the place to ask. There are myriad search engines out there to help
you find what you want. If you want to write your own, feel free to do
so, and post here with any problems you're having.
--
Erik Nielsen, Cyberhighway Internet Services NOC
That's a valid argument. I just don't think it's valid enough. :-)
-- Larry Wall in <199804150050.RAA08093@wall.org>
------------------------------
Date: Tue, 24 Nov 1998 13:51:10 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Hiding "To:" field
Message-Id: <en2f37.9rk.ln@flash.net>
Alex Guberman (alex@digi-q.com) wrote:
: Does anybody know if it's possible to hide "To:" field when sending a
: message through mailprog?
This is the Perl newsgroup.
Ask Perl questions here.
Ask questions about other topics in other newsgroups.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 24 Nov 1998 15:01:36 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Hiding "To:" field
Message-Id: <comdog-ya02408000R2411981501360001@news.panix.com>
In article <3659F287.3025@digi-q.com>, alex@digi-q.com posted:
> Does anybody know if it's possible to hide "To:" field when sending a
> message through mailprog?
how is the message going to know where to go? perhaps you have a
different question with more context though. it would belong in
this forum though.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Tue, 24 Nov 1998 13:45:21 -0600
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: Hiding "To:" field
Message-Id: <365B0CD1.AFCFF9AF@email.sps.mot.com>
Alex Guberman wrote:
>
> Does anybody know if it's possible to hide "To:" field when sending a
> message through mailprog?
>
> Alex
... because your question(s) has nothing to do with Perl. :(
-TK
------------------------------
Date: Tue, 24 Nov 1998 12:37:28 -0500
From: Tk Soh <r28629@email.sps.mot.com>
To: Tad McClellan <tadmc@flash.net>
Subject: Re: in need of some help
Message-Id: <365AEED7.7A1C2D5@email.sps.mot.com>
Tad McClellan wrote:
>
> Jimmy Yeung (jiyeung@pacbell.net) wrote:
> : I wrote this script in order to print out the contents in a directory,
> : and have it posted on a website, therefore allowing the website to be
> : automated . . . it would update itself each time someone adds a file to
> : the directory . . .
>
> : #!/usr/local/bin/perl
>
> You are missing the -w there.
>
> #!/usr/local/bin/perl -w
>
> : print "Content-type:text/html\n\n";
>
> : chdir("/directory/directory/directory/directoryineedtopost") || die
> : "Cannot open directory";
> : opendir(engops,".") || die "Cannot open directory";
>
> : foreach (readdir(engops)) {
> : print "<br><A HREF=http://www.cisco.com/$_>$_</A>";
> : print "<p>";
> : }
> : closedir(engops);
>
> : The script works fine now; however it is also reading out the "." and
> : the ".." , i tried adding a if (/^[^.]/) but it didnt seem to work . .
> : how would i go about printing only the files that do not begin with a
> : dot? I have tried globbing it ( <*> ) but it didnt work . . . it kept
> : getting bugs when it brought up csh .. . so can anyone help? thank you!
>
> opendir(ENGOPS, '/directory/directory/directory/directoryineedtopost') ||
> die "could not open directory $!"; # no need to chdir() first...
> foreach (grep /^[^.]/, readdir(ENGOPS)) {
this is going to ignore also all the filenames begin with a dot. Probably want
to use
!/^[.]{1,2}$/
> print "stuff\n";
> }
> closedir(ENGOPS);
-TK
------------------------------
Date: Tue, 24 Nov 1998 13:44:02 -0600
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: Mailprog
Message-Id: <365B0C82.28A5DCE6@email.sps.mot.com>
Alex Guberman wrote:
>
> Hi,
>
> Does anybody know how to make "undeliverable" messages to come back to
> the reply-to address and not to the server admin, when sending e-mails
> through mailprog?
>
I am not going to tell you ;)
-TK
------------------------------
Date: Tue, 24 Nov 1998 20:59:07 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: mkDir Question
Message-Id: <v6F62.39$Zw2.208@nsw.nnrp.telstra.net>
In article <73egon$r6r$1@camel0.mindspring.com>,
"Allan M. Due" <Allan@due.net> writes:
> Quite annoyingly, this is broken (or purposively left out) on the latest
> version of activestate's perl. They include perldoc.bat but no pod files so
> everything is returned not found. Yuck.
I would consider this a serious bug. A perl distribution without its
documentation is not a complete perl distribution. I suggest that some
of the people using the ActiveState stuff complain loudly about this.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au |
Commercial Dynamics Pty. Ltd. | Curiouser and curiouser, said Alice.
NSW, Australia |
------------------------------
Date: Tue, 24 Nov 1998 19:46:06 GMT
From: William Case <wcase@mediaone.net>
Subject: More Problems with "Rename()"
Message-Id: <365B0C90.35873DCB@mediaone.net>
Thank you Uri for your suggestions, especially the formatting ones. I
have cleaned up the code a bit (snippet attached below).
I am still, however having problems with the "rename()" function (I
added a 'die' clause to the rename() as suggested by another helpful
person).
When I send "rename ( $cgi_sfn{'upfile'}, $tempvar1)" it does not rename
the file, nor does it return an error, nor does it continue running
anything below that statement.
The 'print' shows that $tempvar1 = "logo_TEST_TEST_TEST.gif"
HOWEVER... If I add the one line that sets "$tempvar1 =
"logo_TEST_TEST_TEST.gif";" and then the rename() it works fine!!
I can't think of any reason this would be. Any help would be wonderful,
as this is driving me quite insane!
Thanks again,
William Case
wcase@mediaone.net
-----------CODE------------
my ($tempvar1, $read_len, $extension, $result);
$extension = substr( $cgi_cfn{'upfile'}, -4, 3);
$tempvar1 = $cgi_data{'name'} . ( $extension eq 'jpg' ? '.jpg' :
'.gif' );
print "$cgi_sfn{'upfile'}\n";
print "$tempvar1\n";
$tempvar1 = "logo_TEST_TEST_TEST.gif";
rename ( $cgi_sfn{'upfile'}, $tempvar1) or die
"Unable to rename [$cgi_sfn{'upfile'}] to [$tempvar1].\n",
"Reason: $!\n";
--------END CODE----------
------------------------------
Date: Tue, 24 Nov 1998 13:14:40 -0600
From: "John T. Jarrett" <jjarrett@ecpi.com>
Subject: Opinion Please: DB to start with
Message-Id: <365B059F.D970DA87@ecpi.com>
Expert opinion please:
Got an Access database in the office, Unix servers on the web and Perl
to try to get the data from the web into Access. If you know Access, it
trashes about 30% of the new data and then tells me little more than,
'Oops!'
I just need to start again and build a database on the web and the
office will just have to use their browsers instead of Access. What
should I start with?
1. Needs to be easy (I'm no pro yet and we are in a hurry)
2. Needs to handle about 100 fields
3. Needs to handle about 100 new records per day now while I figure it
out
4. Needs to be able to handle 1000 new records per day
5. Needs to not be too complicated to tie into other tables in querries
6. It would be real nice (but not necessary) if Access already exports
to it
Thanks,
John T. Jarrett
------------------------------
Date: 24 Nov 1998 14:21:01 -0600
From: ben@sofnet.com (BenJamin Prater)
Subject: Re: Opinion Please: DB to start with
Message-Id: <365b1403.2900331@news.sofnet.com>
John,
MySQL is your best bet -- http://www.mysql.com.
Ben
On Tue, 24 Nov 1998 13:14:40 -0600, "John T. Jarrett"
<jjarrett@ecpi.com> wrote:
>Expert opinion please:
>
>Got an Access database in the office, Unix servers on the web and Perl
>to try to get the data from the web into Access. If you know Access, it
>trashes about 30% of the new data and then tells me little more than,
>'Oops!'
>
>I just need to start again and build a database on the web and the
>office will just have to use their browsers instead of Access. What
>should I start with?
>
>1. Needs to be easy (I'm no pro yet and we are in a hurry)
>2. Needs to handle about 100 fields
>3. Needs to handle about 100 new records per day now while I figure it
>out
>4. Needs to be able to handle 1000 new records per day
>5. Needs to not be too complicated to tie into other tables in querries
>6. It would be real nice (but not necessary) if Access already exports
>to it
>
>Thanks,
>
>John T. Jarrett
>
>
>
------------------------------
Date: 24 Nov 1998 15:37:06 -0500
From: ziggy@panix.com (Adam Turoff)
Subject: Re: Opinion Please: DB to start with
Message-Id: <73f5di$hhn@panix.com>
John T. Jarrett <jjarrett@ecpi.com> wrote:
>Expert opinion please:
>
>Got an Access database in the office, Unix servers on the web and Perl
>to try to get the data from the web into Access. If you know Access, it
>trashes about 30% of the new data and then tells me little more than,
>'Oops!'
Expert opinion:
Don't use Access. You won't have the wsiwyg bugs Access gives you,
but you'll have reliable data storage. Which is more important?
Pretty meaningless pictures on the screen or data management?
*>ANYTHING<* would be better than Access. If you want something fully
relational, take a look at using MySQL or PostgreSQL on your *nix boxen
and viewing the data through an ODBC connection in Access. I think
they both support some level of ODBC these days.
>I just need to start again and build a database on the web and the
>office will just have to use their browsers instead of Access. What
>should I start with?
>
>1. Needs to be easy (I'm no pro yet and we are in a hurry)
>2. Needs to handle about 100 fields
>3. Needs to handle about 100 new records per day now while I figure it
>out
>4. Needs to be able to handle 1000 new records per day
>5. Needs to not be too complicated to tie into other tables in querries
>6. It would be real nice (but not necessary) if Access already exports
>to it
1000 recs/day =~ 40 recs/hour =~ 1 record every 90 seconds. Of course, your
usage is not going to be evenly distributed over 24 hours, but this kind
of throughput doesn't require anything massively high-end. A simple
solution should work just fine.
Berkeley DB (use DB_File;) and even text files are a reasonable solution
at this scale (make sure you use lock files!) but won't be viewable on your
Win* boxen through Access. Of course, you could always write a few
more CGI scripts to view your data and not even deal with M$. :-)
Worst case, you might want to take periodic snapshots of your live
data and import it into Access on a regular basis (nightly/hourly).
That would give you data reliability and pretty meaningless pictures.
Z.
------------------------------
Date: 24 Nov 1998 14:25:13 -0600
From: ben@sofnet.com (BenJamin Prater)
Subject: Parsing solution needed...
Message-Id: <365b141e.2927364@news.sofnet.com>
I'm looking for a module that will take this:
$aq = Module->new( foo => \&foo,
bar => \&bar);
$aq->parse($buf);
when $buf looks like:
<foo item="2">Que esta fubara<bar state="5" color="white">Ciesta la
vie</bar></foo>
And call the respective subs in the current package with any
additional info from the tags dumped along with it.
Is XML::Parser what I'm looking for, or is there something better
suited for this parsing job?
Ben Prater
------------------------------
Date: Tue, 24 Nov 1998 13:28:14 -0600
From: Hooptie <harper2@gte.net>
Subject: Probably a simple question about hashes
Message-Id: <73f143$5sr$1@news-2.news.gte.net>
Howdy all,
Im trying to make a hash where each element is a state's name and
the key is its abbreviation, and then use the abbreviation to look up
the actual state such as:
%states = qw (
TX Texas
OK Oklahoma
NM New Mexico);
print "$states{$state_abbrev}\n";
This works fine for one word states (Texas), but not for 2 word states
(New Mexico). I can get it work like this:
%states = qw (
TX Texas
NM New_Mexico);
$new_state = $states{$state_abbrev};
$new_state=~ s/_/ /g;
print "$new_state";
but, I was hoping there was a more elegant solution.
Am I hoping in vain?
Harper
------------------------------
Date: 24 Nov 1998 19:31:15 GMT
From: eln@cyberhighway.net (Erik)
Subject: Re: Probably a simple question about hashes
Message-Id: <73f1i3$mmg$1@news.cyberhighway.net>
[Posted and mailed]
In article <73f143$5sr$1@news-2.news.gte.net>,
Hooptie <harper2@gte.net> writes:
> Howdy all,
> Im trying to make a hash where each element is a state's name and
> the key is its abbreviation, and then use the abbreviation to look up
> the actual state such as:
>
> %states = qw (
> TX Texas
> OK Oklahoma
> NM New Mexico);
> print "$states{$state_abbrev}\n";
qw() quotes a word list, ie, separates on whitespace. This is bad for this
case. Try something like:
%states = (
TX => "Texas",
OK => "Oklahoma",
NM => "New Mexico",
etc.
Should work a bit better.
HTH!
> Am I hoping in vain?
There's no such thing in Perl.
--
Erik Nielsen, Cyberhighway Internet Services NOC
When you need a helpline for breakfast cereals, it's time to start thinking
about tearing down civilisation and giving the ants a go.
-- Chris King in a.s.r.
------------------------------
Date: 24 Nov 1998 14:39:43 -0500
From: Uri Guttman <uri@fastengines.com>
To: Hooptie <harper2@gte.net>
Subject: Re: Probably a simple question about hashes
Message-Id: <sar7lwkani8.fsf@camel.fastserv.com>
>>>>> "H" == Hooptie <harper2@gte.net> writes:
H> %states = qw (
H> TX Texas
H> NM New Mexico);
H> %states = qw (
H> TX Texas
H> NM New_Mexico);
H> $new_state = $states{$state_abbrev};
H> $new_state=~ s/_/ /g;
this is not a hash problem but a qw problem. qw splits on white space
and makes a list of the tokens so two word states break your hash
initialization. use quoted strings instead and you will be fine:
%states = (
'TX' => 'Texas',
'NM' => 'New Mexico',
);
of course many will object to my gratuitous use of quotes for the key
tokens but i don't like visible barewords. for those rare cases when the
key is a perl func and you can't figure it out, this helps too.
hth,
uri
--
Uri Guttman Fast Engines -- The Leader in Fast CGI Technology
uri@fastengines.com http://www.fastengines.com
------------------------------
Date: Tue, 24 Nov 1998 14:45:50 -0500
From: "Allan M. Due" <Allan@due.net>
Subject: Re: Probably a simple question about hashes
Message-Id: <73f24e$221$1@camel18.mindspring.com>
Hooptie wrote in message <73f143$5sr$1@news-2.news.gte.net>...
>Howdy all,
> Im trying to make a hash where each element is a state's name and
>the key is its abbreviation, and then use the abbreviation to look up
>the actual state such as:
>
>%states = qw (
> TX Texas
> OK Oklahoma
> NM New Mexico);
>print "$states{$state_abbrev}\n";
>This works fine for one word states (Texas), but not for 2 word states
>(New Mexico). I can get it work like this:
>%states = qw (
> TX Texas
> NM New_Mexico);
>$new_state = $states{$state_abbrev};
>$new_state=~ s/_/ /g;
>print "$new_state";
>but, I was hoping there was a more elegant solution.
>Am I hoping in vain?
>Harper
How wedded to the notion of qw() are you? I would normally:
%states = (TX => 'Texas',
OK => 'Oklahoma',
NM => 'New Mexico');
which is more elegant to my way of thinking, but esthetics are so personal.
AmD
------------------------------
Date: Tue, 24 Nov 1998 12:01:47 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Probably a simple question about hashes
Message-Id: <MPG.10c4b088c47b21b198988f@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <73f143$5sr$1@news-2.news.gte.net> on Tue, 24 Nov 1998
13:28:14 -0600, Hooptie <harper2@gte.net> says...
> Im trying to make a hash where each element is a state's name and
> the key is its abbreviation, and then use the abbreviation to look up
> the actual state such as:
>
> %states = qw (
> TX Texas
> OK Oklahoma
> NM New Mexico);
> print "$states{$state_abbrev}\n";
>
> This works fine for one word states (Texas), but not for 2 word states
> (New Mexico). I can get it work like this:
>
> %states = qw (
> TX Texas
> NM New_Mexico);
> $new_state = $states{$state_abbrev};
> $new_state=~ s/_/ /g;
> print "$new_state";
>
> but, I was hoping there was a more elegant solution.
How about giving up on 'qw' for this purpose?
%states = (
TX => 'Texas',
OK => 'Oklahoma',
NM => 'New Mexico',
);
The fancy arrow takes care of quoting the left-hand sides, and you quote
the right-hand sides yourself.
I put a comma on the last line also, in case Puerto Rico ever makes it.
:-) [Really for symmetry and uniformity.]
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 24 Nov 1998 14:40:15 -0600
From: "Geir Sjurseth" <geir_sjurseth@dell.com>
Subject: Re: Probably a simple question about hashes
Message-Id: <73f52u$2cq$1@obsidian.us.dell.com>
Try putting New Mexico in quotes "New Mexico" or single quotes depending on
whats appropriate
Geir
Hooptie wrote in message <73f143$5sr$1@news-2.news.gte.net>...
>Howdy all,
> Im trying to make a hash where each element is a state's name and
>the key is its abbreviation, and then use the abbreviation to look up
>the actual state such as:
>
>%states = qw (
> TX Texas
> OK Oklahoma
> NM New Mexico);
>print "$states{$state_abbrev}\n";
>
>This works fine for one word states (Texas), but not for 2 word states
>(New Mexico). I can get it work like this:
>
>%states = qw (
> TX Texas
> NM New_Mexico);
>$new_state = $states{$state_abbrev};
>$new_state=~ s/_/ /g;
>print "$new_state";
>
>but, I was hoping there was a more elegant solution.
>Am I hoping in vain?
>
>Harper
>
------------------------------
Date: Tue, 24 Nov 1998 14:10:36 -0600
From: Tk Soh <r28629@email.sps.mot.com>
To: Hooptie <harper2@gte.net>
Subject: Re: Probably a simple question about hashes
Message-Id: <365B12BC.BB58344A@email.sps.mot.com>
[posted to c.l.p.m and copy emailed]
Hooptie wrote:
>
> Howdy all,
> Im trying to make a hash where each element is a state's name and
> the key is its abbreviation, and then use the abbreviation to look up
> the actual state such as:
>
> %states = qw (
> TX Texas
> OK Oklahoma
> NM New Mexico);
> print "$states{$state_abbrev}\n";
>
> This works fine for one word states (Texas), but not for 2 word states
> (New Mexico). I can get it work like this:
>
> %states = qw (
> TX Texas
> NM New_Mexico);
> $new_state = $states{$state_abbrev};
> $new_state=~ s/_/ /g;
> print "$new_state";
>
> but, I was hoping there was a more elegant solution.
the problem is not with hash but qw(). qw() basical splits up whatever
you put into a list of words with space as delimiter. Probably no the
best, but one quick suggestion is to do this:
%state = map {tr/_/ /; $_} qw ( TX texas NM New_Mexico);
HTH.
-TK
------------------------------
Date: Tue, 24 Nov 1998 15:58:42 -0500
From: "Allan M. Due" <Allan@due.net>
Subject: Re: Probably a simple question about hashes
Message-Id: <73f6d7$rrm$1@camel18.mindspring.com>
Geir Sjurseth wrote in message <73f52u$2cq$1@obsidian.us.dell.com>...
>Try putting New Mexico in quotes "New Mexico" or single quotes depending
on
>whats appropriate
>
Hmm, I just have to ask, did you try it before you suggested it? Did you
notice that we end up with states named either `New or "New? And what
about that dang "Odd number of elements in the hash list" message we get?
Oh well.
AmD
>Geir
>Hooptie wrote in message <73f143$5sr$1@news-2.news.gte.net>...
>>Howdy all,
>> Im trying to make a hash where each element is a state's name and
>>the key is its abbreviation, and then use the abbreviation to look up
>>the actual state such as:
>>
>>%states = qw (
>> TX Texas
>> OK Oklahoma
>> NM New Mexico);
>>print "$states{$state_abbrev}\n";
>>
>>This works fine for one word states (Texas), but not for 2 word states
>>(New Mexico). I can get it work like this:
>>
>>%states = qw (
>> TX Texas
>> NM New_Mexico);
>>$new_state = $states{$state_abbrev};
>>$new_state=~ s/_/ /g;
>>print "$new_state";
>>
>>but, I was hoping there was a more elegant solution.
>>Am I hoping in vain?
>>
>>Harper
>>
>
>
------------------------------
Date: Tue, 24 Nov 1998 12:40:27 -0800
From: Greg Coit <gbc1@axe.humboldt.edu>
Subject: Question about $_
Message-Id: <365B19BA.15DFF31D@axe.humboldt.edu>
I'm writing a script that searches recursively through a directory and
reads info from files with a certain name (text.html in this case). I'm
also trying to use $_ as much as possible to improve readability and my
skills. I have written this test script (included below) to make sure I
understand how $_ works. The first print statement prints a "text.html"
for every text.html file found. That's what I expect. But the second
print statement also prints a "text.html", but I would have thought that
the <FILE> statement would have replaced $_ with the text on the first
line of the file. I would appreciate any info that explains why this
script doesn't produce what I thought it would:
find(\&get_page_info, '/path/to/files');
sub get_page_info
{ if (/text\.html/)
{ print; #Expect and receive
"text.html" here.
open (FILE, "text.html") || die ("Can't open: $!\n");
<FILE>;
print; #Expect contents of <FILE>
but get "text.html" instead.
#do some more stuff here and then close file...
close (FILE);
}
}
Thanks,
Greg Coit
gbc1@axe.humboldt.edu
------------------------------
Date: Tue, 24 Nov 1998 14:27:43 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Question from a mega-geek
Message-Id: <comdog-ya02408000R2411981427430001@news.panix.com>
Jonathan Stowe <gellyfish@btinternet.com> wrote:
> I think that the Perl Mongers t-shirt has a bug in it - I have been wearing
> one quite frequently for nearly three weeks now and no-one has come up to me
> and said "Me too, I'm a Perl Programmer". Is this really a bug or have I
> missed some configuration option ?
our crack team of chemists are working on isolating the Perl hacker phermone [*]
from our Perl hacker capture and release program. once we have the phermone
extract, we will weave specially coated threads into the t-shirt.
[*] so far all attempts have been contaminated with Scotch or Peach Margaritas.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Tue, 24 Nov 1998 19:41:41 GMT
From: kapass@wnt.sas.com (Kathy Passarella)
Subject: Range operator
Message-Id: <365b0a3a.537381653@newshost.unx.sas.com>
The following example is from Learning Perl, page 49:
(1.2 .. 5.2) # same as (1.2, 2.2, 3.2, 4.2, 5.2)
but when I use
@list = (1.2 .. 5.2);
@list gets ( 1, 2, 3, 4, 5)
Can someone explain why?
------------------------------
Date: Tue, 24 Nov 1998 14:14:37 -0500
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: Returning to a previous URL from a CGI script
Message-Id: <MPG.10c4cfa574fc75b8989735@news.scescape.net>
[Followups set]
In article <73eta8$9nr1@shark.ncr.pwgsc.gc.ca>, brian.gaber@pwgsc.gc.ca
says...
[snip]
=> Thanks for the answer. I thought of that. I thought there might be a way
=> to capture the URL and then create a HREF for it.
The main problem isn't really finding out where the person came from, but
rather the link it's self. Your not creating a 'back' button, you are
creating a forward link to where the person came from. See?
Abigail's page explains it quite well, and is well worth the look.
...
Oh my, both of (that I know of) Abigail's pages are gone. Hmm...
Anyway,
HTH!
=> Brian
--Matthew
------------------------------
Date: 24 Nov 1998 17:29:45 GMT
From: eln@cyberhighway.net (Erik)
Subject: Re: Stupid question: Script never terminates?
Message-Id: <73eqe9$gvk$1@news.cyberhighway.net>
In article <sfr62.1550$oa2.2059507@news3.atl>,
abe@abe.com (Abe) writes:
> I wrote a new script, and my server admin tells me it's been running for
> 4 hours straight because it doesn't terminate correctly. I know it's a
> stupid question, but what kind of things would cause the script to not
> terminate?
Any number of things...posting some code would probably help if you want
a more specific answer.
--
Erik Nielsen, Cyberhighway Internet Services NOC
Call me a nut. Call me a crazy dreamer. I would just like someone to write
*ONE* OS that didn't insist on driving admins bugfuck on a regular basis.
-- Mark Stapleton in a.s.r.
------------------------------
Date: Tue, 24 Nov 1998 15:35:40 -0500
From: "Abukar Mohamed" <abukar@insidewire.com>
Subject: Trying to write perl script that zips file
Message-Id: <365b187e.0@diana.idirect.com>
Hi.
I am trying to write a perl script that zips a file that resides on my
server. Someone tried to help me and suggest to include this code:
use strict;
#To make sure multiple tests dont infulence each other
unclink($outfile);
@args = ("$program","$outfile","$infile");
$rc = system(@args);
print "return value = $rc\n";
print " file $outfile exists" if (-f $outfile);
Yet, I got these errors!
Global symbol "infile" requires explicit package name at
/u/web/roomm1/cgi-local/zipfile.cgi line 18.
Global symbol "outfile" requires explicit package name at
/u/web/roomm1/cgi-local/zipfile.cgi line 19.
Variable "$outfile" is not imported at /u/web/roomm1/cgi-local/zipfile.cgi
line 21.
Global symbol "outfile" requires explicit package name at
/u/web/roomm1/cgi-local/zipfile
Any Help would be greatly appretiated.
Abukar
------------------------------
Date: Tue, 24 Nov 1998 19:36:48 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Why doesn't something work?
Message-Id: <365c0a88.1036215@news.skynet.be>
Jonathan Feinberg wrote:
>> #---> Why doesn't %totals_info = ( $1 => $2 ) work?
>
>> If I try the code as indicated above I get *one* entry in totals_info.
>
>Well, of course: you're reinitializing the hash each time through the
>loop with the code that "doesn't work". You're saying "set the hash
>%totals_info to the list ($1, $2)", which is quite different from
>saying "set $totals_info{$1} to $2".
You can MAKE it work by doing it this way:
%totals_info = ( %totals_info, $1 => $2 );
but I bet it's a very inefficient way to do it.
Bart.
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 4288
**************************************