[11722] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5322 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 7 17:07:17 1999

Date: Wed, 7 Apr 99 14:00:23 -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           Wed, 7 Apr 1999     Volume: 8 Number: 5322

Today's topics:
    Re: another perlshop question... <awajda@limbo.ne.mediaone.net>
    Re: Arrays in Learning Perl 2nd Edition (Tad McClellan)
    Re: Autoresponder <aqumsieh@matrox.com>
    Re: Beginner PERL Question, Inserting into Sql database (David Turley)
    Re: Can you stepthrough a Perl program? <aqumsieh@matrox.com>
        Cannot execute PerlScript in ASP ncollins1@my-dejanews.com
    Re: determining the browser? <cassell@mail.cor.epa.gov>
    Re: determining the browser? (Nicholas Carey)
    Re: Dyn-IP "wanna be" 1-liner (Matthew Bafford)
    Re: Dyn-IP "wanna be" 1-liner <SpamMeNOT.3pound@iname.com>
    Re: Enclosing a binary within perl <aqumsieh@matrox.com>
    Re: exponential notation to decimal notation (Larry Rosler)
    Re: here docs vs qq quote operator. Just personal prefe <cassell@mail.cor.epa.gov>
    Re: Most elegant random string generator? (Bart Lateur)
    Re: Perl calls PGP <ddelikat@protix.com>
        perl reading files/text from commandline under NT <evonzee@tritechnet.com>
    Re: perl reading files/text from commandline under NT <evonzee@tritechnet.com>
    Re: pod2html: how to use? (Schipmolder, Jan B.)
        Problem viewing data retrieved using PERL script on ORA <vinod.kudva@eds.com>
    Re: random number ( -w ) (Bart Lateur)
    Re: random number ( -w ) (Rich Lafferty)
    Re: random number <aqumsieh@matrox.com>
    Re: Recursion in Perl <cassell@mail.cor.epa.gov>
    Re: system problem <cassell@mail.cor.epa.gov>
        test <vinod.kudva@eds.com>
    Re: Trouble with Oraperl, and simple select statement (Darren Greer)
        Use Perl as parser? <fritz@frii.com>
        Using a variable in pattern matching operator <mlefevre@cadence.com>
    Re: Using a variable in pattern matching operator <SpamMeNOT.3pound@iname.com>
    Re: Using a variable in pattern matching operator <mlefevre@cadence.com>
        verifying programs can execute (Christian M. Aranda)
    Re: wanted: elegant inverse operation for vec (Tad McClellan)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 07 Apr 1999 15:16:04 -0400
From: Amy Wajda <awajda@limbo.ne.mediaone.net>
To: Video Gameplay Sales <sales@videogameplay.com.au>
Subject: Re: another perlshop question...
Message-Id: <370BAEF4.EC2535EB@limbo.ne.mediaone.net>

Check out http://www.sciencekits.com -- they have links to their product
pages right off of the index page.

Amy
awajda@limbo.ne.mediaone.net

Video Gameplay Sales wrote:
> 
> Great script, one tiny problem..
> 
> Is there a way to make it work, without having to go through the "Enter
> Store" crap for it to initialize?
> Too bad if someone arrives at a purchase page without coming through the
> front entry page.....
> 
> Any help would be greatly appreciated...
> 
> PJ


------------------------------

Date: Wed, 7 Apr 1999 11:51:29 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Arrays in Learning Perl 2nd Edition
Message-Id: <1uufe7.7i3.ln@magna.metronet.com>

northernnj@my-dejanews.com wrote:
: I'm trying to learn Perl programming from the O'reilly book, Learning Perl 2nd
: Edition.

: I can't seem to enter lists of strings.
: The following are examples from the book.
[snip code that looks fine]

: What format should I enter the lists of strings in?


   One per line.


: Do I have to press control+D after I enter the list?


   Yes (on Unix).

   To mark the end of input on Windows, you use control+Z instead.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: Wed, 7 Apr 1999 14:09:58 -0400 
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Autoresponder
Message-Id: <x3y6778nvyh.fsf@tigre.matrox.com>


oscoord@visi.com () writes:

> Iam looking for an e-mail autoresponder script.  I have been looking
> everywhere without any luc.  I see autoresponders everywhere on the
> internet but I cannot seem to find a script anywhere.  If you know of such
> a script please let me know... it will be GREATLY appreciated!

I don't have such a script. But, it is called a 'vacation'
program. Search for 'vacation program' on the web. If you are on
*nix-based system, then most probably you have it installed
already. Do a 'man vacation' to check it out.

HTH,
Ala



------------------------------

Date: Wed, 07 Apr 1999 19:04:33 GMT
From: dturley@binary.net (David Turley)
Subject: Re: Beginner PERL Question, Inserting into Sql database
Message-Id: <370baafa.27949515@news.erols.com>

On 7 Apr 1999 18:45:25 GMT, abigail@fnx.com (Abigail) wrote:

>coldfusion200029@my-dejanews.com (coldfusion200029@my-dejanews.com) wrote
>
>// I was wondering how to enter data in to a sql database, I have a bunch of
>// lists of users, and addresses that I wanted to enter into a Sql Database. I
>// have read that using the split command I can split the data and enter them
>// seperatly into the database.....but I am not sure exactl how this
>// works....please help!!!!
>

>Or don't you just know anything?
>

To the original poster, since you need some pointers, here's some
links that might be a bit more useful than the last reply:

http://language.perl.com/info/documentation.html
http://dc.pm.org/perl_db.html
http://www.symbolstone.org/technology/perl/DBI/index.html
http://www.geocities.com/ResearchTriangle/Node/9672/sqltut.html



-- 
David Turley
dturley@pobox.com
http://www.binary.net/dturley/


------------------------------

Date: Wed, 7 Apr 1999 13:48:47 -0400 
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Can you stepthrough a Perl program?
Message-Id: <x3y7lronwxs.fsf@tigre.matrox.com>


Chris Newman <newman@dynamite.com.au> writes:

> I am new to Perl programming but have some experience with using Borland
> C++. i am using MacPerl (MacOS) and have been look for the 'step
> through' and 'display register' buttons but to no avail. This is very
> useful features for debugging purposes. Anyone suggest how I can step
> through my Perl programs?

You need to learn how to use the debugger.
Checkout the 'perldebug' documentation for more info.

HTH,
Ala



------------------------------

Date: Wed, 07 Apr 1999 19:08:38 GMT
From: ncollins1@my-dejanews.com
Subject: Cannot execute PerlScript in ASP
Message-Id: <7egafg$ici$1@nnrp1.dejanews.com>

I installed ActivePerl on my WinNT (IIS 4.0) server.  I want to be able to
send an mail message from a form.  For testing I hardcoded variable's values
(once this works I will pass them from the form).  I am not able to run the
below .asp page when the .html form is submitted.  However when I copied the
PerlScript code into .pl file (deleted the <% and %> tags) and ran it from
the command line the email was successfully send.  So my guess is that ASP
does not know where to look for PerlScript on my computer.  How can I make
ASP know about PerlScript location?

Here goes the code:

<%@Language=PerlScript%>
<%
use Net::SMTP;

#my $to = $Request->QueryString("to")->Item;
#my $body = $Request->QueryString("body")->Item;
#my $subj = $Request->QueryString("subject")->Item;

$to = "myname\@mycompany.com";
$body = "test body";
$subj = "test bubject";

$smtp = Net::SMTP->new('mail.my_email_server.net');

$smtp->mail( 'myname@mail.my_email_server.net' );
$smtp->to($to);


$smtp->data();
$smtp->datasend("Subject: $subj \n");
$smtp->datasend("To: $to \n");
$smtp->datasend("From: myname\@mycompany.com\n");
$smtp->datasend($body);

$smtp->dataend();
$smtp->quit;

%>

Thank you,

Natalia

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: Wed, 07 Apr 1999 12:54:29 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: determining the browser?
Message-Id: <370BB7F5.46C79CEC@mail.cor.epa.gov>

Philip Newton wrote:
> 
> [stuff snipped to get down to:]
> 
> I suppose the real question is why would you want to determine the
> browser type at all? Valid, portable HTML should render equally well in
> MSIE, Netscape Navigator/Communicator, Lynx, NCSA Mosaic, and
> what-have-you.
> 
> Cheers,
> Philip

I believe you answered your own question.  The goal is most likely
to write non-portable html.  Not a good idea, IMHO.

Or else the goal is to shaft anyone using M$ products.  :-)

David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


------------------------------

Date: Wed, 07 Apr 1999 20:20:20 GMT
From: ncarey@harlequin.com (Nicholas Carey)
Subject: Re: determining the browser?
Message-Id: <370bbdcf.163801854@cnn.cam.harlequin.co.uk>

On Wed, 07 Apr 1999 12:54:29 -0700, "David L. Cassell"
<cassell@mail.cor.epa.gov> wrote:

> Or else the goal is to shaft anyone using M$ products.  :-)

Or any using...ooh...Netscape products, for that matter.
(prolly more likely).



------------------------------

Date: Wed, 07 Apr 1999 20:35:34 GMT
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: Dyn-IP "wanna be" 1-liner
Message-Id: <slrn7gnbvb.4ac.dragons@dragons.duesouth.net>

Wed, 7 Apr 1999 13:09:43 -0500 -- Jay J <SpamMeNOT.3pound@iname.com>:
-> Half jokingly, but - can someone think of a way to get rid of the seperate
-> 'my' line, and still be strict compliant?
-> 
-> #!/usr/bin/perl -wl
-> my %seen = ();    ## thanks Perl-Cookbook, cool dedupe
-> print (my $ip = [ grep { ! $seen{$_}++ } grep !/255.255.255.255/, map
->  /([1-9]\d+\.\d+\.\d+\.\d+)/ } grep /ppp/, map { split /s+/ }
-> `/sbin/route -n` ]->[0]);

How about:

#!/usr/bin/perl -wl
use strict;print+[grep{ !$_{$_}++}grep{!/(255\.){3}255\./x}map{/([1-9]
\d+\.\d+\.\d+\.\d+)/x}grep{/ppp/}map{split/s+/}`/sbin/route -n`]->[0];

or:

#!/usr/bin/perl -wl
use strict;print+(grep{!$_{$_}++}grep{!/(255\.){3}255\./}map{/([1-9]
\d+\.\d+\.\d+\.\d+)/x}grep{/ppp/}map{split/s+/}`/sbin/route -n`)[0];

look ma, 4 less characters!

or:

#!/usr/bin/perl -wl -Mstrict
print+(grep{!$_{$_}++}grep{!/(255\.){3}255\./x}map{/([1-9]\d+\.
\d+\.\d+\.\d+)/x}grep{/ppp/}map{split/s+/}`/sbin/route -n`)[0];

Woah! 1 char less than the one before! :-)

[snip]
-> Now, if I could only fit the lwp stuff on that line, I can update my IP in
-> one fell swoop.. =)

Good Luck!

-> Perl rocks..

:-)

-> -Jay J

--Matthew


------------------------------

Date: Wed, 7 Apr 1999 15:59:50 -0500
From: "Jay J" <SpamMeNOT.3pound@iname.com>
Subject: Re: Dyn-IP "wanna be" 1-liner
Message-Id: <kDPO2.704$s4.4485207@rsnws01.mn.mediaone.net>

I dunno why I find both posts completely helarious, but I do..

But you lost me: print+ , +[  .. huh? what gives??

point me to perldoc perlcryptic 'er something :) .. never see that before,
but not surprised.

-Jay

Matthew Bafford <dragons@scescape.net> wrote in message
news:slrn7gnbvb.4ac.dragons@dragons.duesouth.net...
> Wed, 7 Apr 1999 13:09:43 -0500 -- Jay J <SpamMeNOT.3pound@iname.com>:
> -> Half jokingly, but - can someone think of a way to get rid of the
seperate
> -> 'my' line, and still be strict compliant?
> ->
> -> #!/usr/bin/perl -wl
> -> my %seen = ();    ## thanks Perl-Cookbook, cool dedupe
> -> print (my $ip = [ grep { ! $seen{$_}++ } grep !/255.255.255.255/, map
> ->  /([1-9]\d+\.\d+\.\d+\.\d+)/ } grep /ppp/, map { split /s+/ }
> -> `/sbin/route -n` ]->[0]);
>
> How about:
>
> #!/usr/bin/perl -wl
> use strict;print+[grep{ !$_{$_}++}grep{!/(255\.){3}255\./x}map{/([1-9]
> \d+\.\d+\.\d+\.\d+)/x}grep{/ppp/}map{split/s+/}`/sbin/route -n`]->[0];
>
> or:
>
> #!/usr/bin/perl -wl
> use strict;print+(grep{!$_{$_}++}grep{!/(255\.){3}255\./}map{/([1-9]
> \d+\.\d+\.\d+\.\d+)/x}grep{/ppp/}map{split/s+/}`/sbin/route -n`)[0];
>
> look ma, 4 less characters!
>
> or:
>
> #!/usr/bin/perl -wl -Mstrict
> print+(grep{!$_{$_}++}grep{!/(255\.){3}255\./x}map{/([1-9]\d+\.
> \d+\.\d+\.\d+)/x}grep{/ppp/}map{split/s+/}`/sbin/route -n`)[0];
>
> Woah! 1 char less than the one before! :-)
>
> [snip]
> -> Now, if I could only fit the lwp stuff on that line, I can update my IP
in
> -> one fell swoop.. =)
>
> Good Luck!
>
> -> Perl rocks..
>
> :-)
>
> -> -Jay J
>
> --Matthew




------------------------------

Date: Wed, 7 Apr 1999 14:58:55 -0400 
From: Ala Qumsieh <aqumsieh@matrox.com>
To: Medtronic Employee <howard.pierce@medtronic.com>
Subject: Re: Enclosing a binary within perl
Message-Id: <x3y3e2cntoz.fsf@tigre.matrox.com>


[posted and CCed]

Medtronic Employee <howard.pierce@medtronic.com> writes:

> The Question
> --------------
> Is there any way I can embed a binary within a perl script and have the perl
> script execute
> it?  (either directly or by writing it to a file and then doing a "system" or
> shell "open" on
> that file)

I never tried that. But perhaps it's possible if you pack() it properly.

> What I've Tried
> ----------------
> Defining a variable (with double and single quotes, and as a HERE document) to
> contain
> the binary (just reading it into the editor [vim] at that location).  Using
> double or single
> quotes leads to unpaired quote problems and using HERE documents results in
> "Can't
> find string terminator "END-GREP-HERE-DOC" anywhere before EOF at test.pl
> line 8."

The most probable reason for that is that 'END-GREP-HERE-DOC' has a
leading of trailing spaces where it shouldn't. Check for that.

> Why I want to
> ---------------
> Why would I want to do such a screwy thing?  Because I'm stuck working on
> Windows
> machines, so I can't assume the users have "grep" installed (Cygnus win32 port
> of GNU's
> grep), yet I much prefer to use it over perl's own internal searching because
> it's a lot
> faster.  Am I just stuck with slow searching?

Perl isn't really that slow. My benchmarks on a 6.7 MB file show that
grep takes around 2.6 seconds to find a work that occurs 562
times. The equivalent Perl one-liner:

	perl -ne 'print if /pattern/' filename

took around 3.2 seconds.
Moreover, if the file is already open in your script, I would say it
would be faster to use Perl's internal grep() function, rather than
spawning a child process via system() to run grep and take the results
back in.

	print "Success" if grep { /Pattern/ } <FH>;

If you simply want to know if a pattern exists in a file, a better
solution might be something along the lines of:

	$success = 0;
	while (<FH>) {
		if (/Pattern/) {
			$success = 1;
			last;
		}
	}

	print "SUCCESS" if $success;

This exits the loop once a match is done.
If you want the lines that contain the pattern:

	@lines = grep { /Pattern/ } <FH>;

You're code will be easier to manage this way. There will be no
significant time loss. You might even speed up your program.

HTH,
Ala



------------------------------

Date: Wed, 7 Apr 1999 13:42:04 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: exponential notation to decimal notation
Message-Id: <MPG.117562e67a3d208e98985a@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <370B9E48.3D23@ic.delcoelect.com> on Wed, 07 Apr 1999 
11:04:56 -0700, Micah G. Cook <mgcook@ic.delcoelect.com >says...
> Looking for a module to convert exponential notation
> to decimal notation, I found one that will convert
> decimal notation to exponential notation, but not 
> the other way around.

I don't know about a module.

Here is a simple program that may meet your needs and give you something 
to modify or extend.  It's not completely clear what you mean by 
'decimal notation'.  I have chosen to strip trailing zeros from the 
fractional part and a trailing decimal point from integers.  The '20' is 
arbitrary, of course.

#!/usr/local/bin/perl -w
#use strict;

foreach (<DATA>) {
    s{((?:\d+\.?\d*|\.\d+)[eE][+-]?\d+)}{
        local $_ = sprintf '%.20f', $1;
        s/0+$//; s/\.$//;
        $_
    }eg;
    print;
}
__END__
1E0 1E6 1E20 1e-1 1e-6 1e-20
-1E0 -1E6 -1E20 -1e-1 -1e-6 -1e-20

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Wed, 07 Apr 1999 13:12:19 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: here docs vs qq quote operator. Just personal preference?
Message-Id: <370BBC23.FB0015A4@mail.cor.epa.gov>

Jerome O'Neil wrote:
> 
> Abigail wrote:
> 
> > Nah.  It's as easy to change q{$foo} to qq{$foo} as it is to change
> > "$foo" to q "$foo", or '$foo' to qq '$foo'.
> 
> OK, so its a poor example.  It becomes a bit more problematic with
> longer strings.
> 
> q{Abigail's JAPH said "Foo"};
> qq{Abigail's JAPH said "$foo"};
> 
> Quote-like metacharacters are a Good Thing.  Thats my story, and I'm
> sticking to it.

I'm on Jerome's side on this one.  I find q// and qq// 
extremely useful in one-liners.  Then I only have to change the
outer quotes after -e to get the thing to run on win32 also.
Having lots of ' and " to manhandle inside the quotes isn't nearly 
as nice.

David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


------------------------------

Date: Wed, 07 Apr 1999 19:09:23 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Most elegant random string generator?
Message-Id: <370bacda.1407508@news.skynet.be>

Greg McCann wrote:

>The following simple program generates a random string of characters
>(it's being used as a session ID in a web application).  It works well,
>but being new to Perl I'm wondering if there is a more efficient and/or
>elegant way of doing this - without being TOO obfuscatory!
>
>(BTW, a simple chr(rand $something + $something_else) does NOT work
>because digits, l.c. alpha, and u.c. alpha are not consecutive in ASCII)

	$n = chr(int(rand 36));
	$n =~ tr/\000-\023/0-9A-Z/;

You can collect and combine all characters first, and do the tr/// on
the whole.

	Bart.


------------------------------

Date: Wed, 07 Apr 1999 15:38:36 -0500
From: David Delikat <ddelikat@protix.com>
Subject: Re: Perl calls PGP
Message-Id: <370BC24C.15FB@protix.com>

cryptoman@my-dejanews.com wrote:
> 
> Hi,
> 
> I am trying to write Script to call PGP's functions:
> 
> open (WRITEME, "|pgpv message.sig -o message");
> print WRITEME "\n";
> close (WRITEME);
> 
> It should force a Carriage Return when PGP asks:
> "File to check signature against [message]: "
> 
> But it doesn't work. I tried the same script on "rm -i test.txt" and it
> works. Could u tell me is there any probleme with PGP or do I have to do it a
> different way.
> 
> Thanks!
> 
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own

PGP is probably purging STDIN (or something like that) before 
it waits for the keystroke.  in which case your program has 
to wait until PGP prints out the prompt before it sends the CR.

-dav

-- 
<((((><
Consultant: Internet, Database, Business Systems
Unix/Linux, Windows95/NT
mailto:david-delikat@usa.net / http://obj.webjump.com/


------------------------------

Date: Wed, 07 Apr 1999 15:05:38 -0500
From: Eric Von Zee <evonzee@tritechnet.com>
Subject: perl reading files/text from commandline under NT
Message-Id: <370BBA92.A44E1629@tritechnet.com>

Hey all,

I'm on a NT box, and writing a little program that allows communication
on a UDP port.  The program should allow two specific users to send
messages/files back and forth.

My question is this: I need to be able to accept a command line
parameter of either a filename or a message, and also allow and
interactive mode when no parameters are entered.  However, sometimes my
code can suck in the contents of a file (which I discovered because of a
typo), and other times the name only, depending on how I checked the
contents of @ARGV.  Here is some sample code, along with descriptions of
what happens..

Version 1:

----- BEGIN CODE
use IO::Socket;     #for socket ops
use strict;         #avoid soft refs, barewords, broken stuff

my($sendto) = 'base10';  #computer name to send to, hardcoded
my(@message);            #define the message variable

#############
#get_message_text is the interactive portion, go there if theres
#nothing in argv..
#############

if (@$ARGV = "") {@message = &get_message_text;}else{@message = @ARGV;} 

#############
# I know   ^ that should be '==' but the typo
# creates an interesting effect..
#############

&sendmsg($sendto, @message);
sub sendmsg {

   #############
   #taken from the Perl Cookbook
   #source code listing in Chap. 17
   #############

   my($sock, $server_host, $msg, $PORTNO);

   $PORTNO      = 7224;
   $server_host = shift;
   $msg         = "@_";   # I guess this is like join(" ", @_); ???
   
   $sock = IO::Socket::INET->new(Proto     => 'udp',
                                 PeerPort  => $PORTNO,
                                 PeerAddr  => $server_host)
       or die "Creating socket: $!\n";
   print "Sending message $msg";
   $sock->send($msg) or die "send: $!";
}

----- END CODE

That sucks in the contents of the file and sends them.  however, if I
make one minor change to teh source, as follows:

----- BEGIN CODE

use IO::Socket;
use strict;

my($sendto) = 'base10';
my(@message);
if (!defined(@ARGV)) {@message = &get_message_text;}else{@message =
@ARGV;}
#sendmessage sub is the same

----- END CODE

it gets me the filename.  SO I thought the assignment of a null string
to @$ARGV had something to do with it, so I tried this:

----- BEGIN CODE

if (!defined(@ARGV)) {@message = &get_message_text;}else{
   if (-e $ARGV[0]) {
      @$ARGV = "";
      print "file mode.\n";
   }
   @message = @ARGV;  
}

----- END CODE

but that passed the text only, not the contents of the file again. 

I guess what I really need to know is what does @$ do to an array (and
how do I use it), and why does it act differently when in a 'if' check
or not?

Thanks much,

-eric


-- 
Q: How does a quantum logic chicken cross the road?
A. The chicken is distributed probabilistically on
   all sides of the road until you observe it on 
   the side of your choice.
   
*------------------------------------------------------*
*    eric von zee     *------* tritech marketing inc.  *
*   web  developer    *------* evonzee@tritechnet.com  *
*  www.tritechnet.com *------*   630.654.0170 x 129    *
*------------------------------------------------------*


------------------------------

Date: Wed, 07 Apr 1999 15:23:08 -0500
From: Eric Von Zee <evonzee@tritechnet.com>
Subject: Re: perl reading files/text from commandline under NT
Message-Id: <370BBEAC.9B5E0D47@tritechnet.com>



Eric Von Zee wrote:
> 
> <snip lots of crap>
> 
> if (@$ARGV = "") {@message = &get_message_text;}else{@message = @ARGV;}
> 
> #############
> # I know   ^ that should be '==' but the typo

Make that 'should be 'eq' but the typo/dumb mistake'.

Also, the get_message_text uses a while (<>) to read the text, and it
would appear that it is getting called (apparently no matter what @argv
is) unless I change the conditional to be
if ($ARGV[0] eq "") { blah blah blah

So, from here I'm pretty sure I can get the program working, but I'm
still interested in knowing what the @$ construct does (I thought it
would 'stringify' the array, but I guess not?) and where I can pick up
info on more complex things like that.  I've got/read the cookbook, and
micheal foghlu's book ' perl5 quick reference', but foghlu's is really
basic (and has errors/typos/misexplanations everywhere), and the
cookbook doesn't have the 'dictionary' feel to it that I want.. it
answers specific questions great but if I need to find out what args
'pack' can take, I am forced to return to foghlu's alphabetized index,
or perldocs (which seem to leave out the insight type of stuff I need).

Thanks,

-e


-- 
Q: How does a quantum logic chicken cross the road?
A. The chicken is distributed probabilistically on
   all sides of the road until you observe it on 
   the side of your choice.
   
*------------------------------------------------------*
*    eric von zee     *------* tritech marketing inc.  *
*   web  developer    *------* evonzee@tritechnet.com  *
*  www.tritechnet.com *------*   630.654.0170 x 129    *
*------------------------------------------------------*


------------------------------

Date: Wed, 07 Apr 1999 12:35:13 -0700
From: jan.b.schipmolder@lmco.com (Schipmolder, Jan B.)
Subject: Re: pod2html: how to use?
Message-Id: <jan.b.schipmolder-ya02408000R0704991235130001@svlnews.lmms.lmco.com>

In article <370378c0.0@amhnt2.amherst.edu>, Laird Nelson
<ljnelson@unix.amherst.edu> wrote:

>I've read the FAQ, the pod2html usage message, the manpages and the
>source, and I still can't figure out how to use pod2html properly

I'm having the same problem, namely, I can't get pod2html to work properly.
I get the following error message(s):


--beginerrormessages--
pod2html: perl.pod: cannot resolve L<perlmodlib> in paragraph 53: no such
page 'perlmodlib'
pod2html: perl.pod: cannot resolve L<perlrun> in paragraph 73: no such page
'perlrun'
pod2html: perl.pod: cannot resolve L<perlsec> in paragraph 86: no such page
'perlsec'
--enderrormessages--

The resulting html files have proper #anchor names, but none of the L<name>
links are resolved. Any help would be welcome.

--
jan.b.schipmolder@lmco.com


------------------------------

Date: Wed, 07 Apr 1999 16:10:01 -0400
From: vinod kudva <vinod.kudva@eds.com>
Subject: Problem viewing data retrieved using PERL script on ORACLE database
Message-Id: <370BBB99.29BD@eds.com>

Hello

I have writen a PERL script that accesses ORACLE database and retrieves
the data.  But the browser does not wait for the data to be returned. 
At the UNIX prompt when I run the PERL script, I see the returned data. 
But when I run the script through the browser, the script executes but
the data is not shown on the browser.  Just the short messages that I
put in the script is returned.

I know that the time taken by the databse to return the data is long. 
Is there some way, that I can make the browser wait for all the data to
be returned before displaying it?


------------------------------

Date: Wed, 07 Apr 1999 19:26:47 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: random number ( -w )
Message-Id: <370bb151.2550717@news.skynet.be>

Abigail wrote:

><> What does the "-w" do?
>
>It does what the manual says it does!

That's good! Otherwise, it would have been a bug.

	Bart.


------------------------------

Date: 7 Apr 1999 20:19:53 GMT
From: rich@vax2.concordia.ca (Rich Lafferty)
Subject: Re: random number ( -w )
Message-Id: <7egel9$i1g$2@newsflash.concordia.ca>

Bart Lateur <bart.lateur@skynet.be> wrote:
> Abigail wrote:
> 
> ><> What does the "-w" do?
> >
> >It does what the manual says it does!
> 
> That's good! Otherwise, it would have been a bug.

But -w *is* a bug. Or so perl(1) tells me.

  -Rich

-- 
Rich Lafferty ---------------------------------------------------------
IITS/Computing Services     | "Oderint dum metuant."
Concordia University        |            -- Lucius Accius (170-90 BC).     
rich@vax2.concordia.ca -----------------------------------------[McQ]--


------------------------------

Date: Wed, 7 Apr 1999 14:11:44 -0400 
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: random number
Message-Id: <x3y4smsnvvj.fsf@tigre.matrox.com>


northernnj@my-dejanews.com writes:

> #!usr/bin/perl -w
> srand;
> @array = (1 .. 10);
> $random_number = "rand(@array)";
> print = "$random_number\n";
> 
> 
> I get:
> rand 1 2 3 4 5 6 7 8 9 10

Something is wrong. This code shouldn't even compile. Never type in
you code. Paste it in.



------------------------------

Date: Wed, 07 Apr 1999 13:44:54 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Recursion in Perl
Message-Id: <370BC3C6.8987D4CF@mail.cor.epa.gov>

Ala Qumsieh wrote:
> 
> David Delikat <ddelikat@protix.com> writes:
> 
> > HMMM, let me venture a guess...
> >
> > perldoc recursive
> 
> Is that a joke? I don't get it. No such pod exist.

Wasn't there some sort of ng obligation to make the standard
'definition of recursion' joke here?
 
David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


------------------------------

Date: Wed, 07 Apr 1999 12:46:41 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: system problem
Message-Id: <370BB621.EDB720BA@mail.cor.epa.gov>

Chim Kin Sang wrote:
> 
> Hi,
>         I have write a code in PERL which have to call a csh script and
> pass some argument to it.
> But I found some problem on the command system. Can someone give me some
> suggest?
> 
> If I am in csh. I have to type                  graph.csh 1 1 DATA >
> test
> which graph.csh is the csh script,
> 1 1  are two arguments the scirpt needed
> DATA is the file that the csh scirpt act on
> test is just the STDOUT file
> 
> If I write in PERL
>     system("graph.csh 1 1 DATA > test");
> it don't work. And the most strange thing is that
> it blamed on my csh script and said error on the
> csh script which it run ok on csh.
> 
>    I know that PERL call up the sh but not csh.
> Did it causes the problem?
> 
> Thanks
> Jim

It may have.  What would you expect to see if you
used sh to run your csh script from the command
line?  A similar error message?  BTW, you can find 
out if it really wa a Perl error message or your
system complaining.  Check out perldiag. [I suggest
the command 'perldoc perldiag', but you may want
to use 'man' or your favorite pager.]  It has a
list of *all* the Perl error messages.  If the
error you saw wasn't in there, it wasn't Perl
who sent the error message.

On the other hand, since you haven't shown us any code,
the error could be anywhere.

On the gripping hand, you would be much better off
in the long run if you re-wrote your programs so
that Perl handled the bits that are in your csh
script too.  You would have to re-think the program
some, since Perl does many things much more cleanly
and simply than csh.

David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


------------------------------

Date: Wed, 07 Apr 1999 16:08:52 -0400
From: vinod kudva <vinod.kudva@eds.com>
Subject: test
Message-Id: <370BBB54.2069@eds.com>

test


------------------------------

Date: Wed, 07 Apr 1999 20:02:57 GMT
From: drgreer@qtiworld.com (Darren Greer)
Subject: Re: Trouble with Oraperl, and simple select statement
Message-Id: <370bb938.152711257@news.qgraph.com>

-->$ENV{'LD_LIBRARY_PATH'} = $ORACLE_HOME/lib;
-->$ENV{'ORACLE_HOME'} = $ORACLE_HOME;
-->
-->**Where $ORACLE_HOME is your oracle install directory
-->
-->Example:
-->
--># Environmental Vars
-->$ENV{'LD_LIBRARY_PATH'} = '.../oracle/products/8.0.3/lib';
-->$ENV{'ORACLE_HOME'} = '.../oracle/products/8.0.3/';
-->
-->
-->Also the SQL statement is questionable, but I'm no SQL guru either.  I
-->suggest you put '|| die $ora_errstr' after every function call. This will
-->give you a descent error message at the command line as to what is going
-->wrong.  O'yeah you must run this at the command line
-->not through the web.  Else you error messages will be hidden.

No luck...it still locks up....I ran it through the debugger, and this
is where it locks up:

  DB<1> 
DBD::Oracle::dr::connect(/opt/perl5/lib/site_perl/DBD/Oracle.pm:206):
206:            DBD::Oracle::db::_login($dbh, $dbname, $user, $auth)
207:                or return undef;
  DB<1> 

This complete confuses me....not sure what is going on.  Any thoughts
are appreciated,

Darren



------------------------------

Date: Wed, 7 Apr 1999 14:09:01 -0600
From: "Gary Fritz" <fritz@frii.com>
Subject: Use Perl as parser?
Message-Id: <zXOO2.200$2O7.178284544@news.frii.net>

Sorry if this is a FAQ, but I couldn't find it anywhere, soo...

I'd like to write a Perl script to manipulate a C-like language.  I want to
strip out comments, munge the identifier names, etc.

Stripping the comments (enclosed in { }'s) isn't too hard, especially if I
assume there won't be any {}'s inside quoted strings &etc.  Munging the
names is simple -- I'll just detect the variable declarations and build a
hash of clearname/mungedname for later use.

But writing the Perl code to parse the language seems like it might be a bit
tricky for someone of my limited experience, and I suspect it's been done
many, many times before.

I'd like a function I can call that returns the next "symbol," where
"symbol" is either an identifier or keyword (something that starts with
alpha, then alphanumeric, the usual), a number, or some collection of
non-alphameric chars (arith ops, semicolons, parens, that sort of thing).
I'd be perfectly satisfied if the function returned non-alphamerics all at
once, e.g. given "A[1]=+(x/y)" it returned "]=+(" all in one chunk.  Extra
points if the function returns entire multi-line nested comments as one
symbol.  (I would think it would HAVE to return an entire string as one
symbol, no?)  Note:  the language I'm working with uses spaces as
significant separators, i.e. it's not safe to smash out all spaces.

Does anyone out there have such a beastie that they'd be willing to share?

Thanks!
Gary





------------------------------

Date: Wed, 07 Apr 1999 16:34:51 -0400
From: "Mark B. Lefevre" <mlefevre@cadence.com>
Subject: Using a variable in pattern matching operator
Message-Id: <370BC16A.EAF1E973@cadence.com>

I am using a variable in a pattern matching operator and I don't
understand why the following two
code snippets behave differently:

$pat = "cell";
if (/\b$pat\b) {.....

versus

$pat = "\bcell\b";
if (/$pat/) {....

Why the different behavior ?



------------------------------

Date: Wed, 7 Apr 1999 15:51:19 -0500
From: "Jay J" <SpamMeNOT.3pound@iname.com>
Subject: Re: Using a variable in pattern matching operator
Message-Id: <lvPO2.703$s4.4480716@rsnws01.mn.mediaone.net>

The first one's broken, that's why..
Perl should complain: Search pattern not terminated

Cuz it's not - if (/\b$pat\b/) ... however, would work fine.

-Jay J

Mark B. Lefevre <mlefevre@cadence.com> wrote in message
news:370BC16A.EAF1E973@cadence.com...
> I am using a variable in a pattern matching operator and I don't
> understand why the following two
> code snippets behave differently:
>
> $pat = "cell";
> if (/\b$pat\b) {.....
>
> versus
>
> $pat = "\bcell\b";
> if (/$pat/) {....
>
> Why the different behavior ?
>




------------------------------

Date: Wed, 07 Apr 1999 16:52:13 -0400
From: "Mark B. Lefevre" <mlefevre@cadence.com>
Subject: Re: Using a variable in pattern matching operator
Message-Id: <370BC57C.94E0384C@cadence.com>

Jay,

Thank you.  That was a typo on my part.

$pat = "cell";
if (/\b$pat\b/) {.....

versus

$pat = "\bcell\b";
if (/$pat/) {....

What I am trying to do is use a -w command line option for the perl
script to match the argument
as a word.  I'd like to modify the pattern to include the \b's.

Mark

Jay J wrote:

> The first one's broken, that's why..
> Perl should complain: Search pattern not terminated
>
> Cuz it's not - if (/\b$pat\b/) ... however, would work fine.
>
> -Jay J
>
> Mark B. Lefevre <mlefevre@cadence.com> wrote in message
> news:370BC16A.EAF1E973@cadence.com...
> > I am using a variable in a pattern matching operator and I don't
> > understand why the following two
> > code snippets behave differently:
> >
> > $pat = "cell";
> > if (/\b$pat\b) {.....
> >
> > versus
> >
> > $pat = "\bcell\b";
> > if (/$pat/) {....
> >
> > Why the different behavior ?
> >



------------------------------

Date: Wed, 07 Apr 1999 18:55:02 GMT
From: christianarandaOUT@OUTyahoo.com (Christian M. Aranda)
Subject: verifying programs can execute
Message-Id: <370ba907.18461806@news.bmc.com>

I have a script which has to system() at various points.  Well, we
don't want the script to system() and execute something that isn't
working properly, so I wrote this sub to check the validity of the
executables:

#########################
sub verify_programs {
my ($program);

   $Tar = "/bin/tar";
   $Rsh = "/bin/rsh";
   $Ftp = "/bin/ftp";

   foreach $program ($Tar, $Rsh, $Ftp) {
      if ( ! -X $program ) {
         die "Program $program is not where I thought it would be:
$!";
      }
   }
}

Now, there are obvious problems with this:  first of all, every time I
add a new program, I'll need to put a new variable in the foreach
line.  There must be a better way to accomplish this.  Or perhaps I've
found the best way, and no one will have any suggestions <j/k> :)

All feedback is appreciated and welcomed!

---------------------------------
Christian M. Aranda


------------------------------

Date: Wed, 7 Apr 1999 11:31:36 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: wanted: elegant inverse operation for vec
Message-Id: <ootfe7.5e3.ln@magna.metronet.com>

William Blasius #42722 (Wm.Blasius@ks.sel.alcatel.de) wrote:

: the Subject pretty much says it all. I'm trying to come up with an
: elegant way to turn a sparse bitfield into a set of "bit numbers".
: ie: 00100100 becomes 2 5
: I'd happily settle for an algorithm to get the number for a single
: bit, but I'm having a bit of a bad brain day. There must be a good
: popular idiom for this, iteration seems so...so...so...repetitive!


   I dunno how to do it without iteration, so here it is with
   iteration.

   It is not clear whether you want to manipulate a real bit vector,
   or a string of one and zero chars, so I did both.

   Note that this destroys the vector, but hopefully it will
   get you past your bad day.

---------------------
#!/usr/bin/perl -w
use strict;

### bits are chars in a string
$_ = '00100100';
for (my $pos=0;   $_;   chop, $pos++) {
   print "$pos " if /1$/;
}
print "\n";


### bits are real bits
$_ = 0x24;
for (my $pos=0;   $_;   $_>>=1, $pos++) {
   print "$pos " if $_ & 1;
}
print "\n";
---------------------


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

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 5322
**************************************

home help back first fref pref prev next nref lref last post