[11923] in Perl-Users-Digest
Perl-Users Digest, Issue: 5523 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 29 23:07:35 1999
Date: Thu, 29 Apr 99 20: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 Thu, 29 Apr 1999 Volume: 8 Number: 5523
Today's topics:
Re: "learning perl" does not seem to be written well (Jim Richardson)
Re: "learning perl" does not seem to be written well (Tad McClellan)
Re: a complex associative array problem du_bing@my-dejanews.com
Re: An explanation of sort <cassell@mail.cor.epa.gov>
Can't figure this one out... <portboy@home.com>
Checkbox is not working. jeffrey_f@my-dejanews.com
Re: Count Linenumber sstarre@my-dejanews.com
Dynamic binding problem clearway@my-dejanews.com
How to flush CGI output? (JUNYI J LIN)
importing a namespace from an arbitrary file sstarre@my-dejanews.com
Re: Is this the best way to get a substring? (Tad McClellan)
matching a quoted string (Jon)
Re: newbie q: compiling perl <cassell@mail.cor.epa.gov>
Re: PERL & Y2K (Sam Holden)
Re: pow() ? to the power of ? (Tad McClellan)
RegExs and question marks...a possible bug? <kenrose@home.com>
Re: RegExs and question marks...a possible bug? (Abigail)
Running Perl from Perl <jalil@corp.home.net>
Re: Running Perl from Perl (Andrew Allen)
search string syntax jgangemi@ccf.rutgers.edu
Re: search string syntax (Abigail)
Security:HowTo not pass UserID/Password as hidden varia <nichols@blarg.net>
Selecting a long with DBI/DBD Oracle <blavender@spk.usace.army.mil>
single quotation " erases REST OF TEXT NOSPAMcrstlblu@planet.eon.net
Re: single quotation " erases REST OF TEXT (Abigail)
Re: strict vs. Win32::Registry <homelessinseattle@my-dejanews.com>
Re: stupid single quote " wipes out REST OF TEXT (Sam Holden)
Telnetting from Unix to NT mabus67@my-dejanews.com
Re: Telnetting from Unix to NT <walton@frontiernet.net>
Re: What's wrong with this code? (Tad McClellan)
Re: Win32::OLE and Word <cassell@mail.cor.epa.gov>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 30 Apr 1999 01:34:56 GMT
From: warlock@eskimo.com (Jim Richardson)
Subject: Re: "learning perl" does not seem to be written well
Message-Id: <slrn7ifr4f.pp.warlock@gargoyle.myth>
On 26 Apr 1999 06:51:01 -0700,
Randal L. Schwartz, in the persona of <merlyn@stonehenge.com>,
brought forth the following words...:
>>>>>> "mikecard" == mikecard <mikecard@my-dejanews.com> writes:
>
>mikecard> i am only on page 13 and i am already getting aggrevated. the book introduces
>mikecard> the =~ operator in an example but never explains what it is (they just seem to
>mikecard> assume you'll figure it out, but since this is supposedly a book for beginners
>mikecard> NO assuptions should be made).
>
>Page 13 is still in chapter 1. You are reading through the brief
>runthrough of everything that appears in later chapters. It will be
>explained much more thoroughly later.
>
>Some people find the runthrough at "exactly the right overview" pace.
>If you're not, skip the rest of the runthrough, and go right to
>chapter 2.
>
>Perhaps I'll say it more explicitly in a future version of the
>book. :)
>
>print "Just another Perl [book] hacker,"
I'd like to say thay I like the book, I am new to perl. (some other scripting
experience, and hp fortran 77 a decade ago.) I have to struggle to wrap my
mind around some things, (when will I grok oop?)) But so far, I like "Learning
Perl" It has helped me with some actual tasks I needed done. I was able
to write a (crude perhaps) but simple script to manipulate some data from
a network analyzer, to calibrate some RF gear I use, my boss was amazed that
a process that used to take a week, takes an afternoon now. (admittadly,
most of the speed up is due to the new NA, but I'd still be chopping
away at the data if it hadn't been for perl and "learning perl".)
>
>--
>Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
>Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
>Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
>Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
>Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
--
Jim Richardson
www.eskimo.com/~warlock
All hail Eris
"Linux, where do you want to go tomorrow?"
------------------------------
Date: Thu, 29 Apr 1999 14:25:25 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: "learning perl" does not seem to be written well
Message-Id: <l68ag7.hf2.ln@magna.metronet.com>
Benjamin Franz (snowhare@long-lake.nihongo.org) wrote:
: In fact, the presence of the =~ operator and the grep
: function is *why* I chose to learn Perl - it let me quit
: using awkward chained calls to 'awk' and 'sed'.
Perl saved me from using lex and C to get the power of
regular expressions.
I will be eternally grateful...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 29 Apr 1999 21:13:39 GMT
From: du_bing@my-dejanews.com
Subject: Re: a complex associative array problem
Message-Id: <7gai1u$6rg$1@nnrp1.dejanews.com>
I fixed the problem myself.
Bing
In article <7gabtl$m7$1@nnrp1.dejanews.com>,
bing-du@tamu.edu wrote:
> Hello there,
>
> I expect the following code to give me the result like this:
>
> xxxx:
> ------
> xxxx: xxxx
> xxx: xx
> ....
> xxx:
> ------
> xxxx: xxx
> xxx: xx
> ...
> ...
>
> But I just got the above result inside 'sample' subroutine (if those comments
> were removed) but not outside.
> The print statements outside 'sample' only showed me the first level keys:
> It seemed the associative array was constructed and displayed inside the
> subroutine. Just when it was passed out, something wrong happened.
>
> xxxx:
> -----
> xxx:
> -----
> "-w" option did not show me any hints.
>
> How to fix this problem?
>
> Any idea and suggestion would be greatly appreciated.
>
> Bing
> ------------------------------------------------------
> #!/usr/local/bin/perl -w
>
> my ($a,$b,%out);
>
> %out = &sample;
> foreach $a (keys %out)
> {
> print "$a:\n";
> print "------\n";
> foreach $b (keys %{$out{$a}})
> {
> print "\t$b: $out{$a}{$b}\n";
> }
> }
>
> sub sample {
> my $a;
> my $b;
> my %in;
>
> ### set up %in here ###
>
> # foreach $a (keys %in)
> # {
> # print "$a:\n";
> # print "------\n";
> # foreach $b (keys %{$in{$a}})
> # {
> # print "\t$b: $in{$a}{$b}\n";
> # }
> # }
>
> return (%in);
> }
> ------------------------------------------------------
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 29 Apr 1999 17:13:10 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: An explanation of sort
Message-Id: <3728F596.25A7361B@mail.cor.epa.gov>
Larry Rosler wrote:
>
> In article <3728D0A6.FA11976F@home.com> on Thu, 29 Apr 1999 21:37:12
> GMT, Rick Delaney <rick.delaney@home.com> says...
> > Jerome O'Neil wrote:
> > >
> > > Larry Rosler wrote:
> > > >
> > > > wouldn't be as silly and seems considerably more perspicuous.
> > >
> > > I'm well versed in silly, but how would I know if I'm being perspicous?
> > > Or, if I were being perspicious, what would I be?
> >
> > Don't they have dictionaries in Seattle? I'm not sure if there's a joke
> > in those misspellings or not. I guess I'm not very perspicacious. :-)
>
> Perspicuity is a virtue for programs (except JAPHs and Obscure Perl
> contests, of course). Perspicacity is a virtue for programmers. Maybe
> the latter should be added to The Larry's list of three.
>
> Non-native English speakers might find these words more familiar than
> some of us natives, especially if they have backgrounds in Latin (which
> most of us don't).
But most of us should, IMHO. They both come from the Latin
_perspicere_ . Not to be confused with _spicare_ or _specere_ .
Or spick-and-span.
Surely all Perl programmers should have to take a foreign language
to get their `certification'. :-)
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: Fri, 30 Apr 1999 02:18:39 GMT
From: Mitch <portboy@home.com>
Subject: Can't figure this one out...
Message-Id: <3729136C.2BABC218@home.com>
Okay, let's assume I have two .pl files, one is named commands.pl and
the other interface.pl. Now the commands.pl files contains a structure
like:
$commands{help}{sub} = \&help;
$commands{help}{desc} = "Show all available commands";
$commands{foo}{sub} = \&help;
$commands{foo}{desc} = "Foobar";
......
and below are the subroutine definitions.
Now, in the interface.pl file, it starts out with:
BEGIN {
$BASE_DIR"/foo";
do "$BASE_DIR/commands.pl";
}
......
Now at a command line called "camel>" (generated from with
interface.pl), I'd like to be able to type something like:
foo arg1 arg2
Currently I have a function called get_line that does:
sub get_line
{
my($an);
$an = <STDIN>;
chomp $an;
$an =~ (bunch of stuff to get of funny stuff);
$an;
}
The get_line function is called from another function loop:
sub loop {
while(1)
{
my($an)=&get_line:
...........
if(!$commands{$an})
{
print("not a valid command");
}
else
{
&{$commands{$an}{sub}};
}
}
}
Finally to my question. How can I modify this code to accept from the
prompt:
foo arg1 arg2
Currently it can only take the one command, foo or help.
Any and all help are appreciated, Mitch.
------------------------------
Date: Thu, 29 Apr 1999 23:44:23 GMT
From: jeffrey_f@my-dejanews.com
Subject: Checkbox is not working.
Message-Id: <7gaqsm$eos$1@nnrp1.dejanews.com>
I have a script which saves data..and keeps it in hidden fields. Basically,
you press next, and puts data into hidden fields.
The problem is it only saves the last checkbox (last field in the HTML). I
can figure out why!! Happens with any checkboxes...name doesnt matter, value
doesnt...weird.
Thanks Alot.
Jeff
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 29 Apr 1999 23:01:44 GMT
From: sstarre@my-dejanews.com
Subject: Re: Count Linenumber
Message-Id: <7gaocm$cha$1@nnrp1.dejanews.com>
How about this- no loop:
open F,'./x';
my $count=my @l=<F>;
print "$count\n";
close F;
perl -w count.pl
320
*********************************************************
-Voila, Hug,
S
In article <x7aewfrfkv.fsf@home.sysarch.com>,
Uri Guttman <uri@home.sysarch.com> wrote:
> >>>>> "TL" == Thelma Lubkin <thelma@alpha2.csd.uwm.edu> writes:
>
> TL> Larry Rosler <lr@hpl.hp.com> wrote:
> TL> : In article <370FD664.4B6F484A@xs4all.nl> on Sun, 11 Apr 1999 00:53:24
> TL> : +0200, Frank de Bot <debot@xs4all.nl >says...
> TL> :> How can I count the number of lines WITHOUT a loop in a file?
>
> TL> : You cannot.
>
> TL> : The following is the shortest code I can think of:
>
> TL> : 0 while <FILE>;
> TL> : print "$.\n";
>
> TL> print scalar(@lines=<FILE>)."\n";
>
> but that reads the whole file into memory which can waste a lot of
> memory and time.
>
> abigail had one of those bizarre one using the internal -n loop
> construct in a one liner that was the shortest version of line
> counting. a longer version is something like:
>
> perl -ne 'END{print "$.\n"'}'
>
> or you could just use wc!
>
> uri
>
> --
> Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
> uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
> Have Perl, Will Travel ----------------------------- http://www.sysarch.com
> The Best Search Engine on the Net ------------- http://www.northernlight.com
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 30 Apr 1999 02:39:20 GMT
From: clearway@my-dejanews.com
Subject: Dynamic binding problem
Message-Id: <7gb54o$n65$1@nnrp1.dejanews.com>
Hi, Guys:
In my company, there is a central machine which has all kind of app/scripts
installed on /usr/local , and this machine export its /usr/local directory to
all other machines in house, so that all other machine can nfs mount this
directory and can share the app/scripts on this central machine.
We have some scripts writen in Perl/tk which calls the Perl in
/usr/local/bin. Those scripts ran OK several weeks ago. However, recently, we
cutover the central machine from Tokenring to ethernet, and now this central
machine is in the same subnet as other machine nfs mounted the usr/local.
>From then on, those Perl/Tk script no longer works, even though other
app/scripts in /usr/local/bin still works fine. Everytime when I try to run a
perl script, it gives out following message:
Can't load '/usr/local/lib/perl5/aix/auto/Tk/Tk.so' for module Tk: dlopen:
/usr/local/lib/perl5/aix/auto/Tk/Tk.so: No such file or directory at
/usr/local/lib/perl5/DynaLoader.pm line 450.
at /usr/local/lib/perl5/Tk.pm line 31
BEGIN failed--compilation aborted at test.pl line 2.
The content of test.pl has just two line:
#!/usr/local/bin/perl -w
use Tk;
I heard that there's some dynamic binding /NFS problem of Perl modules . IS
there any solution to this problem??
Thanks a lot.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 29 Apr 1999 21:28:11 GMT
From: jlmy@orion (JUNYI J LIN)
Subject: How to flush CGI output?
Message-Id: <7gaitb$d8r@news.csus.edu>
I am having problem to flush output to the screen
in a CGI program. To demonstrate my problem, I
wrote this little CGI below.
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "hello world!\n";
#assume that I do a lot of stuff here which
#takes 10 seconds.
sleep(10);
exit;
This little CGI will not display "hello world"
on the browser screen until it finished the
10 second sleep.
I tried to call flush(STDOUT) right before the
sleep call, but it didn't help at all. It seems
like the web server is caching it.
Thanks.
------------------------------
Date: Fri, 30 Apr 1999 01:12:14 GMT
From: sstarre@my-dejanews.com
Subject: importing a namespace from an arbitrary file
Message-Id: <7gb01b$itt$1@nnrp1.dejanews.com>
I read Camel, permod, and perldoc for this info but I don't see this topic
even mentioned nor any relavent examples given.
I wish to import variables from a module in another directory. Right now I do
something like:
require '../mydir/modx.pm';
which works OK, but I'd prefer to use "use", as in
use modx qw(varx);
for its additional control over what is loaded.
How can I tell the compiler to look for modules in ../mydir or any other
specific dir? I folled aroud with system('PATH') but
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 29 Apr 1999 14:50:43 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Is this the best way to get a substring?
Message-Id: <3m9ag7.hf2.ln@magna.metronet.com>
Jerome O'Neil (jeromeo@atrieva.com) wrote:
: Randal L. Schwartz wrote:
: > >>>>> "Jerome" == Jerome O'Neil <jeromeo@atrieva.com> writes:
: >
: > Jerome> $newstring =~ /^(\d+)\D+/;
: > Jerome> $digits = $1;
: >
: > Bad code. Very hard to track down coding error, because it *looks* right.
: It's also bad code because I didn't use strict and turn on warnings,
: comment it, write a spec and document it, but that's not the point, nor
: the answer to the fellow's problem.
But it has high potential of providing him yet another problem.
: It's a good example
No it isn't.
: > Hint - what if the regex match fails? What $1 are you getting?
: > Right... the PREVIOUS $1 from the PREVIOUS successful match.
: There is no previous match.
Q: So _then_ what would be the value of $1 if the match failed?
A: undef
: There is no conditional.
*that* is the problem!
: loop. (There is no spoon. :> ) There is a defined pattern, and a regex
: that will match it.
I think it is a regex that might match it, but might not match it.
: > Bad code.
: Good Example.
Bull.
: > Never look at $1 unless you are inside a conditionally executed
: > chunk of code dependant on the success of your match of interest.
I remember you straightening me out on this very thing a few
years ago.
Thanks Randal!
---------------
#!/usr/bin/perl -w
use strict;
my $newstring = 'abc12';
print "'$1'\n"; # no previous match
$newstring =~ /^(\d+)\D+/; # unsuccessful match
print "'$1'\n";
$newstring =~ /(\D+)/; # successful match
print "'$1'\n";
$newstring =~ /^(\d+)\D+/; # unsuccessful match
print "'$1'\n";
---------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 30 Apr 1999 02:43:12 GMT
From: koch9@home.com (Jon)
Subject: matching a quoted string
Message-Id: <4N8W2.143$%d1.337@news.rdc1.fl.home.com>
I am using the following code to find an existing string in a line of input,
then replace it with another string.
if($line =~ /$compare/) {
$line =~ s/$compare/$newstr/eg;
}
This works fine unless the string is contained inside double quotes in the line
of input. In that case, no match is found. How do you stop the double quotes
in the input line from affecting the string match and substitution?
------------------------------
Date: Thu, 29 Apr 1999 17:05:05 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: newbie q: compiling perl
Message-Id: <3728F3B1.DF79844@mail.cor.epa.gov>
Dennis wrote:
>
> Its a couple of weeks ago since i started to use perl. (should have done
> that years ago!!)
Yep. Especially if you've been using the ever-mutating VBScript.
:-)
> I cannot figure out how to compile my scripts. Already downloaded
> EGCS-1.1.2, but i am not familier with this kind of compiling ( I'm a
> spoiled VB GUI kid).
> Can anyone please give my a hint.
You don't. Perl does all the dirty work for you. You write the
Perl program in whatever editor you like the best (or hate the least)
(or just have handy). Then either you:
[1] run the program from inside the editor, as you can do in
emacs, or vi-clones, or pfe, or Ultra-Edit, or...
OR
[2] you save the file as text, then at the command prompt you type
perl -w myfilename.pl
as you have to do if you're writing Perl code in, say, NotePad.
That's it. Perl runs.. or tells you what errors you made, and lets
you go back and fix them.
No code-compile-link-run-curse-debug cycle which you may be used to.
Perl's debugger is built in [read the perldebug docs for tons of
details]. So you don't need an IDE. Perl comes with hundreds of
pages of docs, and you should have them in HTML form to scan in your
browser. It also comes with perldoc, which is well worth learning
to use.
> I am running perl 5.005 on a Windows NT.
>
> Thanx,
Yr welcome,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: 30 Apr 1999 02:09:13 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: PERL & Y2K
Message-Id: <slrn7ii468.pa4.sholden@pgrad.cs.usyd.edu.au>
Ronald J Kimball <rjk@linguist.dartmouth.edu> wrote:
>Sam Holden <sholden@pgrad.cs.usyd.edu.au> wrote:
>
>> Of course there is something to fix in that. I didn't say there wasn't
>> I said (obviously badly) that since the original poster was too stupid to
>> read the documnetation that comes with perl on the subject. And too stupid
>> to do a simple search of the subjects of the days posts to find their answer.
>> Then even if they do find a magical tool that 'scans PERL script for Y2K
>> compliane' they are obviously too stupid to fix anything it finds.
>
>I don't understand... Why do you say the original poster is too stupid
>to read the documentation?
I extrapolated I was wrong I can live with that.
>
>He didn't ask if Perl is Y2K compliant. He asked if there are any tools
>that scan Perl *scripts* to find Y2K bugs. Such as the 'printf "The
>year is 19%d\n", (localtime) [5];' that Abigail provided.
And other threads that he could have easily found have covered that.
He didn't ask that question anyway. He asked for a script that scans
for Y2k 'compliance'. Such a script does not exist. The FAQ about Y2K
contains a reference at the bottom. Reading the document it points
to should have shown them such a tool is impossible.
The author claimed to be doing some research, a simple look at
http://www.perl.com/ should have led them to something like what they
where looking for...
http://www.activetsate.com/PerlDirect/
Damn I answered the original question, in a way that might actually
help the poster, rather then one line perl scripts that only catch
a very small class of problems.
>
>I simply cannot fathom your logic...
>
>I agree with Abigail; you are confused. Take a deep breath, and come
>back tomorrow when you're more rational. :)
It's tomorrow and I'm back, no more rational though ;)
--
Sam
Of course, in Perl culture, almost nothing is prohibited. My feeling is
that the rest of the world already has plenty of perfectly good
prohibitions, so why invent more? --Larry Wall
------------------------------
Date: Thu, 29 Apr 1999 14:31:52 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: pow() ? to the power of ?
Message-Id: <oi8ag7.hf2.ln@magna.metronet.com>
David Cassell (cassell@mail.cor.epa.gov) wrote:
: And, of course, pow() is one of the experimental functions in
: PSI::ESP::Telekinesis .
It is?
I thought it was part of Batman::Sounds ...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 30 Apr 1999 02:03:48 GMT
From: Kenneth Rose <kenrose@home.com>
Subject: RegExs and question marks...a possible bug?
Message-Id: <37290EAC.25CF0AA7@home.com>
Hi all,
OK, this one took me a while to figure out...consider a program that
reads markup and does things accordingly.
Let's say that I have the following:
$n = 'Where are you going<proper>henny penny?</proper>asked Cocky
Locky';
$foundTag = $n =~ m/<(.+)>(.*)<\/\1>/;
$tag = $1;
$text = $2;
$n =~ s|<proper>$text</proper>|ucfirst(lc($text))|sei;
print $n;
now, the output looks like this:
Where are you going<proper>henny penny?</proper>asked Cocky Locky
no difference from $n! Now, let's try this (notice that in this case, $n
doesn't have a question mark contained in it after the word penny)
$n = 'Where are you going<proper>henny penny</proper>asked Cocky Locky';
$foundTag = $n =~ m/<(.+)>(.*)<\/\1>/;
$tag = $1;
$text = $2;
$n =~ s|<proper>$text</proper>|ucfirst(lc($text))|sei;
print $n;
Where are you goingHenny pennyasked Cocky Locky
This is what I want...what I want to know is why the f*ck when I have a
question mark in the string, it pukes on me?!
I am aware that I could do:
$n = 'Where are you going<proper>henny penny</proper>asked Cocky Locky';
$n =~ s|<proper>(.*)</proper>|ucfirst(lc($1))|sei;
print $n;
and get the desired result...still, I'd like to know why the first
example doesn't work.
Thanks to anyone who can help.
/<enneth Rose
P.S. - could this be a bug in Perl?
P.P.S. - I'm using Perl 5.005_03 on Win32 (ActiveState build)
------------------------------
Date: 29 Apr 1999 21:31:50 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: RegExs and question marks...a possible bug?
Message-Id: <slrn7ii5g6.bln.abigail@alexandra.delanet.com>
Kenneth Rose (kenrose@home.com) wrote on MMLXVIII September MCMXCIII in
<URL:news:37290EAC.25CF0AA7@home.com>:
,,
,, $n = 'Where are you going<proper>henny penny</proper>asked Cocky Locky';
,, $foundTag = $n =~ m/<(.+)>(.*)<\/\1>/;
,, $tag = $1;
,, $text = $2;
,, $n =~ s|<proper>$text</proper>|ucfirst(lc($text))|sei;
,, print $n;
,,
,, Where are you goingHenny pennyasked Cocky Locky
,,
,, This is what I want...what I want to know is why the f*ck when I have a
,, question mark in the string, it pukes on me?!
,,
Because ? is special in regexes. Since $text equals "henny penny?"
your actual regex becomes: "<proper>henny penny?</proper>", which
matches the following two strings:
<proper>henny penny</proper>
<proper>henny penn</proper>
You want:
$n =~ s|<proper>\Q$text\E</proper>|ucfirst(lc($text))|sei;
And note that your fragment won't work if you have two <proper></proper>
pairs in the same line. Or if you have a new line between <proper> and
</proper>.
You can combine all that, and do:
1 while $n =~ s{<([^>]+)>((?!</\1>).)</\1>}{ucfirst lc $2}segi;
Abigail
--
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com/ The Largest Usenet Servers in the World!
---------== Over 72,000 Groups, Plus Dedicated Binaries Servers ==--------
------------------------------
Date: Fri, 30 Apr 1999 00:10:45 GMT
From: "Jalil Feghhi" <jalil@corp.home.net>
Subject: Running Perl from Perl
Message-Id: <925431045.736107@zeppelin.svr.home.net>
I would like to run a perl program from my perl code but I don't want to
block on. The program I want to run takes a long time to finish.
Is there a way to do this?
Also, how one perl program can communicate w/ an already running perl
program (to stop it, or get some info on its status)? I control the code for
both programs.
Thanks,
-Jalil
------------------------------
Date: 30 Apr 1999 01:00:30 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: Running Perl from Perl
Message-Id: <7gavbe$pet$1@fcnews.fc.hp.com>
Jalil Feghhi (jalil@corp.home.net) wrote:
: I would like to run a perl program from my perl code but I don't want to
: block on. The program I want to run takes a long time to finish.
: Is there a way to do this?
See perlfaq8, "How do I start a process in the background?"
: Also, how one perl program can communicate w/ an already running perl
: program (to stop it, or get some info on its status)? I control the code for
: both programs.
You could send a signal to the other perl script. You could talk via
files or pipes, or use the IPC modules. Check out perlipc.
Andrew
------------------------------
Date: Fri, 30 Apr 1999 01:49:37 GMT
From: jgangemi@ccf.rutgers.edu
Subject: search string syntax
Message-Id: <7gb27g$kpa$1@nnrp1.dejanews.com>
Hey all -
Could someone please help me with the syntax to match the following :
$string = "mobile internet communications"
and I want to check to see if the word "mobile" is in that string, I also
would like to be able to check if the word "operating systems" in the string.
Thanks
--
-Jae
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 29 Apr 1999 21:33:27 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: search string syntax
Message-Id: <slrn7ii5j8.bln.abigail@alexandra.delanet.com>
jgangemi@ccf.rutgers.edu (jgangemi@ccf.rutgers.edu) wrote on MMLXVIII
September MCMXCIII in <URL:news:7gb27g$kpa$1@nnrp1.dejanews.com>:
{} Hey all -
{}
{} Could someone please help me with the syntax to match the following :
{}
{} $string = "mobile internet communications"
{}
{} and I want to check to see if the word "mobile" is in that string, I also
{} would like to be able to check if the word "operating systems" in the string.
Use the index() function. Please read the manpage and if you don't
understand it, specify what you don't understand.
Abigail
--
perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")
-> define ("foldoc", "perl")) [0] -> print'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com/ The Largest Usenet Servers in the World!
---------== Over 72,000 Groups, Plus Dedicated Binaries Servers ==--------
------------------------------
Date: Thu, 29 Apr 1999 18:30:50 -0700
From: nichols <nichols@blarg.net>
Subject: Security:HowTo not pass UserID/Password as hidden variables from page to page
Message-Id: <372907CA.8CBC8E8D@blarg.net>
I have a web application that is written in Perl that accesses an Oracle
database that requires a user_id/password for each person.
There is a login page that requires the user_id and password. On
subsequent pages, the user_id and password are passed as hidden
variables.. Of course, this is a security hole. The user can edit the
source html and see the password. If you save it as a cookie, it is
still viewable on the user's machine.
What approach would you recommend to solve this problem? Does anyone
have sample code?
Thanks for your help,
Frankie
------------------------------
Date: Fri, 30 Apr 1999 00:53:09 GMT
From: Brian Lavender <blavender@spk.usace.army.mil>
Subject: Selecting a long with DBI/DBD Oracle
Message-Id: <7gautj$i5l$1@nnrp1.dejanews.com>
I am using the DBI/DBD perl modules to select a long from a database. I can't
get it to work. I have seen the bind param and a LongTruncOk command. Here is
my code. What do I need to make this work?
Table definition:
SYNOPSIS LONG
LOCATION VARCHAR2(64)
PERL code:
#!/usr/local/bin/perl -Tw
use DBI;
use DBD::Oracle qw(:ora_types);
BEGIN {
$ENV{ORACLE_HOME} = '/opt/app/oracle/product/7.3.4';
$ENV{TWO_TASK} = 'foo.bar';
}
my $dbh = DBI->connect('dbi:Oracle:','myuserid','mypasswd')
or die "Unable to connect: $DBI::errstr";
my $query = "select synopsis , location from solicitation";
my $sth= $dbh->prepare($query) or die "Prepare failed: $DBI::errstr";
$sth->execute;
while(@row = $sth->fetchrow() ) {
print @row, "\n\n";
}
$sth->finish();
$dbh->disconnect();
--
Brian E. Lavender
US Army Corps of Engineers -- Programmer / Systems Analyst
Sacramento, CA (916) 557-6623
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 30 Apr 1999 02:08:37 GMT
From: NOSPAMcrstlblu@planet.eon.net
Subject: single quotation " erases REST OF TEXT
Message-Id: <371c8fb3.614507@news.planet.eon.net>
On Thu, 29 Apr 1999 08:00:31 GMT, bart.lateur@skynet.be (Bart Lateur) wrote:
>>NOSPAMcrstlblu@planet.eon.net wrote:
>> $content=~ s/"/"/d; > > TRIED YOUR IDEA HERE AND GOT AN ERROR
>
>That "d" must be a "g" (as in "global": ALL occurences of '"' are
>replaced).
> $content=~ s/"/"/g;
> Bart.
thanks Bart, unfortunately IT DON'T WORK either, :(
again:
(a) a dbm file has a text string INSIDE it that reads:
I am 5'10" tall
(b) ONE script extracts this into a $variable then passes it
in a hidden form field to a SECOND script
(c) the SECOND script parses values and then saves the
value into a NEW DBM file!
now if you VIEW the actual contents of this NEW dbm file,
you will see that the ONLY THING THAT GOT SAVED is:
I am 5'10
EVERYTHING after the quotation mark in the middle got LOST!
Don't do ANY HTML codeing in the scipts - to keep the flamers away -
don't worry about trying to "print" to the browser any values this is
100% strictly PERL programming!
I apologize for not FRAMING my original problem so as to prevent wanderings.
:)
wj
remove SPAM from email to reply
------------------------------
Date: 29 Apr 1999 21:38:02 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: single quotation " erases REST OF TEXT
Message-Id: <slrn7ii5rq.bln.abigail@alexandra.delanet.com>
NOSPAMcrstlblu@planet.eon.net (NOSPAMcrstlblu@planet.eon.net) wrote on
MMLXVIII September MCMXCIII in <URL:news:371c8fb3.614507@news.planet.eon.net>:
!!
!! again:
!!
!! (a) a dbm file has a text string INSIDE it that reads:
!! I am 5'10" tall
!!
!! (b) ONE script extracts this into a $variable then passes it
!! in a hidden form field to a SECOND script
!!
!! (c) the SECOND script parses values and then saves the
!! value into a NEW DBM file!
!!
!! now if you VIEW the actual contents of this NEW dbm file,
!! you will see that the ONLY THING THAT GOT SAVED is:
!! I am 5'10
!!
!! EVERYTHING after the quotation mark in the middle got LOST!
!!
!! Don't do ANY HTML codeing in the scipts - to keep the flamers away -
!! don't worry about trying to "print" to the browser any values this is
!! 100% strictly PERL programming!
If it's 100% Perl, and you're not doing any HTML, then what the hell
is a "hidden form field"? I know what formats are, but forms? Never
heard of them as being part of Perl....
It might help if you actually supplied some code....
Abigail
--
perl -wlne '}for($.){print' file # Count the number of lines.
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com/ The Largest Usenet Servers in the World!
---------== Over 72,000 Groups, Plus Dedicated Binaries Servers ==--------
------------------------------
Date: Thu, 29 Apr 1999 22:42:38 GMT
From: homeless <homelessinseattle@my-dejanews.com>
Subject: Re: strict vs. Win32::Registry
Message-Id: <7gan8u$bm0$1@nnrp1.dejanews.com>
Thank you very much foer the help.
In article <37273DD3.6B49A19D@mail.cor.epa.gov>,
David Cassell <cassell@mail.cor.epa.gov> wrote:
> Let me ask a question, since you aren't showing any code.
> Are you saying something like:
>
> $remote_key = $Registry->{"yadda/yadda/yadda"...};
>
> If so, then you want to add a `my' immediately before:
>
> my $remote_key = $Registry->{"yadda/yadda/yadda"...};
Yes, I use "my" for all variables except the ones exported
(or imported?) automatically by Win32::Registry module.
So, I'm not using my->$HKEY_LOCAL_MACHINE.
I'll try that though.
thanx again,
homeless
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 30 Apr 1999 01:54:07 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: stupid single quote " wipes out REST OF TEXT
Message-Id: <slrn7ii39u.pa4.sholden@pgrad.cs.usyd.edu.au>
On Thu, 29 Apr 1999 00:34:03 GMT, NOSPAMcrstlblu@planet.eon.net wrote:
>On Wed, 28 Apr 1999 08:39:35 -0400, tadmc@metronet.com (Tad McClellan) wrote:
>> STOP POSTING YOUR HTML PROBLEMS IN THE PERL NEWSGROUP!!!
>> *plonk*
>> $value =~ s/"/"/g; # escape double quotes as REQUIRED
>> # by the HTML specification!!!
>> Tad McClellan
>
> thanks for your suggestion, Tad, however it doesn't work!
>
>foreach $item(@pairs) {
> ($key,$content)=split(/=/,$item,2);
> $content=~tr/+/ /;
> $content=~ s/"/"/d; > > TRIED YOUR IDEA HERE AND GOT AN ERROR
A d is not a g. What error did you get? A compile error or did it not do what
you expected?
> $content=~ s/%(..)/pack("c",hex($1))/ge;
> $fields{$key}=$content;
>}
>
> I have aslo tried content=~tr/"/"/d; never got an error, but still
>lost the 200 characters after the single quote in the value of the text string
I thought you were losing the value after the double quote. I'm sure that's what
you said earlier.
>
> again, in the 1st cgi script the variable was:
>$value = $dbhash{dbkey{'thevalue'}};
> where 'thevalue' = "200 characters, 5'10", followed by 200 more"
>
> passed to the 2nd cgi script in a hidden field:
> <input type=\"hidden\" name=\"samevariable\" value=\"$value\">
> PARSED as in my example parser above, and several ways
> ALWAYS loses the QUOTATION mark in middle & the 200 chars following it!
>
> escaping BEFORE entering the $value into the hidden field would be
>insane, because then I'd be CHANGING the value, which is NOT MY RIGHT,
>as that text was typed in by a customer, and stored in a DBM.
Do you have any idea what the term 'escaping' means. Instead of yelling and
blaming everyone else why don't you try hiring someone who can actually
program.
> escaping AFTER parsing the values in the 2nd script seems insane,
>because I'd be changing the value, when I might want to RE-save it to another
>DBM in the remainder of the script!
>
> it's NOT A MATTER OF HTML friend, the PROOF is that in the FIRST cgi
>script, when the value of $value is: "200 chars, 5'10", and 200 chars" NO QUOTE
>ESCAPE IS NECESSARY IN ORDER for $value to be printed PERFECTLY!
> *note: the script declares the variable as from a DBM file
> $value=$dbhash{$dbkey{'thevalue'}};
> "200 chars, 5'10", and 200 chars" is simply WHAT IS IN THE DBM, it is
> NEVER WRITTEN in the script - SILLY.
You still don't have the foggiest idea of even a tiny clue. Why don't you
try reading what people have sayed instead of being so bloody defensive.
One more time for the idiot :
'10" long' is a perfectly valid value for a perl scalar variable. It is
perfectly valid to store in a dbm. It is perfectly valid to print out. It
is perfectly valid to include in HTML. It is not valid to quote that
value using "s however.
"10" long" does not make sense. The " closes the quotes. If you were to
declare such a variable in perl using double quoting you would use :
"10\" long"
That's called escaping the quote, so that the parser doesn't think it
end the string and thus screw up. The actual value of the variable is
'10" long' the escaping is removed by the parser.
Funnily enough in HTML we also quote values like this :
value="some text"
Since we use "s for the quoting we can't do things like this :
value="10" long"
Since the " in the text closes the quoting and thus we have value=10
followed by some crap that would cause perl to fail to compile. Since
browsers are forgiving of bad HTML it probably looks OK on the
browser, but the value is wrong.
So we do what we did in perl we escape the value. I don't know how HTML
does escaping since I don't use it very much at all and when I do I use
perl modules from CPAN that do all the escaping for me. I do that
because I'm not an idiot and don't want to write buggy code when
there is well tested code available. From what I've read above I
will assume it used " to produce a ".
So we use :
value="10" long"
That's called escaping the quote, so that the parser doesn't think it
end the string and thus screw up. The actual value of the variable is
'10" long' the escaping is removed by the parser.
>so if it works WITHOUT escapeing in the 1st script, WHY would it require
>escaping in the 2nd script? this is ILLOGICAL!
Because you aren't sending it through an HTML parser in the first script.
>
> even **MORE PROOF** is that no quote escaping of anysort was required in
>the OTHER 3 scripts which 1) collected the input, 2) displayed PERFECTLY for
>confirmation, and 3) entered the text into a DBM file - PERFECTLY!
>
> the $value is being passed EXACTLY THE SAME WAY from script to script to
>script in BOTH APPLICATIONS!?!?!?!?!?
> app1: 1) collects text string / 2) displays to confirm / 3) puts in DBM
> app2: 1) extracts & DISPLAYS from DBM / 2) displays AGAIN to confirm
>
>THE PRECISE SAME HTML SPECIFICATIONS ARE BEING USED IN BOTH APPLICATIONS
> ? :)
I don't believe you. Since it works in one and not the other, you are doing
something different. I don't know what, it might not be in the HTML but that
is the best bet right now. Since you haven't given any evidence for why that
is not the solution that is still the best bet. All you have done is rant and
rave that that isn't the solution and in doing so indicate that you have no
idea on what that solution is actually doing.
>
>but i keep LOSING both the quotation PLUS the 200 chars following it FROM THE
>value of the variable when it gets parsed AND printed by the 2nd script.
>
>This is my last attempt to have a PracticalExtractionandReportLanguage question
>answered in this PERL newsgroup - thanks for all of your time,
I for one am glad. THough for anyone else reading, you can ask questions, we do
give answers. When you believe your results completely contradict those answers,
then post some evidence. The shortest example script that shows the problem
is the best. A pointer to a URL which shows the example code and runs it will
result in less people answering your question due to the extra time and
effort required, but someone still might.
--
Sam
You are bordering on ridiculous if you think you need to support your
premises. Such an argument is an infinite regression.
--George Reese in <wv0O1.1521$Ge.4809664@ptah.visi.com>
------------------------------
Date: Thu, 29 Apr 1999 21:46:57 GMT
From: mabus67@my-dejanews.com
Subject: Telnetting from Unix to NT
Message-Id: <7gak0g$8k9$1@nnrp1.dejanews.com>
I need to execute a script on a NT server from a Unix server. Specifically,
I need to shut an application down on an NT box whenever I need to shut down
Sybase running on a Sun server. Ideally, I would telnet into the NT box and
execute a command from within Perl that would shut down the NT app. My
second option is to have my Perl script call a batch file that would shut
down the application. Are there any Perl modules that could help me do this?
What about other tools? The problem that I'm having is telnetting into the
NT box.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 29 Apr 1999 22:52:29 -0400
From: Bob Walton <walton@frontiernet.net>
To: mabus67@my-dejanews.com
Subject: Re: Telnetting from Unix to NT
Message-Id: <37291AED.BCC83B8@frontiernet.net>
Hmmm...First, NT is so braindead it doesn't have a telnet server included, so you
would have to get one and install it (don't get NT's telnet client confused with
a telnet server). I think you could generate one in perl using the LWP package
(if I remember correctly, there is an example of such in the LWP docs). Then you
could implement whatever capability you wish in your NT telnet server.
One other thing you could do (which I have done) is to install a web server on
your NT box. Then you can put up an HTML form with an accompanying perl CGI
script. The form has text boxes for the directory in which to run a DOS command,
the DOS command itself, and a password; and a "run DOS command" submit button.
The response from the CGI script is whatever the DOS command outputted. This
works only for commands with text-only output, but lets one do quite a bit of
stuff. Web server software for NT is readily available and of reasonable
quality, unlike telnet servers. With this, your Unix box could use a perl script
with LWP::Simple to transmit the DOS command to your NT box. Estimated coding on
your part is about 100 lines.
mabus67@my-dejanews.com wrote:
> I need to execute a script on a NT server from a Unix server. Specifically,
> I need to shut an application down on an NT box whenever I need to shut down
> Sybase running on a Sun server. Ideally, I would telnet into the NT box and
> execute a command from within Perl that would shut down the NT app. My
> second option is to have my Perl script call a batch file that would shut
> down the application. Are there any Perl modules that could help me do this?
> What about other tools? The problem that I'm having is telnetting into the
> NT box.
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 29 Apr 1999 15:00:11 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: What's wrong with this code?
Message-Id: <r7aag7.hf2.ln@magna.metronet.com>
tfinn (tfinn@hotmail.com) wrote:
: Having a bit of a problem trying to work out what's wrong with this.
: Does anyone know?
No -w switch.
No "use strict"
has barewords
If you want a serious answer then don't post joke code.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 29 Apr 1999 17:21:03 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Win32::OLE and Word
Message-Id: <3728F76F.8C9882CE@mail.cor.epa.gov>
David Ritchie wrote:
>
> I'm having a poor time trying to edit an existing MSWord document using the
> Win32::OLE module.
>
> I can read the BuiltInDocumentProperties just fine, and count the number of
> tables and paragraphs and other such simple things, but I can't get the hang
> of translating the examples in the online VB help into perl.
>
> For example, doing a search-replace function would be useful, as would
> italicising or bolding a range. I suspect most of my problems come from not
> getting my head around ranges, being a bear of little brain.
>
> If anyone can push me in the right direction, either here or pointing me to
> a URL, that would be fly.
If it's any help, this sort of topic is commonplace on the
win32-perl-users listserv. You can subscribe to it just by going
to www.activestate.com and finding the list of listservs you can
subscribe to. Or you can use DejaNews to search previous
win32-perl-users digests.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: 12 Dec 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 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5523
**************************************