[22373] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4594 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 20 14:11:12 2003

Date: Thu, 20 Feb 2003 11:10:11 -0800 (PST)
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, 20 Feb 2003     Volume: 10 Number: 4594

Today's topics:
        Perl Library to execute stored procedures in MS-SQL Ser (Ye H. Aung)
    Re: Regular Expression Noob <perl-dvd@darklaser.com>
    Re: Regular Expression Noob <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Religious question: commenting <flavell@mail.cern.ch>
    Re: Religious question: commenting (Tony L. Svanstrom)
    Re: Religious question: commenting <mr@sandman.net>
    Re: Religious question: commenting <mr@sandman.net>
    Re: Religious question: commenting <tore@aursand.no>
    Re: Religious question: commenting <nobull@mail.com>
    Re: Religious question: commenting <tassilo.parseval@post.rwth-aachen.de>
    Re: Report physical RAM of a remote PC (Walter Roberson)
    Re: Simple regex question... <barryk2@SPAM-KILLER.mts.net>
        storing regex vars into array and not $1 $2 etc (John)
    Re: storing regex vars into array and not $1 $2 etc <nobull@mail.com>
    Re: storing regex vars into array and not $1 $2 etc (Tony L. Svanstrom)
    Re: storing regex vars into array and not $1 $2 etc (Andrew Perrin (CLists))
    Re: stripping part of a string <perl-dvd@darklaser.com>
    Re: Subroutine does not 'see' parameter passed to it <noreply@gunnar.cc>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 20 Feb 2003 07:11:38 -0800
From: ye_aung@nacm.com (Ye H. Aung)
Subject: Perl Library to execute stored procedures in MS-SQL Server
Message-Id: <7897a770.0302200711.5d58d195@posting.google.com>

Hello,

I am trying to write Perl wrapper to run stored procedure in MS SQL
Server. I am looking at the following two Perl modules:

(1) Win32::ODBC
(2) MSSQL::SQLLIB

Here are my requirements:

(1) I need to capture result data set from stored procedures
(2) I need to capture return codes from stored procedures

Unless I am doing wrong, I am unable to capture both result set and
return code from MS SQL Server using those two Perl modules. Can you
point out to me as to what other Perl modules are available to fulfill
my requirements or what I am doing incorrectly.

Here are a few things I learned about those two Perl modules:

(1) Win32::ODBC
It is good at capturing result data set from running SQL statements
such as SELECT, INSERT, UPDATE, and DELETE but not result data set
from stored procedures calls. It does not work for me.

(2) MSSQL::SQLLIB
It has 'sql_sp' function which requires special way of passing
parameters and my stored procedure calls are dynamic with unknown
number of parameters until run-time. It does not work for me.

Thank you,

Ye H. Aung
Database Administrator
Nicholas Applegate Capital Management
San Diego, California
Tel: (619) 652-5417
ye_aung@nacm.com


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

Date: Thu, 20 Feb 2003 14:47:45 GMT
From: "David" <perl-dvd@darklaser.com>
Subject: Re: Regular Expression Noob
Message-Id: <lU55a.47$F6.11214@news-west.eli.net>

"Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net> wrote in
message news:Xns93279D184CCE3elhber1lidotechnet@62.89.127.66...
> David wrote:
>
> > "Abigail" <abigail@abigail.nl> wrote in message
> > news:slrnb54tcr.263.abigail@alexandra.abigail.nl...
> >> David (perl-dvd@darklaser.com) wrote on MMMCDLVIII September
MCMXCIII
> > in
> >> <URL:news:gxt4a.25$F6.6438@news-west.eli.net>:
> >> []
> >> []  my @ani_list = $string =~ /ANI\=(\d+)/g; # untested
> >>
> >>
> >> Why did you escape the equal sign?
> >
> > Sorry, bad habit (escape any special characters).
>
>
> But the point is that '=' is not a special character. :)

That depends.  Define special character . . .

My definition of a special character is anything non alphanumeric, so in
other words, if its not a-zA-Z0-9 then its a special character.  I'm
certain you have your own definition.

Regards,
David




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

Date: Thu, 20 Feb 2003 14:50:51 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Regular Expression Noob
Message-Id: <Xns9328A0851CC84elhber1lidotechnet@62.89.127.66>

David wrote:

> "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net> wrote in
> message news:Xns93279D184CCE3elhber1lidotechnet@62.89.127.66...
>> David wrote:
>>
>> > "Abigail" <abigail@abigail.nl> wrote in message
>> > news:slrnb54tcr.263.abigail@alexandra.abigail.nl...
>> >> David (perl-dvd@darklaser.com) wrote on MMMCDLVIII September
> MCMXCIII
>> > in
>> >> <URL:news:gxt4a.25$F6.6438@news-west.eli.net>:
>> >> []
>> >> []  my @ani_list = $string =~ /ANI\=(\d+)/g; # untested
>> >>
>> >>
>> >> Why did you escape the equal sign?
>> >
>> > Sorry, bad habit (escape any special characters).
>>
>>
>> But the point is that '=' is not a special character. :)
> 
> That depends.  Define special character . . .
> 
> My definition of a special character is anything non alphanumeric, so in
> other words, if its not a-zA-Z0-9 then its a special character.  I'm
> certain you have your own definition.


The only definition which is relevant is Perl's definition. What difference 
does it make what your (or my) opinion is?


-- 
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'



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

Date: Thu, 20 Feb 2003 15:01:25 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Religious question: commenting
Message-Id: <Pine.LNX.4.53.0302201459150.26804@lxplus078.cern.ch>

On Thu, Feb 20, Tore Aursand inscribed on the eternal scroll:

> On Wed, 19 Feb 2003 16:08:30 -0600, Tad McClellan wrote:
> > Comments should say _why_ something is being done.
>
> Oh?  My comments always say what _really_ should have happened. :)

A tutor commenting on a student assignment "what a pity the compiler
didn't compile the comments and ignore the code".


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

Date: Thu, 20 Feb 2003 15:47:20 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Religious question: commenting
Message-Id: <1fqouma.omfwe01qz3p4wN%tony@svanstrom.com>

Sandman <mr@sandman.net> wrote:

> How do you comment code?

 It was hard to write... yada yada...

-- 
# Per scientiam ad libertatem! // Through knowledge towards freedom! #
# Genom kunskap mot frihet! =*= (c) 1999-2002 tony@svanstrom.com =*= #

    perl -e'print$_{$_} for sort%_=`lynx -source svanstrom.com/t`'


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

Date: Thu, 20 Feb 2003 17:03:56 +0100
From: Sandman <mr@sandman.net>
Subject: Re: Religious question: commenting
Message-Id: <mr-5FB39F.17035620022003@news.fu-berlin.de>

In article <3e54aa33.1117431361@news.cis.dfn.de>,
 helgi@decode.is (Helgi Briem) wrote:

> >I strongly suggest you stop focusing on the code, and start talking 
> >about  commenting. This is a useless discussion. Sorry. I 
> >suppose this is what I get for bringing up a topic as religious as 
> >this.
> 
> I don't think he should.  Every comment Tassilo has made
> has been spot-on.  It has taught me things I was
> better off knowing.
>
> You should focus more on the code and less on the 
> commenting.

In a thread about commenting? Odd.

-- 
Sandman[.net]


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

Date: Thu, 20 Feb 2003 17:11:30 +0100
From: Sandman <mr@sandman.net>
Subject: Re: Religious question: commenting
Message-Id: <mr-6B1FC7.17113020022003@news.fu-berlin.de>

In article <b32b4o$r0p$1@mamenchi.zrz.TU-Berlin.DE>,
 anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:

> > Sigh. It was an example. Stop focusing on the -code-. Or are you claiming 
> > that 
> 
> It is impossible to discuss comments without looking at their relationship
> to the code.  It's like discussing the caption of a picture without
> looking at the picture.

I disagree. If I ask you where you usually put captions to pictures and give 
you a picture and a "blablabla" caption and ask you to place them together, 
would you go "Hey, this caption is AQLL wwrong for this picture! I can't give 
any general comments on this at all!"?

> > I strongly suggest you stop focusing on the code, and start talking about 
> > commenting. This is a useless discussion. Sorry. I suppose this is what I 
> > get for bringing up a topic as religious as this.
> 
> In this case, the whole line should have been made a comment.  That way
> readers *know* that the code in question doesn't do anything in the
> current program.

Good, now you're commenting on the comments (hehe, no pun intended).

> Again it's impossible to improve the comment and leave the code alone.
> The question of commenting style is impossible to discuss without
> also discussing coding style.

I, obviously, disagree.

> The best comments are those that aren't necessary because the code
> is clear.

Then you're limiting the availability of the script to people with a certain 
level of knowledge of perl. The point with comment is to make that level lower 
without altering the code.

-- 
Sandman[.net]


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

Date: Thu, 20 Feb 2003 17:55:24 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: Religious question: commenting
Message-Id: <pan.2003.02.20.16.34.28.738834@aursand.no>

On Thu, 20 Feb 2003 17:11:30 +0100, Sandman wrote:
>> It is impossible to discuss comments without looking at their
>> relationship to the code.  It's like discussing the caption of a
>> picture without looking at the picture.

> I disagree. If I ask you where you usually put captions to pictures and
> give you a picture and a "blablabla" caption and ask you to place them
> together, would you go "Hey, this caption is AQLL wwrong for this
> picture! I can't give any general comments on this at all!"?

Ofcourse.  Why shouldn't he?  If it's _obvious_ that the caption doesn't
go with the picture, why should he let you commit that foul?

It seems to be that you're trying to separate comments from code and vice
versa.  To me that seems wrong, because sloppy commenting can obfuscate
the most elegant code, the same way great commenting can't make up for bad
code.

Or - to use the picture/caption relevance;  It doesn't matter if the
caption says 'George W. Bush' when it's a picture of Saddam Hussein.  It's
just wrong.


-- 
Tore Aursand - tore@aursand.no - http://www.aursand.no/



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

Date: 20 Feb 2003 17:47:38 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Religious question: commenting
Message-Id: <u9n0kqetdx.fsf@wcl-l.bham.ac.uk>

Sandman <mr@sandman.net> writes:

> In article <b32b4o$r0p$1@mamenchi.zrz.TU-Berlin.DE>,
>  anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
>
> > The best comments are those that aren't necessary because the code
> > is clear.
> 
> Then you're limiting the availability of the script to people with a certain 
> level of knowledge of perl. The point with comment is to make that level lower 
> without altering the code.

I agree with Anno on this one.  Comments of the nature you describe
generally belong only in code that is intended as a programming
example.  Comments in "real" code should explain the logic of the
program not the language in which it is written.  There are very few
exceptions to this.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 20 Feb 2003 18:19:01 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Religious question: commenting
Message-Id: <b3366l$o6p$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Sandman:

> In article <3e54aa33.1117431361@news.cis.dfn.de>,
>  helgi@decode.is (Helgi Briem) wrote:

>> You should focus more on the code and less on the 
>> commenting.
> 
> In a thread about commenting? Odd.

Well, what are your priorities? Rather becoming an expert in Perl or in
commenting Perl code? The time you spent here arguing your point could
have been spent better on becoming even more familiar with Perl. This
will on the long run reduce the need for comments, too, by increasing
the expressiveness and clearity of your programs.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: 20 Feb 2003 16:22:02 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Report physical RAM of a remote PC
Message-Id: <b32vba$odb$1@canopus.cc.umanitoba.ca>

In article <b32b1q$er$1@news.dtag.de>, Malte Ubl  <ubl@schaffhausen.de> wrote:
:Obviously you mean:

:my $test = "";
:my $i = 0;
:while(++$i){
:     $test.='X';

:     print "you have at least $i bytes of ram available\n";
:}

At some point, ++$i would go into scientific notation, lose
enough precision to be able to tell $i from ($i + 1), and the 
printouts of the $i after that would be inaccurate.

Not that you are likely to find any -real- PC's with that
much memory, but there's always a chance that you're running
on a system with a couple of terabytes...
-- 
Everyone has a "Good Cause" for which they are prepared to Spam.
   -- Roberson's Law of the Internet


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

Date: Thu, 20 Feb 2003 08:22:10 -0600
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: Simple regex question...
Message-Id: <MPG.18bea08e984eba3c989707@news.mts.net>


In article <e52c9016.0302191231.4a63728a@posting.google.com>, Sam 
(s_vakareskov@hotmail.com) says...
> Hi there,
> I have what should be a simple question about a regex that I'm playing
> with.
> 
> Here is my regesx:
> /onmouseout=(.)*;/
> This should match all occurences of 'onmouseover='.  And it does. But
> some for some reason it also matches other stuff around it.  For
> example, this whole string was retunred as a match:
> 
> 'onmouseout=mouseOut(); onmouseover=mouseOverLink(1);>special fares &
> 
> Any ideas?  
> Thank you in advance.
> Regards,
> -Sam
> 

You need to use minimal pattern matching as follows :

/onmouseout=(.)*?;/

-- 
---------

Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com


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

Date: 20 Feb 2003 08:56:08 -0800
From: jgking@packetstorm.org (John)
Subject: storing regex vars into array and not $1 $2 etc
Message-Id: <6d9df2eb.0302200856.638db78b@posting.google.com>

I have a statement like so:

 if ($line =~ /(\w{3})\s+(\d{1,2})\s+([0-9:]+)\s+([0-9\.]+)\s+(\w)
 .....

If it matches I get $1 $2 $3 ... values stored since I am wanting
those values for further processing in a function.

Currently I have to call the function like so:

somefunc($dbuser,$dbpass,$dbname,$dbtable,$1,$2,$3...)

which is annoying as some regexes have up to 20 stored variables.

I would like to have those stored into an array and then call the
function like so:

somefunc($dbuser,$dbpass,$dbname,$dbtable,\@varlist)

How would i go about doing that?

Thanks,

-Greg


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

Date: 20 Feb 2003 17:40:37 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: storing regex vars into array and not $1 $2 etc
Message-Id: <u9r8a2etpm.fsf@wcl-l.bham.ac.uk>

jgking@packetstorm.org (John) writes:

> Subject: storing regex vars into array and not $1 $2 etc

You have a question about the m// operator.  You should consult the
section of the reference manual that explains the m// operator.

> I have a statement like so:
> 
>  if ($line =~ /(\w{3})\s+(\d{1,2})\s+([0-9:]+)\s+([0-9\.]+)\s+(\w)
> .....
> 
> If it matches I get $1 $2 $3 ... values stored since I am wanting
> those values for further processing in a function.

> Currently I have to call the function like so:
> 
> somefunc($dbuser,$dbpass,$dbname,$dbtable,$1,$2,$3...)

Never pass $1 et al to functions.  They interact in a most unfortunate
way with the @_ mechanism.

> which is annoying as some regexes have up to 20 stored variables.
> 
> I would like to have those stored into an array and then call the
> function like so:
> 
> somefunc($dbuser,$dbpass,$dbname,$dbtable,\@varlist)

if ( my @varlist = $line =~ /(\w{3})\s+(\d{1,2})/ ) {
  somefunc($dbuser,$dbpass,$dbname,$dbtable,\@varlist);
}

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Thu, 20 Feb 2003 18:01:42 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: storing regex vars into array and not $1 $2 etc
Message-Id: <1fqp0sp.v3q5iz1lwf4eeN%tony@svanstrom.com>

John <jgking@packetstorm.org> wrote:

> which is annoying as some regexes have up to 20 stored variables.
> 
> I would like to have those stored into an array


@firesticks = /(a)(b)(c)/;


-- 
# Per scientiam ad libertatem! // Through knowledge towards freedom! #
# Genom kunskap mot frihet! =*= (c) 1999-2002 tony@svanstrom.com =*= #

    perl -e'print$_{$_} for sort%_=`lynx -source svanstrom.com/t`'


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

Date: 20 Feb 2003 13:07:37 -0500
From: clists@perrin.socsci.unc.edu (Andrew Perrin (CLists))
Subject: Re: storing regex vars into array and not $1 $2 etc
Message-Id: <84el62keqe.fsf@perrin.socsci.unc.edu>

jgking@packetstorm.org (John) writes:

> I have a statement like so:
> 
>  if ($line =~ /(\w{3})\s+(\d{1,2})\s+([0-9:]+)\s+([0-9\.]+)\s+(\w)
> .....
> 
> If it matches I get $1 $2 $3 ... values stored since I am wanting
> those values for further processing in a function.
> 
> Currently I have to call the function like so:
> 
> somefunc($dbuser,$dbpass,$dbname,$dbtable,$1,$2,$3...)
> 
> which is annoying as some regexes have up to 20 stored variables.
> 
> I would like to have those stored into an array and then call the
> function like so:
> 
> somefunc($dbuser,$dbpass,$dbname,$dbtable,\@varlist)
> 
> How would i go about doing that?

Interesting question - the only thing that springs to mind for me is
the dangerous Symref:

#!/usr/local/bin/perl

use strict;
use warnings;

my $foo = 'abcdefg';

my @matches;

if ($foo =~ /(.)(.)(.)(.)(.)(.)(.)/) {
    no strict 'refs';
    push(@matches, $$_) for (1..7);
}

print "Matches: @matches\n";


There are probably other ways too.

-- 
----------------------------------------------------------------------
Andrew J Perrin - http://www.unc.edu/~aperrin
Assistant Professor of Sociology, U of North Carolina, Chapel Hill
clists@perrin.socsci.unc.edu * andrew_perrin (at) unc.edu


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

Date: Thu, 20 Feb 2003 14:49:44 GMT
From: "David" <perl-dvd@darklaser.com>
Subject: Re: stripping part of a string
Message-Id: <cW55a.48$F6.11191@news-west.eli.net>


"Ryan" <scheller@student.umass.edu> wrote in message
news:1edcb178.0302130611.4e95cbc3@posting.google.com...
> I'm sure this is an easy task, but I jsut seem to be stuck on it.
> Here's the problem:
> I have a string in a "format" such as this, where there will always be
> a " - " seperating the two parts, if you will.
>
> $name = "My Cat - Brown Dog.txt";
>
> Now what I'd like to have is:
> $name = "My Cat";
>
> I'd like to be able to delete everything in the string after and
> including the " - ".  That's "Space-Space".  I've been looking at
> using s///, but it jsut doesn't seem to come out right.  Can anyone
> help!!  Is there a beter operation to use?  Thanks so much,

Try

$name =~ s/ - .*$//;

Regards,
David




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

Date: Thu, 20 Feb 2003 14:39:05 GMT
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Subroutine does not 'see' parameter passed to it
Message-Id: <dM55a.11485$FF4.631799@newsb.telia.net>

george wrote:
> There was no error message.

If not, it seems to me as if you are struggling with this without having 
enabled strictures and warnings. You shouldn't do that. Add these to 
your program:

     use strict;
     use warnings;

and you'll likely get the necessary help from Perl to resolve the issue.

/ Gunnar

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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.

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 V10 Issue 4594
***************************************


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