[7252] in Perl-Users-Digest
Perl-Users Digest, Issue: 877 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 16 00:37:46 1997
Date: Fri, 15 Aug 97 21:00:22 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 15 Aug 1997 Volume: 8 Number: 877
Today's topics:
Accessing lexical (my) variables in other frames from t <lali@imhps.im.se>
Re: Any nice "Powered by Perl" gifs? (Scott Maxwell)
Anyone use study function? <rapark1@pop.uky.edu>
Re: Anyone use study function? <rootbeer@teleport.com>
Associative Arrays called as Variables (better subject, <ptrainor@aura.title14.com>
Compile error... (Chris Sherman)
Re: convert a Perl AV* (containing strings) to a C char (Stephen McCamant)
Environment variables :LC_CTYPE , LC_ALL...??? <devonc@inetnebr.com>
Re: GET and POST limits <petri.backstrom@icl.fi>
Re: HELP! Full-text search in large DB <bri@mojo.calyx.net>
How can I make traceroute CGI? stormshield@hotmail.com
Re: Java or CGI password protect a web (Christian Roy)
Re: modules??? <zenin@best.com>
Re: mssql to perl question (Danny Aldham)
Re: Need help accessing tty modem devices within perl!! <pfeifer@ls6.informatik.uni-dortmund.de>
Re: Net::FTP documentation and examples <zenin@best.com>
Re: Newbie-type question <stuartc@ind.tansu.com.au>
Re: Newbie-type question <rootbeer@teleport.com>
Perl 4 mSQL queries <arabung@acm.vt.edu>
Perl 5 for DOS? (Kenton E. Sinner)
Re: perl5 regexes slower than perl4? (Ilya Zakharevich)
Problem parsing a 200 MB file on NT Perl 5 (Peter Xihong Wang)
Win32::ODBC and Autoincrement Primary index? <Marty@capehatteras.net>
Writing To an Existing File <e.phillips@mindspring.com>
Re: Writing To an Existing File <rootbeer@teleport.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 15 Aug 1997 13:35:44 GMT
From: Lars Liljestad IMD <lali@imhps.im.se>
Subject: Accessing lexical (my) variables in other frames from the debugger
Message-Id: <yg1en7vefgv.fsf@imhps.im.se>
Hi,
Is there any way to do, or any plans to add support for, something like
the up command in gdb. That is a way to print lexical (declared with my)
variables in frames somewhere above in the call chain.
Perhaps the caller function could return something that made it possible
to access them.
Anybody heard any rumors (or is it already there and I can't find it)?
Lars Liljestad
------------------------------
Date: 16 Aug 1997 00:20:02 GMT
From: maxwell@natasha.jpl.nasa.gov (Scott Maxwell)
Subject: Re: Any nice "Powered by Perl" gifs?
Message-Id: <MAXWELL.97Aug15172002@yoda.jpl.nasa.gov>
In article <5rmbfb$rpf$1@news2.voicenet.com> nospam@domain.com writes:
> Has anyone ever seen any nice "Powered by Perl" gifs?
> (Maybe with a really muscular-looking camel...)
I searched Lycos (http://www.lycos.com/) for pictures, giving it the
search string "powered by perl," and got at least two different images
(several Lycos hits seem to be the same image). I prefer this one:
http://jhuniverse.hcf.jhu.edu/HAC/images/perl-power.gif
Enjoy!
--
-------------------------+-----------------------------------------------------
// Scott Maxwell: | ``All labor that uplifts humanity has dignity and
\\// maxwell@ | importance and should be undertaken with painstaking
XX natasha.jpl.nasa.gov | excellence.'' -- Martin Luther King, Jr.
------------------------------
Date: 16 Aug 1997 00:41:46 GMT
From: Richard Allen Parks <rapark1@pop.uky.edu>
Subject: Anyone use study function?
Message-Id: <5t2t0a$5os$1@gte1.gte.net>
Has anyone had noticably faster processing using the study function?
My algorithm searches an input string, say ABCDEFGHIJ, for substrings of
varying lengths.
I tried using study($var) where var is the ABC... and my computation
time did not decrease any.
I am wanting to search the string as quickly as possible and I want the
location of the character matches to be pushed on an array. Other than
using for loops and substr searches, I can think of no other way. Is
there some new function I could use. I think index and rindex just
return the first position of the match.
Does anyone have any suggestions?
Thanks a bunch,
Rick Parks
------------------------------
Date: Fri, 15 Aug 1997 18:20:15 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Richard Allen Parks <rapark1@pop.uky.edu>
Subject: Re: Anyone use study function?
Message-Id: <Pine.GSO.3.96.970815181741.14848K-100000@julie.teleport.com>
On 16 Aug 1997, Richard Allen Parks wrote:
> Has anyone had noticably faster processing using the study function?
If you're really interested in it, you should see what Jeffrey Friedl says
about it in the "hip owls" book, also known as "Mastering Regular
Expressions". Worth buying.
> I am wanting to search the string as quickly as possible and I want the
> location of the character matches to be pushed on an array.
> I think index and rindex just return the first position of the match.
You could use the three-argument form of index to find more than one
match. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 15 Aug 1997 22:05:01 -0400
From: Pat Trainor <ptrainor@aura.title14.com>
To: Anagrams of the Word 'A' <jefpin@bergen.org>
Subject: Associative Arrays called as Variables (better subject, eh?!)
Message-Id: <Pine.LNX.3.95.970815212011.25130D-100000@aura>
On Fri, 15 Aug 1997, Anagrams of the Word 'A' wrote:
> > $a="SECT_" . $SECTION . "_CHOICES";
> > print $a; yields:
> > SECT_0001
>
> It works with Perl4 and Perl5 here...
> just try:
> $a = "SECT_${SECTION}_CHOICES";
>
> That should work.
That is very useful!!!
I'll post the answer/fix to my dillemna to the newsgroup as well, but I found
out that this:
(Used to parse variables passed from the last time the script was executed. You
see, I am containing the entire system in one .pl file. Each execution/pass makes a call
to the same script-passing new variables to itself based on user choices.)
#############################################
if (&parse_input(*fields)) {
$SECTION=$fields{'SECTION'};
$SUB=$fields{'SUB'};
$ITEM=$fields{'ITEM'};
}
#############################################
Early on in my script prevented subsequent calls to these "variables" from
outputting correctly. I ran your nifty code:
if ($SECTION =~ /^\d\d\d\d$/) {
print "SECTION '$SECTION' is good.<br>\n";
} else {
print "SECTION '$SECTION' has bad data!<br>\n";
}
..and found that indeed the variables were being parsed in the format I had
expected, but still "nulled" out whatever was after that variable. The 'fix' was to
remove the first call to those variables. I have a feeling that I am battling local and
global variables-that is- variables that do not either go into/out of subroutines. I'm
afraid I have a few subroutines to control program flow.
Why would I be doing such a bizzarre variable call? The reason is that I need to
have a variable as a call to an associative array. Now I've gone through the books in
tremendous detail all afternoon, and none of them deals with having variables as
associative arrays. Not the keys or values, but rather the actual name assigned to the
array. There is, of course, a slight possibility it's right in front of me :) !
Let me show you an example of what is holding me up on a really exciting (to me)
first programming attempt:
########################################
dbmopen (%SECT_$SECTION_CHOICES,"sect_$SECTION_choices.db",0600);
dbmopen (%SECT_$SECTION_DESCRIPTIONS,"sect_$SECTION_choices_descriptions.db",0600);
foreach (sort keys %SECTION_$SECTION_CHOICES ) {
print "<a href="$baseFAQ.pl/2?SECTION=$SECTION&SUB=$_"> ${SECT_$SECTION_CHOICES}{$_} </a> ";
print "$SECT_$SECTION_DESCRIPTIONS{$_} <br>";
$nextsub="$_";
}
[...]
(I took out the \'s to make it more readable.)
########################################
This sample of unintelligible code is _supposed_ to create an associative array
name that is a variable, as well as calling the keys in 2 arrays based on that same
variable.
Unfortunately this extremely important few lines are at the base of my program.
I had mentioned this before in the newsgroup, but I want the code to produce URLs and
descriptions to STDOUT based on what is in DBM arrays that are called by variables.
Doing this makes the code extremely small, and I seem to be in a rut (all day)
making a call via a %xxxx assoc. array call that has to be a variable as in the above:
dbmopen (%SECT_$SECTION_CHOICES...).
I'm looking at the globbing/aliases in local(), but that doesn't readily appear
to be a fix.
Any ideas really appreciated! After all, it's only my first program! It reminds
me of rebuilding my bathroom-I felt I could do any other room in the house easily once I
got done with the bathroom! Maybe after this program, all others will seem easy as well!
Thanks in advance!!! :)
pat
:)
ptrainor@aura.title14.com
http://www.title14.com/resume
#$reality=$bandwidth!=spam;
"While it's true winning isn't everything-LOSING IS NOTHING!" -Ed Bighead
------------------------------
Date: Fri, 15 Aug 1997 17:06:59 GMT
From: sherman@unx.sas.com (Chris Sherman)
Subject: Compile error...
Message-Id: <EEysvn.BBH@unx.sas.com>
>From pp.h, there is this following #define:
#define RvDEEPCP(rv) STMT_START { SV* ref=SvRV(rv); \
if (SvREFCNT(ref)>1) { \
SvREFCNT_dec(ref); \
SvRV(rv)=AMG_CALLun(rv,copy); \
} } STMT_END
The compiler on my machine has no idea what to make of the "copy" symbol
in the above macro.
I get the following error from the HP/UX (cc) compiler:
"gv.c", line 1327: 'copy' undefined
"gv.c", line 1327: syntax error
*** Error code 1
This is what gcc says about it:
gv.c: In function `Perl_amagic_call':
gv.c:1327: `copy' undeclared (first use this function)
gv.c:1327: (Each undeclared identifier is reported only once
gv.c:1327: for each function it appears in.)
gv.c:1327: parse error before `_amg'
I can't find any other mention of "copy" in perl's sources. (There's COPY,
Copy, mg_copy, COPY16, COPY32, sv_mortalcopy, etc). But no "copy".
Can anyone help???
Thanx!
--
____/ / / __ / _ _/ ____/
/ / / / / / / Chris Sherman
/ ___ / _/ / /
_____/ __/ __/ __/ _\ _____/ _____/ sherman@unx.sas.com
--
____/ / / __ / _ _/ ____/
/ / / / / / / Chris Sherman
/ ___ / _/ / /
_____/ __/ __/ __/ _\ _____/ _____/ sherman@unx.sas.com
------------------------------
Date: 16 Aug 1997 01:11:46 GMT
From: stephen@alias-2.pr.mcs.net (Stephen McCamant)
Subject: Re: convert a Perl AV* (containing strings) to a C char**
Message-Id: <slrn5v9vf4.tko.stephen@alias-2.pr.mcs.net>
On Thu, 14 Aug 1997 15:16:31 -0500,
John Tucker <jatucker@austin.dsccc.com> wrote:
>I have many C functions which I am using with perlxs to
>create an extension package for my perl scripts.
>
>All of the C functions have at least one argument which
>requires a non-empty "char**" parameter and I would like
>to allow perl scripts which use my package to call the
>routine with a perl array variable as the arguement
>which I can then have converted into the expected
>C char** target data type.
>
>Is there some generic utility library out there which
>is full of common conversion routines which I can use,
>and if not, then how do you do it.
XS's typemap is a form of generic utility library, though it doesn't include
what you need. You might also want to try SWIG
(http://www.cs.utah.edu/~beazley/SWIG/swig.html), which is like XS but in
some ways more powerful (and includes backends for many different scripting
languages).
If you have an AV*, you can find the number of elements in it with the
av_len() function, retrieve the elements with av_fetch(), convert them to
`char *'s using SvPV() (all these functions are described in perlguts(1)),
and put them in a malloc()d array. If the C function modifies the strings,
you'll want to pass copies of the values from the array.
--
____________________________________________________________
Stephen McCamant ======== alias@mcs.com (finger for PGP key)
------------------------------
Date: Fri, 15 Aug 1997 19:34:52 -0500
From: Devon Caines <devonc@inetnebr.com>
Subject: Environment variables :LC_CTYPE , LC_ALL...???
Message-Id: <33F4F5AC.47108A99@inetnebr.com>
Hi guys
this is probably a NEWBY question.. but not fount in the FAQ's
when I first upgraded perl to 5.003 I kept getting these warnings...
I guess I reinstalled Linus sometime and that dissapeared........ but
suddenly they have reappeared and to my knowledge nothing has
changed.....
Need help.. Advise
-warning setlocale(LC_CTYPE," ") failed
-warning LC_ALL = "(null)", LC_CTYPE = "(null)", LANG = "US";
-warning falling back to the "C" locale;
AWAITING ----the "gods" replies
DevonC
--
--------------------------------------------------------------
C'ing is leaving the BASIC's behind | devonc@inetnebr.com |
C++ ing walking by faith and not by sight): | |
--------------------------------------------------------------
------------------------------
Date: Wed, 13 Aug 1997 23:28:22 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: GET and POST limits
Message-Id: <33F218E6.BA@icl.fi>
David Cheitel wrote:
>
> What are the limits on url size that can be passed via a get and a post. I am
> working on a online testing program and need to pass the users answers to 50
> questions as well as the question numbers themselves (the test is randomly
> generated and questions vary.)
>
> What is the best way to pass such a large amount of information in a form
> submission?
Use POST (and use CGI.pm).
If you use GET, you're limited by the length allowed for environment
variables by your web server operating system.
For HTTP/CGI limitations in general, see the specs:
http://www.w3.org/Protocols/Specs.html
http://www.ast.cam.ac.uk/~drtr/cgi-spec.html
CGI.pm is at:
http://www-genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.htm
regards,
...petri.backstrom@icl.fi
ICL Data Oy
Finland
------------------------------
Date: 16 Aug 1997 00:52:55 GMT
From: Sol Lightman <bri@mojo.calyx.net>
Subject: Re: HELP! Full-text search in large DB
Message-Id: <5t2tl7$oga@cdc2.cdc.net>
Secret Squirrel <nobody@secret.squirrel.owl.de> wrote:
: This is a bibliographic database, and it is crucial that users be able
: to search the full text of certain fields such as Keywords, Abstract,
: and Comments. Can someone please tell me what is the standard
: approach to this problem, and whether there is anything out there that
: I can use to speed up a Perl implementation of this?
Use glimpse/agrep structured queries with a perl wrapper. This should
be fast and powerful as long as the database is not constantly being
modified (you'd have to re-index it each time).
http://glimpse.cs.arizona.edu
--
Brian S. Julin
------------------------------
Date: Fri, 15 Aug 1997 21:11:18 -0600
From: stormshield@hotmail.com
Subject: How can I make traceroute CGI?
Message-Id: <871697025.9202@dejanews.com>
I want to know how to make traceroute CGI or JAVA for my homepage.
Please visit these websites which support traceroute in homepage.
http://www.csu.net/cgi-bin/trace
http://counter.boardwatch.com/cgi-bin/trace?
And it's said that they used CGI source from
http://www.carpe.net/src/index.html
However, I don't understand how to use it in my homepage. I want to add
traceroute menu in my homepage so that Netizens from abroad can know how
they're connected to my homepage.
Can you please explain how to use those source codes or how to make a new
CGI to traceroute? I know little about UNIX. My homepage server is;
Connected to 203.236.128.1.
Escape character is '^]'.
UNIX(r) System V Release 4.0 (orange)
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Fri, 15 Aug 1997 19:48:40 GMT
From: roychri@total.net (Christian Roy)
Subject: Re: Java or CGI password protect a web
Message-Id: <33f4b173.159414481@news.total.net>
On Thu, 14 Aug 1997 09:41:46 -0400, Nick Marcantonio
<marcan@notes.nu.com> wrote:
>I've been looking for a way to password protect a highly confidential
>web that I've done. I've played with many self-written and downloadable
>Java and CGI scripts, but none seem to be truly effective. If you know
>of a sure fire way to password protect a web, it would be greatly
>appreciated if you would share that with me. Please e-mail:
>marcan@nu.com with any info. I extend my thanks in advance.
Did you though of using .htaccess?
(http://www.he.net/info/htaccess/demo.html)
Your documents will be very well protected from any web access. But
that doesn't prevent people who have shell access to the same computer
to have acces to those files. If you are sharing the computer where
your files are, then you need to protect yourself using file
permissions which is not what this newsgroup is for. You need to ask a
guru of the operating system where your files are.
I Hope this helps.
------------------------------
Date: 16 Aug 1997 02:19:54 GMT
From: Zenin <zenin@best.com>
Subject: Re: modules???
Message-Id: <5t32oa$3ak$2@nntp2.ba.best.com>
Kurt <kurt@rfpi.com> wrote:
> I understand what CPAN is ( I think). It is a source of Perl modules to
> use with your Perl scripts. i have actually tried to go to some of the
> CPAN sites but quickly found myself lost. Is there any good
> documentation on it.
http://www.perl.com/perl/CPAN/CPAN.html
> Also, how does one actually use a module?
man perlmod
man perlmodlib
and again, http://www.perl.com/perl/CPAN/CPAN.html
> Is it something like this?
> require module;
Yes, of course this assumes that you've already installed it
in a location that perl knows to search for it. :)
> Or am I completely missing the point here?
No.
> Is the whole idea behind modules similiar to object orientated concepts?
Kinda yes, and kinda no. Perl modules can function as a class
complete with methods class and instance vars, etc. However it
doesn't have to be. Many modules are simply function libs. Others
still are pramas (compile time directives).
> Are there modules for creating web based databases that I can use with
> Perl and SQL?
Yes.
> Do all the modules have documentation that tell me how to install it,
> how to reference it, what it's purpose is, etc...?
Most do (see the file README that comes with almost
every one of them). The ones that don't should be deleted from
CPAN or labeled vary clearly as alpha code.
Once installed, you should (danger) be able to get to the
documentation by one or both of these:
man -M/usr/local/lib/perl5/man Module::Name
or better:
perldoc module::name
I prefer perldoc because it pulls the docs directly out
of the module itself (more likely up to date), is case intensive,
and knows to search all the standard perl lib directorys to find
the module. You can also give it partial names, such as if you
are looking for the docs for the module IPC::Open3, you can simply
type:
perldoc open3
and find it. Vary handy if, like me, you can't always remember off
hand that open3 is under the IPC set.
> Are databases nothing more than super Perl associative arrays?
Umm, no. DBM files are kinda like this, but not SQL and similar
databases. If you'd like, using what's known as a "tied class" in
perl, it would be posible to create a class that would make a two
level perl hash map directly to a single SQL table. This would
assume a strong background in perl5 and is not recommended for the
faint of heart. :-)
> Thanks for all your help?
Umm, odd question... :-)
Hope this helps!
--
-Zenin
zenin@best.com
------------------------------
Date: 15 Aug 1997 20:32:55 -0700
From: danny@lennon.postino.com (Danny Aldham)
Subject: Re: mssql to perl question
Message-Id: <5t3717$fs3$1@lennon.postino.com>
Edward Yeh (Eyeh@cris.com) wrote:
: where can I get the perl extensions to access
: a MS SQL server?
At any CPAN site, look for Win32odbc_v970208.readme and Win32odbc_v970208.zip
These modules really need the activeware port of perl, at www.activeware.com.
--
Danny Aldham SCO Ace , MCSE , JAPH , DAD
I don't need to hide my e-mail address, I broke my sendmail.
------------------------------
Date: 14 Aug 1997 16:48:21 +0200
From: Ulrich Pfeifer <pfeifer@ls6.informatik.uni-dortmund.de>
Subject: Re: Need help accessing tty modem devices within perl!!!
Message-Id: <yfm7mdokeh6.ulp@gretchen.informatik.uni-dortmund.de>
>>>>> "Aaron" == Aaron Sherman <ajs@lorien.ajs.com> writes:
Aaron> However, my first guess is that you want to open the modem
Aaron> read/write and read back the modem's output, like so:
Aaron> open(M,"+</dev/ttyA00")||die("modem: $!");
Aaron> print M "at\&b0\n";
Aaron> $reply = <M>;
You probably should use sysopen and friends when reading and writing
to the same file descriptor since otherwise you will get trapped
easily. This is a snippet of my 'dial' script (Too lazy to type
numbers in the phone ;-). Not that you check the result of system
calls ...
sysopen(MODEM, "/dev/$device", O_RDWR)
or die "Couldn't read/write open $device: $!\n";
$cmd = "ATZ\r\n";
syswrite(MODEM, $cmd, length($cmd)); # still need to check the result here
while (1) {
my $buf='';
sleep(1);
sysread(MODEM, $buf, 512); # still need to check the result here
print STDERR $buf;
$answer .= $buf;
last if $answer =~ /OK/i;
# some timeout handling needed here
}
close MODEM;
Ulrich Pfeifer
--
perl -e 'print map chr($_&=127), unpack "C*", pack "w", \
"28031325277245338375695089304165009203757780884355338"'
------------------------------
Date: 16 Aug 1997 02:24:08 GMT
From: Zenin <zenin@best.com>
Subject: Re: Net::FTP documentation and examples
Message-Id: <5t3308$3ak$3@nntp2.ba.best.com>
Tom Phoenix <rootbeer@teleport.com> wrote:
>snip<
> But if you can't fix perldoc, you should still be able to read the POD
> docs in Net::FTP with any text reader. (That is, open up the FTP.pm file
> and look for "=head". The docs follow that line.)
Or, hand hold perldoc and walk it directly to the module:
perldoc C:\full\path\to\my\perl5\lib\site_perl\Net\FTP.pm
If you still can't get the docs out of it that way, you've got a
broken copy of Net::FTP. I'd recommend downloading a new copy and
reinstalling, or just reading the docs in it.
Perl works under Win32, but it doesn't like it.
--
-Zenin
zenin@best.com
------------------------------
Date: 16 Aug 1997 10:49:11 +1000
From: Stuart Cooper <stuartc@ind.tansu.com.au>
Subject: Re: Newbie-type question
Message-Id: <yeou3grdkag.fsf@kudu.ind.tansu.com.au>
Jefferson Bell <jeffbell@uu.net> writes:
> I'm writing a program and I have a line where I say (well, actually I
> typed. not said):
>
> $studone[4]="$studone[4]".","."$adclassname";
>
> meaning of course "take what's in studone[4] and concatenate (I think
> that's the term) it with a , and another variable then assign it back to
> studone[4].
Concatenate it is, Jeff. However "add onto", "bung on", "whack in" etc
are perfectly acceptable. "Concatenate" is the word from which the
Unix "cat" program gets its name.
> Is there a way to say "if studone is empty than don't cat it with the
> comma just the variabel?
>
> I know you can use a standard if-then-elsif, but there has to be some
> other way of doing it that won't take up three or four lines.
>
> Jeff
You'd be wanting the trinary ?: operator.
$is_it_true? $yes: $no; ==
if ($is_it_true) {
$yes;
} else {
$no;
}
in your example you want not so much to append ,$adclassname or $adclassname
but to *prepend* "$studone[4]," to $adclassname if $studone[4] is set.
Here's an answer:
#! /usr/local/bin/perl -w
# $studone[4]="Hello";
# Try program with above line commented and uncommented
$adclassname="Classifieds";
$studone[4]= ( (defined($studone[4])? "$studone[4]," : "") .$adclassname );
print "elt is $studone[4]\n";
explaining the line where it all happens:
defined() checks if the element has been set: if it is the value of
the ?: expr becomes "Hello," otherwise the value of the expression is ""
this value then has $adclassname appended to it by the . operator;
the value of this expression is thus the string you want and thrown into
$studone[4] by the assignment.
Hope this helps,
Stuart Cooper
stuartc@ind.tansu.com.au
------------------------------
Date: Fri, 15 Aug 1997 18:02:43 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Jefferson Bell <jeffbell@uu.net>
Subject: Re: Newbie-type question
Message-Id: <Pine.GSO.3.96.970815175313.14848E-100000@julie.teleport.com>
On Fri, 15 Aug 1997, Jefferson Bell wrote:
> $studone[4]="$studone[4]".","."$adclassname";
That's a little easier to read if you write it like one of these. They're
functionally equivalent, although you might choose one or the other
depending upon the way you think about the problem. (Some are more
efficient than others.)
$studone[4] = "$studone[4],$adclassname";
$studone[4] .= ",$adclassname";
$studone[4] .= ',' . $adclassname;
> Is there a way to say "if studone is empty than don't cat it with the
> comma just the variabel?
There are other ways, but this one may work, unless $studone[4] might be
'0':
$studone[4] = $studone[4]
? "$studone[4],$adclassname"
: $adclassname ;
If you need to check that it's non-empty (rather than just false) that's
easily done when you understand how this one works. :-) Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 15 Aug 1997 14:57:40 -0700
From: Adam Rabung <arabung@acm.vt.edu>
Subject: Perl 4 mSQL queries
Message-Id: <33F4D0D4.167E@acm.vt.edu>
For mant stupid admin problems, I have access to perl
5, but can't compile the mSQL module. So, in the manner
of the wheel re-inventer, I use Perl 4 to interface the
mSQL interface. It's a big pain in the butt, but I've got
it going. The only problem is it's too slow.
I've yet to see a definition of the protocol the msqld uses,
so I just use system calls to msql. It returns my queries
in pretty table format, which I've got to chop down to
colon delimited form. I can do this, but parse 1100 records
takes 3 seconds- unacceptable in Web Time. The statement
that takes a lion's share of the time is
s/^\s*(.*?)\s*$/$1/;
I know this is a really stupid way to do things, but I'm just
trying to make the most of a stupid situation.
Thanks!
------------------------------
Date: 16 Aug 1997 00:55:49 GMT
From: ksinner@solaria.sol.net (Kenton E. Sinner)
Subject: Perl 5 for DOS?
Message-Id: <871692949.739282@smyrno.sol.net>
Has Perl 5 been ported to DOS yet? I heard of a beta release, but
not a stable one. If there is one, where can it be ftp'd from?
Since I would have to use ftpmail, please give host, full path,
and all relevant filenames, please.
Thanks greatly!
--
Single, white, Milwaukee-area male seeks non-smoking female.
Object: simple, honest, romantic relationship.
Are you caring, bright, humorous, sensuous, between 18 and 35 years old?
I am a computer programmer in my mid thirties.
Turn-ons: good food, pre-sputnik SF, roller coasters, and fast computers.
Turn-offs: taxes, voice mail menues, and politicians.
Send email if interested.
------------------------------
Date: 16 Aug 1997 00:47:58 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: perl5 regexes slower than perl4?
Message-Id: <5t2tbu$9cl@agate.berkeley.edu>
In article <5t2966$o1q$1@vixen.cso.uiuc.edu>,
Andrew Dalke <dalke@ks.uiuc.edu> wrote:
> I think I see where a point of confusion might be. I am not
> doing 300,000 iterations of the same string. I generated a
> string of length 300,000 letters and tested each of the 1,000
> or so regexs against it once, one at a time.
...
> (proof: the regexs I used can be implemented as a DFA without
> cycles so any test should take less than a fixed time. There are
> R regexs so if T is the max time for any regex then the string
> starting at position i takes at most R*T time. In a string of
> size N there are N possible start positions so the total time is
> proportional to N. See, that automata theory class was good for
> something after all. :)
I'm afraid not. This is irrelevant, since Perl does not work this
way.
If you spend so much time on it, a reproducible test case (with $& and
friends missing - there is a BIG known slowdown related to some bugs
corrected) is the best thing you can do.
My measurement show that somewhere close to 5.003 the RE engine was
slowed down approximately 30%. Two reason for slowdown are known
(after some guys found that their scripts started to work 10000 times
(yes!) slower) - it is
a) //i which disables constant substring optimizations
b) scalar context //g is horrible now: it copies the string *each
time*;
If your test case will reveal some new reasons for slowdown, it may be
fixed eventually (a fix for "a" was discussed many times, but
currently Perl development is in turmoil because threads are merged
in, which inhibits other changes; I have ideas how to fix "b", but it
requires some round tuits - new type of write magic is needed +
refcounting of saved copies).
(Note that *major* optimizations in the jumbo RE patch *hide* a lot of
slowdowns, so it is important they are fixed before the patch is
merged in the mainstream perl.)
Ilya
------------------------------
Date: 15 Aug 1997 23:28:26 GMT
From: pxwang@ishark.intel.com (Peter Xihong Wang)
Subject: Problem parsing a 200 MB file on NT Perl 5
Message-Id: <5t2omq$ekq$1@news.or.intel.com>
------------------------------
Date: Fri, 15 Aug 1997 13:01:50 -0400
From: "Marty" <Marty@capehatteras.net>
Subject: Win32::ODBC and Autoincrement Primary index?
Message-Id: <5t21ut$omf@redstone.interpath.net>
Im trying to add a record to a MS Access database with and autoincrement
index. For some reason I cant seam to get the syntax correct and keep
getting errors:
$db->Run("INSERT INTO userbase (Accept_Cookies, Email_ID, News_name,
Times_Accessed, User_Password, User_name,User_id) VALUES (1,
'Marty2capehatterasnet','Marty',1,'tiptop','Marty',3)");
gives:
Executing connection 1 SQL statement: "INSERT INTO userbase
(Accept_Cookies, Email_ID, News_name, Times_Accessed, User_Password,
User_name,User_id) VALUES (1,
'Marty2capehatterasnet','Marty',1,'tiptop','Marty',3)" Error:
"-1605[Microsoft][ODBC Microsoft Access 97 Driver] The changes you requested
to the table were not successful because they would create duplicate values
in the index, primary key, or relationship. Change the data in the field or
fields that contain duplicate data, remove the index, or redefine the index
to permit duplicate entries and try again.10" --------------------
or without reference to the primary index (User_id) we have:
$db->Run("INSERT INTO userbase (Accept_Cookies, Email_ID, News_name,
Times_Accessed, User_Pasword, User_name) VALUES (1,
'Marty2capehatterasnet','Marty',1,'tiptop','Marty')");
witch gives:
Executing connection 1 SQL statement: "INSERT INTO userbase (Accept_Cookies,
Email_ID, News_name, Times_Accessed, User_Password, User_name) VALUES (1,
'Marty2capehatterasnet','Marty',1,'tiptop','Marty')" Error:
"" --------------------
If I substitute anything besides a number including null I get a datatype
mismatch. What am I doing wrong??
I'm using the latest version of Win32 Perl (build 307) and ODBC and
everything
else seams to work fine.
(*)\||/(*)
| ~ ~ | Marty Poulin
( @ @ )
+-----oOOo-(<>)-oOOo------+-------------------------------------------+
| | There is an art, or rather a knack to |
| Marty@capehatteras.net | flying. The knack lies in learning how |
| http://wavemagnet.com | to throw yourself at the ground and miss. |
| Oooo. | |
+----.oooO------( )------|-------------------------------------------+
( ) (_/
\_)
------------------------------
Date: Fri, 15 Aug 1997 08:46:26 -0700
From: Eric Phillips <e.phillips@mindspring.com>
Subject: Writing To an Existing File
Message-Id: <33F479D2.A3DB88E3@mindspring.com>
Hello, I need some help. i am a beginner at Perl, and I need to know
something. How do I write to a page that already exists. I understand
the "open (TEMP_FILE, "<<temp_file.txt")" method, but how do I write
(say to the 45 line) of that file. Please let me know by E-Mailing me at
e.phillips@mindspring.com. Thanks!
--
--
Eric Phillips
e.phillips@mindspring.com
------------------------------
Date: Fri, 15 Aug 1997 18:22:13 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Eric Phillips <e.phillips@mindspring.com>
Subject: Re: Writing To an Existing File
Message-Id: <Pine.GSO.3.96.970815182033.14848L-100000@julie.teleport.com>
On Fri, 15 Aug 1997, Eric Phillips wrote:
> Subject: Writing To an Existing File
> I understand the "open (TEMP_FILE, "<<temp_file.txt")" method,
That's not quite what it is, but let's not let that stop us. :-)
> how do I write (say to the 45 line) of that file.
There's some good information in the FAQ.
http://www.perl.com/CPAN/doc/FAQs/FAQ/html/perlfaq5/
How_do_I_change_one_line_in_a_fi.html
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
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 877
*************************************