[26230] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8415 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 14 00:05:30 2005

Date: Tue, 13 Sep 2005 21:05:05 -0700 (PDT)
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, 13 Sep 2005     Volume: 10 Number: 8415

Today's topics:
    Re: [OT] connecting to MS SQL on a different computer ( <kuujinbo@hotmail.com>
    Re: File::Copy works, File::NCopy doesn't <jgibson@mail.arc.nasa.gov>
    Re: File::Copy works, File::NCopy doesn't <1usa@llenroc.ude.invalid>
    Re: File::Copy works, File::NCopy doesn't xhoster@gmail.com
        How to remove `` \x{d} metacharacters from strings ... <ckb@reboot.erg>
        Looking for Chinese->English Translation Script <speediercoREMOVE_THIS@yahoo.com>
    Re: Looking for Chinese->English Translation Script <john@castleamber.com>
    Re: Need a regex <randy@SpamFree.com>
    Re: Need a regex <tadmc@augustmail.com>
    Re: Need a regex <john@castleamber.com>
    Re: Perldoc security issues <spam-block-@-SEE-MY-SIG.com>
    Re: Perldoc security issues <spam-block-@-SEE-MY-SIG.com>
    Re: Perldoc security issues <spam-block-@-SEE-MY-SIG.com>
    Re: Simple question for you's...... <zabel@higherprime.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 14 Sep 2005 12:14:53 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: [OT] connecting to MS SQL on a different computer (DBD::ODBC)
Message-Id: <43279520_1@x-privat.org>

John Bokma wrote:
> Can anyone give pointer(s) on how to connect to a server which runs MS SQL 
> using DBD::ODBC? I thought it would be as simple as specifying a host and 
> port, but I can't seem to get it working, and been googling for quite some 
> time and not found any solution yet and I am a bit lost in UNC, DNC and 
> more 3 letter abbreviations :-(
> 

DBI->connect(
   qq[dbi:ODBC:driver={SQL Server};Server=$server;database=$db],
   $user, $password,
   { RaiseError => 1, PrintError => 0, AutoCommit => 1 }
);

1. $server => IP address/hostname, or '(local)' where web server is on 
same host as SQL Server.
2. $db => database name.
3. $user & $password => undef to use windows authentication.

Good reference:
http://groups.google.com/group/perl.dbi.users

HTH - keith


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

Date: Tue, 13 Sep 2005 18:53:34 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: File::Copy works, File::NCopy doesn't
Message-Id: <130920051853345704%jgibson@mail.arc.nasa.gov>

In article <Xns96D0B67CEB50Dasu1cornelledu@127.0.0.1>, A. Sinan Unur
<1usa@llenroc.ude.invalid> wrote:


> 
> On the other hand, I do not find it encouraging that the module author 
> uses print for debug messages. He should be using warn.

Why is that? Why do you want to write debugging messages to standard
error instead of standard output?


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

Date: Wed, 14 Sep 2005 02:32:56 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: File::Copy works, File::NCopy doesn't
Message-Id: <Xns96D0E560B25EEasu1cornelledu@127.0.0.1>

Jim Gibson <jgibson@mail.arc.nasa.gov> wrote in news:130920051853345704%
jgibson@mail.arc.nasa.gov:

> In article <Xns96D0B67CEB50Dasu1cornelledu@127.0.0.1>, A. Sinan Unur
> <1usa@llenroc.ude.invalid> wrote:
> 
> 
>> 
>> On the other hand, I do not find it encouraging that the module author 
>> uses print for debug messages. He should be using warn.
> 
> Why is that? Why do you want to write debugging messages to standard
> error instead of standard output?

So that I can actually see the debugging messages even if standard output 
is redirected. Or, so that I can log debugging messages to a file 
separately from the normal output of the program.

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


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

Date: 14 Sep 2005 03:10:11 GMT
From: xhoster@gmail.com
Subject: Re: File::Copy works, File::NCopy doesn't
Message-Id: <20050913231011.303$zm@newsreader.com>

Jim Gibson <jgibson@mail.arc.nasa.gov> wrote:
> In article <Xns96D0B67CEB50Dasu1cornelledu@127.0.0.1>, A. Sinan Unur
> <1usa@llenroc.ude.invalid> wrote:
>
> >
> > On the other hand, I do not find it encouraging that the module author
> > uses print for debug messages. He should be using warn.
>
> Why is that? Why do you want to write debugging messages to standard
> error instead of standard output?

Because a lot of Perl program write a lot of stuff to STDOUT.  Indeed, that
is often their main purpose.  Good programs write little if anything to
STDERR, so you should probably send dubugging output there, where it will
be easy to find. Besides, you want to debug things because you suspect
there are ERRors.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Tue, 13 Sep 2005 19:55:21 -0500
From: "C. Colin Backslas" <ckb@reboot.erg>
Subject: How to remove `` \x{d} metacharacters from strings ...
Message-Id: <pan.2005.09.14.00.55.19.632711@reboot.erg>

Howdy,

I've got a Perl-Tk/Net::Telnet command generator [Tl1] to build commands
and send them to a box and display the responses back to a 
Tk::Text entry. In each of the response strings I have ``\x{d}''
at the beginning or end of each string.

How can I remove these characters?
Any help would be greatly appreciated.

 -- C:\

PS: I have a curses-based command generator which displays the responses
in a Gnome-Terminal window without these characters present.


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

Date: Tue, 13 Sep 2005 20:29:51 -0400
From: "OttawaTrade" <speediercoREMOVE_THIS@yahoo.com>
Subject: Looking for Chinese->English Translation Script
Message-Id: <pNydnfoRVaKe8rreRVn-vg@rogers.com>

I need to translate short sentences, maybe at most 100 per day. I know
google has one, but it can not be crawled

http://world.altavista.com/tr
http://www.google.com/translate_t

Is there a database I can download, a php/perl script, a GET url I can use?




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

Date: 14 Sep 2005 01:39:47 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Looking for Chinese->English Translation Script
Message-Id: <Xns96D0D201675B8castleamber@130.133.1.4>

"OttawaTrade" <speediercoREMOVE_THIS@yahoo.com> wrote:

> I need to translate short sentences, maybe at most 100 per day. I know
> google has one, but it can not be crawled

Without violating the TOS? Or not at all. The last if false.

> http://world.altavista.com/tr
> http://www.google.com/translate_t
> 
> Is there a database I can download, a php/perl script, a GET url I can
> use? 

don't know, yes (don't know if you can download it), no (POST).

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: Tue, 13 Sep 2005 22:12:29 GMT
From: "Randy Harris" <randy@SpamFree.com>
Subject: Re: Need a regex
Message-Id: <h9IVe.346$H62.195@newssvr23.news.prodigy.net>


"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message
news:Xns96D0B43E61878asu1cornelledu@127.0.0.1...
> Shane <shane@weasel.is-a-geek.net> wrote in
> news:pan.2005.09.13.21.28.25.356154@weasel.is-a-geek.net:
>
> > On Tue, 13 Sep 2005 21:20:38 +0000, Randy Harris wrote:
> >
> >> I would appreciate help creating a regex.  I have a file that
> >> contains lines that begin with several groups of numbers separated by
> >> a dash followed by a dash and then non digit data. For example:
> >>
> >> 123-12-23-Bottom Bracket
> >> 561-318-001-Cowling Spacer 2
> >> 453-2193-Fitting Hose
> >>
> >> I need to capture the numeric portion, up to but not including the
> >> last dash. From the above samples I would want:
> >>
> >> 123-12-23
> >> 561-318-001
> >> 453-2193
> >>
> >> Thank you for any help.
>
> To the OP: This is not a "write my code for me" service. If you do not
> put any effort into helping others help you, you cannot expect others to
> put much effort into helping you.
>
> Or, you get:
>
> use strict;
> use warnings;
>
> missing.
>
> > my @list = <Filehandle>
> > $list[$linenumber] =~ /([\d-]+)/
> > print $1
>
> Now, Shane,
>
> 1. Why are you slurping the whole file only to process it line by line?
> 2. What is $linenumber?
> 3. Since you are not actually looping through all the elements of @list,
> do you really expect this to do what the OP asked for?
> 4. You are using $1 without checking if the regex actually matched.
> 5. Since you did not anchor the regex, it will also match lines such as
>
> Hello -555- World!
>
> This is clearly against the specs.
>
> 6. The regex you specified will also match the trailing dash. Again, the
> OP was asking the exact opposite.
>
> Here is something that will actually work:
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> while(<DATA>) {
>    if( /^([\d-]+\d+)-/ ) {
>       print "$1\n";
>    }
> }
>
> __DATA__
> 123-12-23-Bottom Bracket
> 561-318-001-Cowling Spacer 2
> 453-2193-Fitting Hose
>
> D:\Home\asu1\UseNet\clpmisc> www
> 123-12-23
> 561-318-001
> 453-2193
>
> Please read the posting guidelines for this group.
>
> Sinan
> -- 
> A. Sinan Unur <1usa@llenroc.ude.invalid>
> (reverse each component and remove .invalid for email address)
>
> comp.lang.perl.misc guidelines on the WWW:
> http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

Thank you.  I'll attempt to adhere more closely to the posting guidelines.
I have been reading the docs, it was mostly the grouping for the quantifier
that I couldn't figure out. [ ]




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

Date: Tue, 13 Sep 2005 17:20:42 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Need a regex
Message-Id: <slrndiek5q.co.tadmc@magna.augustmail.com>

Randy Harris <randy@SpamFree.com> wrote:

> followed by a
> dash and then non digit data. For example:
> 
> 123-12-23-Bottom Bracket
> 561-318-001-Cowling Spacer 2
> 453-2193-Fitting Hose
> 
> I need to capture the numeric portion, up to but not including the last
> dash. From the above samples I would want:
> 
> 123-12-23
> 561-318-001
> 453-2193


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

while ( <DATA> ) {
   print "$1\n" if /(.*)-/;
}

__DATA__
123-12-23-Bottom Bracket
561-318-001-Cowling Spacer 2
453-2193-Fitting Hose
--------------------


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 14 Sep 2005 00:25:27 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Need a regex
Message-Id: <Xns96D0C56CCC79Acastleamber@130.133.1.4>

"Randy Harris" <randy@SpamFree.com> wrote:

> I would appreciate help creating a regex.  I have a file that contains
> lines that begin with several groups of numbers separated by a dash
> followed by a dash and then non digit data. For example:
> 
> 123-12-23-Bottom Bracket
> 561-318-001-Cowling Spacer 2
> 453-2193-Fitting Hose

Are there non-fitting hoses as well?

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: Wed, 14 Sep 2005 01:19:53 +0100
From: James Taylor <spam-block-@-SEE-MY-SIG.com>
Subject: Re: Perldoc security issues
Message-Id: <ant1400536d2fNdQ@riscpc.jtnet>

In article <Xns96CFD002A2F63castleamber@130.133.1.4>,
John Bokma <john@castleamber.com> wrote:
>
> James Taylor wrote:
> > 
> > In article <Xns96CF585C89187castleamber@130.133.1.4>,
> > John Bokma <john@castleamber.com> wrote:
> > > 
> > > Never fix input, like you do above.
> > 
> > Never? What's the right way to tidy user input in this situation?
> 
> If it's unexpected input, don't fix it. It was wrong in the first place.

Okay, I see what you mean. I'll raise an error instead.

> > > But don't do that with a regexp. Use a parser.
> > 
> > Why use a sledgehammer when a nutcracker will do?
> 
> You misread my post: regexp will *not* do what you want.
> You asked for security, you won't get that with a regexp (or several).

Actually, you can, by following the example Tad gave.

-- 
James Taylor, London, UK                              PGP key: 3FBE1BF9
To protect against spam, the address in the "From:" header is not valid.
In any case, you should reply to the group so that everyone can benefit.
If you must send me a private email, use james at oakseed demon co uk.



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

Date: Tue, 13 Sep 2005 21:23:41 +0100
From: James Taylor <spam-block-@-SEE-MY-SIG.com>
Subject: Re: Perldoc security issues
Message-Id: <ant13204163dfNdQ@riscpc.jtnet>

In article <slrndicans.skd.tadmc@magna.augustmail.com>,
Tad McClellan <tadmc@augustmail.com> wrote:
> 
> James Taylor wrote:
> > 
> > For instance, it's not clear to me whether it would be
> > possible to use some of perldoc's more esoteric options
> > to write to another file, or execute another file even.
> 
> Then disallow any functions that you are wary of.

Well, I could do that, but then I would be restricting people's
legitimate use of perldoc, and one of the primary purposes of
my interface is to give those without a native perldoc the ability
to see how perldoc works and what it returns for any combination
of options and arguments that they might see given in this group.

> You should fail to run rather than repair input and then run.

Yes, okay.

> You should specify what you will allow rather than what you
> will forbid.

Yes, of course, although this means rather more coding. :-(

> if ( $ARGV[0] eq '-f' and $ARGV[1] =~ /^\w+$/ )
>       { perldoc_f() }
> }
> elsif ( $ARGV[0] eq '-q' and 
>         ( $ARGV[1] =~ /^[\w ]+$/ or $ARGV[1] =~ /^(['"])[\w ]+\1$/ )
>       { perldoc_q() }
> }
> elsif ( $ARGV[0] =~ /^(\w|::)+$/ ) {
>    perldoc();
> }
> else {
>    fail();
> }

That kind of thing seems a reasonable approach so I'll extrapolate
that example to all the other options, assuming I can guess
correctly how to use them. Thanks.

-- 
James Taylor, London, UK                              PGP key: 3FBE1BF9
To protect against spam, the address in the "From:" header is not valid.
In any case, you should reply to the group so that everyone can benefit.
If you must send me a private email, use james at oakseed demon co uk.



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

Date: Wed, 14 Sep 2005 01:19:29 +0100
From: James Taylor <spam-block-@-SEE-MY-SIG.com>
Subject: Re: Perldoc security issues
Message-Id: <ant1400299eefNdQ@riscpc.jtnet>

In article <dg67er$mda$1@mamenchi.zrz.TU-Berlin.DE>,
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> 
> James Taylor wrote:
> > 
> > Why use a sledgehammer when a nutcracker will do?
> 
> In view of this attitude one has to wonder why you asked about
> security in the first place. You are obviously determined not
> to invest any more effort than you already have.

I think you misunderstand. I just wanted the size of the solution
to be in the same ball park as the size of the problem; something
doable in the kind of time the task deserves. Anyway, I refute your
apparent belief that a secure script requires a large or complex
solution. Merely disallowing any options would suffice (although
in this particular case it would be too Draconian for my purposes).

In the real world you have to compromise on perfection, otherwise
you'd spend so much time perfecting a solution to the first small
task you came across that you'd never move on to the second, or
third, or the rest of your life! Sadly, in this world, you don't
get paid for perfectionism, you get paid for getting the job done.
Don't forget that Perl is *the* language for getting the job done.

It amuses me how often small questions in this group are answered
with disproportionately large and idealistic solutions. This
invariably results in the questioner squirming for a way to get
a more pragmatic answer without seeming ungrateful. They then get
attacked as obstinate, clueless, or even wilfully lazy in much
the same way as you've just had a go at me. When I'm watching
this happen to someone else I can laugh and shake my head in
wonder at how people can be so lacking in self-awareness. As it's
happening to me this time, I must ask you to take a long hard
look at the position you're taking and be more reasonable.

> Answering was a waste of time.

Absolutely not. The answers have all been very useful thanks,
 ...with the possible exception of yours, of course. ;-)

-- 
James Taylor, London, UK                              PGP key: 3FBE1BF9
To protect against spam, the address in the "From:" header is not valid.
In any case, you should reply to the group so that everyone can benefit.
If you must send me a private email, use james at oakseed demon co uk.



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

Date: Tue, 13 Sep 2005 23:49:30 -0400
From: Shawn <zabel@higherprime.com>
Subject: Re: Simple question for you's......
Message-Id: <dd294$43279dc1$4528b32f$15615@ALLTEL.NET>

Brian McCauley wrote:
> 
> 
> Slow Learner wrote:
> 
>  > Subject: Simple question for you's......
> 
> Please put the subject of your post in the Subject of your post.
> 
>> http://www.mysite.com/beta/content/english/misc/publications/papers/index.html 
>>
>>
>> .... and I want to restrict it to no more than 50 characters, but I 
>> want the result to look something like this:
>>
>> .../english/misc/publications/papers/index.html
> 
> 
>> In other words, I want the left-most part of a path string replaced 
>> with ".../" for those bits of the path that make it go over 50 
>> characters.
> 
> 
>  s/.+?(?=\/.{0,46}$)/.../ if length > 50;
> 
> Note: This will leave the string unchaged if there is no '/' in the last 
> 47 characters of the string.
> 

Or, similarly

s/^.*?(.{47})$/...\1/ if length > 50;


- Shawn


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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