[22375] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4596 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 20 18:10:41 2003

Date: Thu, 20 Feb 2003 15:10:13 -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: 4596

Today's topics:
    Re: Religious question: commenting <JCornwall@cox.net>
    Re: Report physical RAM of a remote PC <me@privacy.net>
        Retrieving Information <smiley@uvgotemail.com>
    Re: Retrieving Information <jeff@vpservices.com>
    Re: storing regex vars into array and not $1 $2 etc (Andrew Perrin (CLists))
    Re: storing regex vars into array and not $1 $2 etc (Anno Siegel)
        Suppress DBD MySQL info messages at terminal <jane_dunnie@hotmail.cmo>
    Re: Suppress DBD MySQL info messages at terminal <rereidy@indra.com>
        Switch order of sprintf conversions <noreply@gunnar.cc>
    Re: Switch order of sprintf conversions (Anno Siegel)
        Tcl Notifier Window <oeschey@web.de>
        UNIX: creating a command line alias <hasting@agere.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 20 Feb 2003 19:16:10 GMT
From: "J. F. Cornwall" <JCornwall@cox.net>
Subject: Re: Religious question: commenting
Message-Id: <_P95a.64116$zL6.52685@news2.central.cox.net>

Tassilo v. Parseval wrote:
> 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

Data Point:  As a novice Perl programmer (with 19 years of experience in 
Fortran), I rather like seeing clear comments interspersed with the 
code.  Experts can pick out the functions from the code with no aids, 
but those of us who are still earning the language can definitely 
benefit from good, clear, *accurate* commenting.  My code (in any 
language) has lots of comments, because my priorities include making it 
easy for the next guy to see what the code is for and how it functions. 
  Yes, I have to make sure comments get updated when the code does. 
Yes, I have to work harder on it to ensure the code and the comments 
match.  No, I don't care much for programmers' work that depends on 
[Fortran|C|Perl] being a "self-documenting" language.

What's wrong with spending a bit of extra effort and putting in *good* 
comments, ones that are accurate and helpful to the non-experts?

Jim Cornwall



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

Date: Fri, 21 Feb 2003 07:58:47 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: Report physical RAM of a remote PC
Message-Id: <b33fie$1hv2g8$1@ID-172104.news.dfncis.de>


"JohnShep" <go@way.com> wrote in message
news:b32hs3$dkn$1@knossos.btinternet.com...
>
> "SAPBasis2003" <sapbasis2003@netscape.net> wrote in message
> news:3E5481FD.10600@netscape.net...
> > How can I report the RAM of a remote PC?
> > Does anybody have a sample code to do this?
> > Thank you.
>
> #!/usr/bin/perl -w
> use CGI::Carp 'fatalsToBrowser';
> print "Content-type: text/html\n\n<PRE>";
> print system ("cat /proc/meminfo");
>
> Caveat, it's cheap and nasty but should work on a Linux box.

Doesn't report on a remote host.

Why output an HTML MIME header, when you aren't using valid HTML, and
anyway, who said the OP wanted the output in his browser?




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

Date: Thu, 20 Feb 2003 17:51:57 -0500
From: "Smiley" <smiley@uvgotemail.com>
Subject: Retrieving Information
Message-Id: <v5an0u151n936b@corp.supernews.com>

I'm looking to retrieve some information from a website that has a nice
searchable database.  This information isn't copyrighted, sensitive, or
exclusive in any way so there's no problem there.

My original thought was to create a Perl script to read in the data using
LWP and appending the search values to the URL in GET format.
Unfortunately, the ASP script that does the search was only set up to accept
POST.

Is there any other way to do this?

Thanks.




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

Date: Thu, 20 Feb 2003 15:01:05 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Retrieving Information
Message-Id: <3E555E31.2010503@vpservices.com>

Smiley wrote:

> I'm looking to retrieve some information from a website that has a nice
> searchable database.  This information isn't copyrighted, sensitive, or
> exclusive in any way so there's no problem there.


Good lad for thinking about that.  I'd suggest checking with the site 
admins anyway.


> My original thought was to create a Perl script to read in the data using
> LWP and appending the search values to the URL in GET format.
> Unfortunately, the ASP script that does the search was only set up to accept
> POST.


Well LWP can do a POST also, but it might be alot easier to just contact 
the site admin and use a direct query to their database without going 
through their form at all.  If their data is stored in a DBI accessible 
rdbms, you can use a remote call to it.  If it's stored in a publicly 
accessible XML, CSV, Fixed width or various other formated file, 
DBD::AnyData will retrieve it from its remote location.

-- 
Jeff





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

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

clists@perrin.socsci.unc.edu (Andrew Perrin (CLists)) writes:

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

[snip]

Sorry... brain infarct. Please see the correct responses posted
elsewhere in this thread.

-- 
----------------------------------------------------------------------
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: 20 Feb 2003 22:28:35 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: storing regex vars into array and not $1 $2 etc
Message-Id: <b33kqj$qfn$5@mamenchi.zrz.TU-Berlin.DE>

Brian McCauley  <nobull@mail.com> wrote in comp.lang.perl.misc:
> 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);
> }

 ...or even

    somefunc($dbuser,$dbpass,$dbname,$dbtable, [ $line =~ /regex/]);

if it must be passed as a reference.  The natural way of doing it
would just be

    somefunc($dbuser,$dbpass,$dbname,$dbtable, $line =~ /regex/);

with somefunc() expecting the parameters spread out instead of in a
listref.

In both cases, somefunc() must also check if there was a match at
all ("if ( @_ > 4 ) { ..."), something that your code combines nicely
with gathering the parameter list.

Anno


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

Date: Thu, 20 Feb 2003 22:44:06 GMT
From: "Jane_Dunnie" <jane_dunnie@hotmail.cmo>
Subject: Suppress DBD MySQL info messages at terminal
Message-Id: <VSc5a.190345$HN5.820295@rwcrnsc51.ops.asp.att.net>

Hi,

I have a small Perl script, which connects to a MySql database. Works fine,
except that when a duplicate record is attempted to be added, the error
message is wriiten to the terminal, thus:

DBD::mysql::db do failed: Duplicate entry .......etc

How can I get rid of that, and just have it return nothing....?


I've tried the following, which I found in another group, but it doesn't
seem to work for me:

 ....or die "$DBI::err: $DBI::errstr";


My code (partial extract from a sub-routine) looks something like this:

my $dbh;
        if ($x ne "")
        {
        $dbh = WebDB::connect();
        $dbh-> do (qq
                {
                INSERT INTO table1 SET f1=?, f2=?, f3=?
                }, undef, $f1, $f2, $f3);        # tried adding the or die
"$DBI::err: $DBI::errstr"; in here...(before the semi-colon :-) )
        $dbh->disconnect();
        }

I also tried adding the line:

        $dbh->{RaiseError}=1;

 ....but didn't seem to make any difference.


Any assistance appreciated.....I'm guessing (without trying) that if this
were actually part of a Web application, then the message wouldn't make any
difference ?....Just curious. Anyway, the error message is what I'm trying
to get rid of if someone can help - Many thanks!

Jane














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

Date: Thu, 20 Feb 2003 15:57:12 -0700
From: Ron Reidy <rereidy@indra.com>
Subject: Re: Suppress DBD MySQL info messages at terminal
Message-Id: <3E555D48.7080307@indra.com>

What about $dbh->{PrintError} = 0?  Or placing your code within eval { 
 ... } blocks?

--
Ron Reidy
Oracle DBA

Jane_Dunnie wrote:
> Hi,
> 
> I have a small Perl script, which connects to a MySql database. Works fine,
> except that when a duplicate record is attempted to be added, the error
> message is wriiten to the terminal, thus:
> 
> DBD::mysql::db do failed: Duplicate entry .......etc
> 
> How can I get rid of that, and just have it return nothing....?
> 
> 
> I've tried the following, which I found in another group, but it doesn't
> seem to work for me:
> 
> ....or die "$DBI::err: $DBI::errstr";
> 
> 
> My code (partial extract from a sub-routine) looks something like this:
> 
> my $dbh;
>         if ($x ne "")
>         {
>         $dbh = WebDB::connect();
>         $dbh-> do (qq
>                 {
>                 INSERT INTO table1 SET f1=?, f2=?, f3=?
>                 }, undef, $f1, $f2, $f3);        # tried adding the or die
> "$DBI::err: $DBI::errstr"; in here...(before the semi-colon :-) )
>         $dbh->disconnect();
>         }
> 
> I also tried adding the line:
> 
>         $dbh->{RaiseError}=1;
> 
> ....but didn't seem to make any difference.
> 
> 
> Any assistance appreciated.....I'm guessing (without trying) that if this
> were actually part of a Web application, then the message wouldn't make any
> difference ?....Just curious. Anyway, the error message is what I'm trying
> to get rid of if someone can help - Many thanks!
> 
> Jane
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 



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

Date: Thu, 20 Feb 2003 20:53:46 GMT
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Switch order of sprintf conversions
Message-Id: <ufb5a.11525$FF4.632031@newsb.telia.net>

I'm using a gettext like approach for making it easy to translate a Perl 
program to non-English languages, and the sprintf function is often used 
for the purpose:

     $string = gettext("There Is %s Than %s Way To Do It");
     $more = gettext("More");
     $one = gettext("One");
     print sprintf($string, $more, $one);

Right now the program is translated into Chinese, and the translator has 
reported a need to have the value of $one printed *before* the value of 
$more. I understand from the gettext documentation that if it had been a 
C program, $string could have been assigned (the equivalent of) "There 
Is %2$s Than %1$s Way To Do It".

Is there a way in Perl to achieve the same thing?

/ Gunnar

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



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

Date: 20 Feb 2003 22:00:49 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Switch order of sprintf conversions
Message-Id: <b33j6h$qfn$3@mamenchi.zrz.TU-Berlin.DE>

Gunnar Hjalmarsson  <noreply@gunnar.cc> wrote in comp.lang.perl.misc:
> I'm using a gettext like approach for making it easy to translate a Perl 
> program to non-English languages, and the sprintf function is often used 
> for the purpose:
> 
>      $string = gettext("There Is %s Than %s Way To Do It");
>      $more = gettext("More");
>      $one = gettext("One");
>      print sprintf($string, $more, $one);
> 
> Right now the program is translated into Chinese, and the translator has 
> reported a need to have the value of $one printed *before* the value of 
> $more. I understand from the gettext documentation that if it had been a 
> C program, $string could have been assigned (the equivalent of) "There 
> Is %2$s Than %1$s Way To Do It".
> 
> Is there a way in Perl to achieve the same thing?

Where is the gettext() function coming from?  Are you using a module
from CPAN?  What does its documentation say?

Anno


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

Date: Thu, 20 Feb 2003 23:06:31 +0100
From: Lars Oeschey <oeschey@web.de>
Subject: Tcl Notifier Window
Message-Id: <44ka5vcqlbn3uau93vbhgq88fbf8k8et3s@4ax.com>

Hi,

I have written an application that generates a problem: As soon as it
starts
on a certain machine (W2k), I get a fullscreen Window "Tcl Notifier"
that
hides my app behind it. 
My Application is written using ActivePerl 5.6 + Perl::Tk and compiled
with
PerlApp from Activestate.
I think there is some Tcl Application running on the machine, and
somehow my
Tk interferes with the Tcl/Tk.
Did anyone ever see something like that?

Lars



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

Date: Thu, 20 Feb 2003 15:39:54 -0500
From: "Joe Hasting" <hasting@agere.com>
Subject: UNIX: creating a command line alias
Message-Id: <b33eno$19a$1@test-nntp.agere.com>

I would like a PERL program to create a UNIX command line alias.  I tried
using system, exec, and the ticks, but it seems that when the process for
the PERL program is complete, it does not leave the alias.  Is there a way
to fork this process so that the alias remains after the PERL program
completes?

thank you for any input
Joe Hasting
hasting@agere.com




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

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


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