[9110] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2728 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 26 17:08:26 1998

Date: Tue, 26 May 98 14:00:26 -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           Tue, 26 May 1998     Volume: 8 Number: 2728

Today's topics:
        Bi-directional IPC in Perl for Win32 <bjs@iti-oh.com>
        format and ~~ <prl2@lehigh.edu>
    Re: format and ~~ <rootbeer@teleport.com>
    Re: GNU attacks on the open software community <vonbrand@inf.utfsm.cl>
    Re: GPL documentation == unspeakable evil <hp@pobox.com>
        grep -v? (Shawn Laemmrich)
    Re: grep -v? <rootbeer@teleport.com>
        Inplace file editing within a perl program <apollock@Xlibrary.berkeley.edu>
        list context: || vs or (Matt Knecht)
    Re: MakeMaker: How to run preprocessors? (Earl Hood)
        Perl Tutorials - Boulder, CO & Naperville, IL <johnd@xor.com>
    Re: Perl without cgi <jc@ral1.zko.dec.com>
    Re: Problem reading large files under Win95 (Vasile CALMATUI)
        regexp to delete trailing spaces? <rcyahnke@doit.wisc.edu>
    Re: scope of variables in Perl under Linux <keithmur@mindspring.com>
        SECURITY - simple perlscript for taking orders nem@aae.com
    Re: SQL statement parser (Matt Knecht)
    Re: SQL statement parser <prl2@lehigh.edu>
        system question <eglamkowski@angelfire.com>
    Re: UNIX Radius & Perl (Matt Knecht)
    Re: UNIX Radius & Perl <andy@wonderworks.co.uk>
    Re: utility which can POST web queries <rootbeer@teleport.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 26 May 1998 15:59:37 -0400
From: "Brian J. Sayatovic" <bjs@iti-oh.com>
Subject: Bi-directional IPC in Perl for Win32
Message-Id: <6kf771$sh9$1@malgudi.oar.net>

I've come to the dead-end conclusion that bi-directional IPC doesn't work in
Perl for Win32 as it does in UNIX.  The Open2 module dies complaining that
fork isn't implemented in NT.

Are there any alternative methods to accomplish this in NT?

Brian.




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

Date: Tue, 26 May 1998 15:10:56 -0400
From: "Phil R Lawrence" <prl2@lehigh.edu>
Subject: format and ~~
Message-Id: <6kf43t$1326@fidoii.cc.Lehigh.EDU>

Hey, I want to do a multi-line fill.  First I tried:
__________________________________
my $text = "Check Me Out\n1     2      3\n";
format =
blah
^|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
~~
$text
blah
 .
write;
__________________________________

But that outputs:
blah
                          Check Me Out 1     2      3
blah

Notice my newlines are ignored!  Next I tried the shift method (because I want
those newlines):
_________________________________
my @text = ("Check Me Out\n", "1     2      3\n");
format =
blah
@|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
~~
shift @text
blah
 .
write;
_________________________________

This gives the following error along with the output I wanted:
Use of uninitialized value at ./test.pl line 10 (#1)
  ## Note:  Line 10 is 'shift @text' ##

    (W) An undefined value was used as if it were already defined.  It was
    interpreted as a "" or a 0, but maybe it was a mistake.  To suppress this
    warning assign an initial value to your variables.

blah
                                  Check Me Out
                                 1     2      3
blah


So, the shift/@ method seems to be what I want, but how can I get rid of that
error message?

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Phil R Lawrence               phone: 610-758-3051
Programmer / Analyst      e-mail: prl2@lehigh.edu
194 Lehigh University Computing Center
E.W. Fairchild - Martindale, Bldg. 8B
Bethlehem, PA  18018
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





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

Date: Tue, 26 May 1998 20:36:32 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: format and ~~
Message-Id: <Pine.GSO.3.96.980526133519.27437j-100000@user2.teleport.com>

On Tue, 26 May 1998, Phil R Lawrence wrote:

> So, the shift/@ method seems to be what I want, but how can I get rid of
> that error message? 

Maybe you want this?

    @text ? shift(@text) : ''

Hope this helps!    

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/




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

Date: 26 May 1998 16:28:10 -0400
From: Horst von Brand <vonbrand@inf.utfsm.cl>
Subject: Re: GNU attacks on the open software community
Message-Id: <m1ra1gojz9.fsf@pincoya.inf.utfsm.cl>

Barry Margolin <barmar@bbnplanet.com> writes:

[...]

> The Hurd has some very grandiose ideas for features that RMS is interested
> in promoting (mostly some features he misses from OSes like TOPS-20 and
> ITS).  Linux, I believe, is more modest in its goals -- it's basically just
> another POSIX-compliant system.  The Hurd is POSIX compliant as well, but
> by basing it on a microkernel, they provide the hooks for many interesting
> extensions, and they have plans to use them.

As long as it's just plans and grandiose ideas... Hurd is _still_ 0.2,
still totally unusable (never could get grub to grok the disks of a
standard PC clone), and dates from June 12, 1997. Linux started way later
than the hurd, and it just _works_.

Seems to me FSF completely screwed up on assigning development effort, and
even more so on recruiting people willing to work for free/the sheer fun of
it.  For some reason or other they seem to have left for greener pastures,
most of them.

Don't get me wrong: I sincerely admire the enormous amount of work done by
the FSF, and I'm grateful for the software it has given all of us. I think
it is sad to see it in the current stand.
-- 
Dr. Horst H. von Brand                       mailto:vonbrand@inf.utfsm.cl
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513


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

Date: Tue, 26 May 1998 20:34:43 GMT
From: robert havoc pennington <hp@pobox.com>
Subject: Re: GPL documentation == unspeakable evil
Message-Id: <wsnogwkpy8s.fsf@harper.uchicago.edu>

birgitt@my-dejanews.com writes:
> 
> I understood that part, I just don't understand how you can
> ever get out of a GPL license if you have to get permissions
> from so many authors who might have made only relatively
> small contributions.
> 

This isn't a consequence of the GPL, it's a consequence of copyright
law. You have to have permission to do whatever you do with a piece of
copyrighted software. That means permission from whoever has the
copyright - if there are many authors, and they all have the copyright
on their contributions, then you have to get permission from all of
them unless the license already gives you the permissions you want.
Alternatively, you can replace their code with code you control the
permissions of. If their contributions are really small this should be
no problem. 

You are quite right that in effect most free software projects are
"stuck" with the license that they have, because there are so many
contributors. The only exception is that a less-restrictive license
can maybe moved to a more-restrictive, since the necessary permissions
are already granted. This is why BSD code can be included in
proprietary code. The GPL generally can't be changed to another
license (unless you own the copyright) due to the GPL's restrictions.
That is in fact the point of the GPL.

Havoc Pennington ==== http://pobox.com/~hp


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

Date: 26 May 1998 20:19:37 GMT
From: swlaemmr@dilbert.tdg.mtu.edu (Shawn Laemmrich)
Subject: grep -v?
Message-Id: <6kf84p$26p$1@campus1.mtu.edu>

I need to write a simple script that searches line by line through a text file and
finds any characters that are NOT letters or numbers.  In bourne shell I would use a
grep -v to do this, how do I do it in perl?

Thanks

Shawn


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

Date: Tue, 26 May 1998 20:38:51 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: grep -v?
Message-Id: <Pine.GSO.3.96.980526133753.27437k-100000@user2.teleport.com>

On 26 May 1998, Shawn Laemmrich wrote:

> I need to write a simple script that searches line by line through a
> text file and finds any characters that are NOT letters or numbers. 

You may want to use the tr/// operator in a scalar context. It's
documented in perlop. Hope this helps! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 26 May 1998 13:24:52 -0700
From: "Alvin Pollock" <apollock@Xlibrary.berkeley.edu>
Subject: Inplace file editing within a perl program
Message-Id: <6kf88i$brv$1@agate.berkeley.edu>

Deep within a perl program I would like to open up a set of files
and edit them inplace, much as I could do with the -pi switch
on the perl command line. I can create temp files and delete them
when I am through but I would rather not do that. Can anybody suggest
the easiest way to do this? I've never found any examples of the
syntax used to do this with open (FILE, "+<filename"), and I'm not
even sure I can use this construct on Windows 95, my target platform.

Specifically I want to loop through each line and do a search and replace
on a substring, just like if I did:

perl -pi -e 's/this/that/g;' filename

on the command line.

Alvin Pollock
ratty11@hotmail.com




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

Date: Tue, 26 May 1998 20:22:16 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: list context: || vs or
Message-Id: <YvFa1.250$j4.989911@news3.voicenet.com>

I've noticed some odd behaviour when using || as opposed to or.  The
following script explains it better than I could:

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

my ($fname, @stat, $elem);

$fname = "/tmp/$$.test";

open(FILE, ">$fname") || die "Can't open $fname: $!";
close(FILE) || warn "Could not close $fname: $!";

#@stat = stat($fname) or die "error:$!";
@stat = stat($fname) || die "error:$!";

foreach $elem (@stat) {
	print "element: $elem\n";
}
print "\n";

unlink $fname;
########################################

@stat gets the value of 1 when using || (Actually, $stat[0]).
When using 'or' @stat gets filled as per stat().  

As far as I understand, the only difference between || and or should
be precedence.  ||'s behavious makes even less sense after reading
perldoc perlop.  Here is the section I'm refering to:

     C-style Logical Or

     Binary "||" performs a short-circuit logical OR operation.
     That is, if the left operand is true, the right operand is
     not even evaluated.  Scalar or list context propagates down
     to the right operand if it is evaluated.

     The || and && operators differ from C's in that, rather than
     returning 0 or 1, they return the last value evaluated.
     Thus, a reasonably portable way to find out the home
     directory (assuming it's not "0") might be:

         $home = $ENV{'HOME'} || $ENV{'LOGDIR'} ||
             (getpwuid($<))[7] || die "You're homeless!\n";

     As more readable alternatives to && and ||, Perl provides
     "and" and "or" operators (see below).  The short-circuit
     behavior is identical.  The precedence of "and" and "or" is
     much lower, however, so that you can safely use them after a
     list operator without the need for parentheses:


The last value evaluated should be the array returned from stat(), not
the truth of the operation.  Am I misreading perlop?

System info:
$ perl -V
Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration:
  Platform:
    osname=solaris, osvers=2.6, archname=sun4-solaris
    uname='sunos freebird 5.6 generic sun4m sparc sunw,sparcstation-10 '
    hint=recommended, useposix=true, d_sigaction=define
    bincompat3=y useperlio=undef d_sfio=undef
  Compiler:
    cc='gcc', optimize='-O', gccversion=2.7.2.3
    cppflags='-I/usr/local/include'
    ccflags ='-I/usr/local/include'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    voidflags=15, castflags=0, d_casti32=define, d_castneg=define
    intsize=4, alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc
    libc=/lib/libc.so, so=so
    useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fpic', lddlflags='-G -L/usr/local/lib'


Characteristics of this binary (from libperl): 
  Built under solaris
  Compiled at Nov 26 1997 18:18:41
  @INC:
    /usr/local/lib/perl5/sun4-solaris/5.00404
    /usr/local/lib/perl5
    /usr/local/lib/perl5/site_perl/sun4-solaris
    /usr/local/lib/perl5/site_perl
    .
-- 
Matt Knecht + <hex@voicenet.com>


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

Date: 26 May 1998 18:35:15 GMT
From: ehood@geneva.acs.uci.edu (Earl Hood)
Subject: Re: MakeMaker: How to run preprocessors?
Message-Id: <6kf213$djq@news.service.uci.edu>

In article <896084059.465302@thrush.omix.com>,
Zenin  <zenin@bawdycaste.org> wrote:
>I'm trying to find a way to get MakeMaker to run my modules through a
>preprocessor such as cpp or such while "building" (copying them to the
>./blib directory).  Is there any way to do such a thing?  I thought about
>trying to override pm_to_blib(), but this looked like a *major* pain when
>all I really only want to override the copy() function (blagh, why couldn't
>it be a method...) it uses.

You may want to look at the Makefile.PL that comes with GetoptLong.
Johan Vromans generates the module to be installed from separate source
files by using the MY::postamble routine (to create a make target), and
setting the PM attribute accordingly.  I am guessing you can do
something similiar.

	--ewh
-- 
             Earl Hood              | University of California: Irvine
      ehood@medusa.acs.uci.edu      |      Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME


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

Date: Tue, 26 May 1998 13:54:33 -0700
From: John Donnelly <johnd@xor.com>
Subject: Perl Tutorials - Boulder, CO & Naperville, IL
Message-Id: <356B2C09.632B@xor.com>

Beginning/Advanced Perl Programming Tutorials
                Boulder, CO & Naperville, IL
For complete write-ups (who  should  attend;  prerequisites;
course  outline)  and registration information, please visit
our Web site:  http://www.xor.com/training,  send  email  to
training@xor.com,  or call XOR Network Engineering's Training
Coordinator - 800-XOR-4404, 303-448-4800.

                **Register on-line and save 15%**
                   http://www.xor.com/training
                                *****

               Introduction to Perl for Programmers
              (3 day, hands-on, lecture/lab format)
                        Tuition: $995
               Naperville, IL - June 22-24, 1998
                  Boulder, CO - July 8-10, 1998
   Designed to  be  programmer-friendly  and  platform-neutral,
   Perl  is  a high-level, general-purpose programming language
   that makes easy and medium-hard  tasks  easy  and  seriously
   non-trivial  tasks  possible.   Now  moving  into its second
   decade, Perl has become the language of  choice  across  all
   platforms for programmers engaged in rapid prototyping, sys-
   tem utilities, software tools, system management tasks, data
   base  access, graphical programming, and world wide Web pro-
   gramming.
   NOTE: While this course is based on the current  release  of
   Perl  (version  5.004),  it is not intended to be a detailed
   discourse  on  all  advanced  programming   constructs   now
   afforded  by  that release.  It is a jump-start introduction
   to Perl for experienced programmers, not an advanced  course
   for Perl programmers.


                    Advanced Perl Programming
              (3 day, hands-on, lecture/lab format)
                        Tuition: $995
                  Boulder, CO - June 15-17, 1998
                Naperville, IL - July 15-17, 1998
   This course presents everything you'll  need  to  completely
   master  advanced Perl programming using features and facili-
   ties from the latest release of Perl, the 5.004 release.


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

Date: Tue, 26 May 1998 15:59:39 -0400
From: John Chambers <jc@ral1.zko.dec.com>
Subject: Re: Perl without cgi
Message-Id: <356B1F2B.DDB43DBD@ral1.zko.dec.com>

Jonathan K. Cohen wrote:

> I think what you're asking is whether it's possible to execute client-side
> Perl in a browser, in the same way as you can execute client-side Java.
> The answer
> is that nobody I know of has yet written a browser that incorporates a
> Perl interpreter. It's an interesting idea, ...

Well, you obviously haven't been looking at any of my code!  (Oh, well, 
maybe it's because I didn't tell you about it. ;-)

For some time, I've had a personal "html viewer" that I wrote primarily as
a tool for testing web pages. The GUI is mostly written as a wish (tcl/tk)
script, but it calls assorted subprocesses to do part of its work, most of
which are written in perl.  The main reason for doing it myself is the lack
of debugging hooks with the available browsers.  But whatever the excuse,
the fact is that even the dumbest "html viewer" will function as a browser,
and I often use my little tool as such.  (The fact that its window appears
within a second or so of when I hit Return is a major factor in its favor,
despite its lack of frame support.   I can check out 3 or 4 web documents
in the time it takes for Netscape to open its first window.  ;-)

The Web is in fact easily accessible to programs other than browsers.  In
fact, those little monsters are becoming so bloated that you might reasonably
argue that a browser is now the most difficult way to use the Web.  If you
want some clues on how to write your own Web apps, try the following:
   : telnet home.netscape.com 80
   GET /
where you can, of course, use any other web server instead of Netscape's.
This just might be enough of a clue to get some readers started on hacking
together their own Web tools, most of which will probably be in perl ...

> Still, I think there might be performance and size issues that could weigh
> against doing so.

Nah; perl works just fine for the job.  (But I've gotta say that the CGI
module has itself become so large and abstruse that I can almost always get
the job done faster - and get much better performance - if I write it myself
from scratch. And I'll understand the resulting code. ;-)

I'd bet that I'm not nearly the only person in the world who has been doing
such things. But who wants to get sucked into a battle with Bill Gates? It's
better to keep sorta quiet if you are writing things that some gorilla might 
mistake for a competing browser ...


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

Date: Tue, 26 May 1998 20:06:50 GMT
From: vasile@club-internet.fr (Vasile CALMATUI)
Subject: Re: Problem reading large files under Win95
Message-Id: <356b1da2.5608404@news.club-internet.fr>

vasile@club-internet.fr (Vasile CALMATUI) wrote:
>I have a problem with big files under  Win95.
>
>The problem is that I can read only the first 4-5 Mb from the file (total length is 25 Mb).
>It works well by splitting the file in some little files of 4 Mb.
>PS : I'm using Perl for Win32 "normal version" (not ActiveState) version 5.004_02

OK, I will re-explain the problem here.
I have a 25Mb text file made by a mail program. I want to take all the URLs
which are in this file. In most cases, an URL ends at the end of the line.
The problem is that the URLs at the end of the file were not matched.
Finally, I found the problem : the <FROM> never reached the end 
of the file.
So, by splitting the big file in some 4Mb files, it worked well.

The script is simple(little) enough, so I post it entirely.

#Takes all the UNIQUE URL from a file and put them in another file
my @fromFile = ("big25MbFile.txt");
my $outputFile = "allURL.txt";
my @all;

foreach $file (@fromFile) {
  #reading the file entirely
  open (FROM,"$file") || die "  Error opening file: $file\n";
  while (<FROM>) {
    my @url=/(http:.*)/;

    if(scalar(@url)>0) {
      push(@all,@url);
    }
  }
  close (FROM);
}

open (OUTPUT,">$outputFile") || die "  Error opening file: $outputFile\n";
print "We have ", scalar(@all), " URLs\n";
my $prev;
#for counting
my $count=0;
foreach $curr (sort @all) {
  #ignoring the same URLs
  if($curr ne $prev) {
    print OUTPUT $curr, "\n";
    $count++;
    $prev=$curr;
  }
}
close (OUTPUT);

print "We have $count unique URLs";

- -
Vasile Calmatui
vasile@club-internet.fr
http://www.chez.com/vasile/


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

Date: Tue, 26 May 1998 15:33:55 -0500
From: "Ross Yahnke" <rcyahnke@doit.wisc.edu>
Subject: regexp to delete trailing spaces?
Message-Id: <6kf8vj$sb2$1@news.doit.wisc.edu>

Hi all - A newbie question here, what's a useful regexp to delete all the
trailing spaces in a string?

I.e., I want to change:
    "All that glitters               "

 ...to...
    "All that glitters"

Thanks in advance!

- Ross


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

Date: Tue, 26 May 1998 15:42:52 -0500
From: "Keith G. Murphy" <keithmur@mindspring.com>
Subject: Re: scope of variables in Perl under Linux
Message-Id: <356B294C.9A952601@mindspring.com>

Keith G. Murphy wrote:
> 
> Nathan Morse wrote:
> >
> > I have been wending my way through the beginning of Learning Perl, and have
> > been typing in the examples with some negligible personal modifications.
> > In the example that starts on p17 (in the 2nd edition, at least ;^), Moving
> > the Secret Word List into a Separate File, there is a fine demonstration of
> > creating a [by default] global variable within a subroutine.  Since I'd
> > been using the Win32 Perl that can't do file globs,
> What distribution is this, that doesn't support file globs?  The Sarathy
> distribution does globbing just fine on Win95, can't speak for other
> distributions or platforms.
> 
> I decided to transfer
> > my programs/scripts to a Linux machine.  Having cleaned up all the carriage
> > returns, I went merrily to testing the Perl to be sure everything behaved
> > well, and to try out proper glob behavior.  Since this init_words() sub
> > comes to have a globbing while loop in it on p22 (Many Secret Word Files in
> > the Current Directory), it was one of my first choices.  The only secret
> > word it was content to accept for _any_ given name was the default one
> > ("groucho" in their example).  After a bit of hunting and debugging, I
> > realized that the problem was that @words was empty/undefined outside of
> > init_words(), where it is created, but not via my().  :^(  That machine is
> > using Perl 5.003, but I didn't see anything in the 5.004 revision history
> > that indicated a problem with that.  What am I missing?  Thanks!!
> 
> Do you *know* whether it's getting filled in init_words()?  Time to
> familiarize yourself with perl -d, if you haven't already.  It's nice;
> trust me.
> 
> I'm going to go out on a *very* shaky limb here, since I can't get to my
> Linux system right now.  Might it be that your script isn't opening your
> .sec file(s) for some reason (protection or such)?  I could swear I've
> seen "|| die" not work as expected on Linux, and I had to use "or die",
> so maybe you can't open the file and you're not seeing the error.  Try
> your script with "or die".  (If I think of it, I'm going to verify this
> when I get home; it's been bugging me...)

That limb was so shaky, it broke right under me.  The example script
you're talking about worked perfectly for me, whether using "||" or
"or", under Win95 and Linux.  And when I made it have a file open error,
it showed it fine, either way.  The 'words' hash was getting filled just
fine.

Have you had any progress this weekend?


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

Date: Tue, 26 May 1998 20:20:15 GMT
From: nem@aae.com
Subject: SECURITY - simple perlscript for taking orders
Message-Id: <6kf85v$pjp$1@nnrp1.dejanews.com>

Hi All,

I'm still getting the hang of writing in Perl, and am just looking at
snippets of code from available scripts. My goal is to write my own script
that, along with an encryption certificate, will take in credit card orders,
write them to a flat txt file, send an email reminder to a staff person, and
then generate a custom HTML for the user to know it's been received.

I've got it up and running, but am wondering how secure it is. I started w/
simple mailto: routines, combined with a section that writes to the file. The
flat file is OUTSIDE of the w3 path, and the email reminder (that says to go
look at the file to process manually) does NOT contain any sensitive
information, such as the card type or number or exp. date.

Any pointers? I would include the script, but it's a bit long.

regards,
neal magee

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Tue, 26 May 1998 20:00:21 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: SQL statement parser
Message-Id: <pbFa1.248$j4.989911@news3.voicenet.com>

On Tue, 26 May 1998 19:22:11 GMT, Eric Chien <ecchien@jps.net> wrote:
>Has anyone written a module that parses an SQL statement and checks it
>for validity?  Basically something that parses the tokens and verifies
>the statement is complete and formed correctly.

I never saw the need for such a sub since DBI does the job already.  here is
what I use as a simple frontend for my databases:

sub query
{
	my $statement = shift;
	my ($sth);

	print "$statement\n\n" if $debug > 10;

	$sth = $dbh->prepare($statement)
		or die "FATAL: Could not prepare $statement: $dbh->{'errstr'}\n";

	$sth->execute
		or die "FATAL: Could not execute $statement\n\nCalled by line: ",
		(caller)[2], "\n\n$dbh->{'errstr'}\n";

	return $sth;
}


If you wanted to check for validity, you could use something like this.
Instead of die()ing on the prepare, you could return an error code, and
print out $dbh->{'errstr'} (assuming you've named your database handle
$dbh), or analyze $dbh->{'errstr'} and pretty print an error message.

-- 
Matt Knecht + <hex@voicenet.com>


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

Date: Tue, 26 May 1998 16:04:58 -0400
From: "Phil R Lawrence" <prl2@lehigh.edu>
Subject: Re: SQL statement parser
Message-Id: <6kf796$26u0@fidoii.cc.Lehigh.EDU>

Eric Chien wrote in message <356b161a.7742919@news>...
>Hello,
>
>Has anyone written a module that parses an SQL statement and checks it
>for validity?  Basically something that parses the tokens and verifies
>the statement is complete and formed correctly.


I have written a module that builds SQL statements based on what the user is
interested in.  Along the lines of your question, it makes sure the table names
aren't repeated, puts a FROM in the right place, etc.   Obviously it has a stock
of where clause snippets that it draws from.  Later I'll try to add optimizing
logic, haven't yet.  Let me know if your interested in what I've done.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Phil R Lawrence               phone: 610-758-3051
Programmer / Analyst      e-mail: prl2@lehigh.edu
194 Lehigh University Computing Center
E.W. Fairchild - Martindale, Bldg. 8B
Bethlehem, PA  18018
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





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

Date: Tue, 26 May 1998 16:48:31 -0400
From: the count <eglamkowski@angelfire.com>
Subject: system question
Message-Id: <356B2A9F.6CBB@angelfire.com>

I had to run dos2unix on a bunch of files, so I wrote a trivial perl
script to do it:

@ARGV = ('-') unless @ARGV;
while ($ARGV = shift) {
    system "dos2unix $ARGV > tmp;mv tmp $ARGV";
}

But then I had the idea:  what if I could generalize this to run
ANY command on a bunch of files?  Specify the command to run as
the first argument, and run it on the rest of @ARGV.  Only, I am
not particularly sure how to proceed.  I tried:

command.pl
----------
@ARGV = ('-') unless @ARGV;
$command = shift; # Yes, I need to check for the existance of this...

while ($ARGV = shift) {
    system "$command";
}

But, I am not even sure how to run it:
perl -w command.pl 'dos2unix $ARGV > tmp; mv tmp $ARGV' *.txt

This fails - it seems to start processing the first file:
could not open /dev/kbd to get keyboard type US keyboard assumed
could not get keyboard type US keyboard assumed

But then just hangs.
tmp exists, but is empty.

Any pointers on how to go about doing this?


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

Date: Tue, 26 May 1998 20:09:20 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: UNIX Radius & Perl
Message-Id: <QjFa1.249$j4.989911@news3.voicenet.com>

On Tue, 26 May 1998 19:05:03 GMT, Eric Alexander <cyrixdude@lancom.net> wrote:
>Hi, I'm needing a script that will open the detail file that Radius uses and
>clear out all the starts and stops except for the starts that do not have
>stops.. I am sort of good with Perl, but not that good. If anyone knows of a
>script to do this, or could possibly help me, please get in touch! Thanks!

This isn't as easy as it sounds.  I've found _many_ pitfalls in dealing with
Radius records.  A good start is:

http://www.livingston.com/Tech/Docs/RADIUS/guide/7account.html

There is also a public script directory at:

ftp://ftp.livingston.com/pub/le/contrib/

There are a few Radius parsing scripts in there that you can look at (Although,
IMHO, they leave a lot of loopholes).

-- 
Matt Knecht + <hex@voicenet.com>


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

Date: Tue, 26 May 1998 21:09:33 +0100
From: Andy Armstrong <andy@wonderworks.co.uk>
Subject: Re: UNIX Radius & Perl
Message-Id: <Z7XrqBA9Fya1Ew83@wndrwrks.demon.co.uk>

In article <znEa1.650$VX6.680629@news.randori.com>, Eric Alexander
<cyrixdude@lancom.net> writes
>Hi, I'm needing a script that will open the detail file that Radius uses and
>clear out all the starts and stops except for the starts that do not have
>stops.. I am sort of good with Perl, but not that good. If anyone knows of a
>script to do this, or could possibly help me, please get in touch! Thanks!

With respect Eric you seem to be expecting everybody else to know what
the file you want to process looks like. If you can contrive a /short/
but adequately representative example of the file perhaps you could let
us have a look at it.

-- 
** Don't CC any follow-ups to me - I *do* read the newsgroups I post to **
Andy Armstrong, Wonderworks, http://www.wonderworks.co.uk


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

Date: Tue, 26 May 1998 20:20:58 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: utility which can POST web queries
Message-Id: <Pine.GSO.3.96.980526131926.27437g-100000@user2.teleport.com>

On Tue, 26 May 1998, Jonathan Epstein wrote:

> Subject: utility which can POST web queries

> Which utility should I using (preferably one which is commonly used by
> others)? 

I think you should get LWP, which you'll find on CPAN. There's a lot of
support for it, including its own mailing list and the lwpcook manpage,
which shows plenty of good examples. Hope this helps! 

-- 
Tom Phoenix       Perl Training and Hacking       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 2728
**************************************

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