[16544] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3956 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 8 21:10:30 2000

Date: Tue, 8 Aug 2000 18:10:17 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <965783417-v9-i3956@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 8 Aug 2000     Volume: 9 Number: 3956

Today's topics:
    Re: OT: find the number of characters in a string (Tim Hammerquist)
    Re: OT: Re: Converting from US dates/numbers to Europea <godzilla@stomp.stomp.tokyo>
    Re: OT: Re: Converting from US dates/numbers to Europea <memmett@fraser.sfu.ca>
    Re: Parsing name list -- Help! <tim@ipac.caltech.edu>
        password protected web pages which? <.@.>
        perl sql (delimited) fg19537@my-deja.com
    Re: perl sql (delimited) <jeff@vpservices.com>
    Re: perl sql (delimited) <bwalton@rochester.rr.com>
        Problem with Net::Telnet jpalloz@my-deja.com
        proximity/adjacency matches w/ regexp? <mestdagh@us.ibm.com>
    Re: proximity/adjacency matches w/ regexp? <ren.maddox@tivoli.com>
    Re: Reap ? (Tim Hammerquist)
    Re: Reg Expression multiple parsing <ren.maddox@tivoli.com>
    Re: returning error message (Decklin Foster)
    Re: Running other programs in background wutang_warrior@my-deja.com
        Send email with attatchment using CGI script? <donotreply@interbulletin.bogus>
    Re: Send email with attatchment using CGI script? (Marcel Grunauer)
    Re: Send email with attatchment using CGI script? <jeff@yoak.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 09 Aug 2000 00:30:22 GMT
From: tim@degree.ath.cx (Tim Hammerquist)
Subject: Re: OT: find the number of characters in a string
Message-Id: <slrn8p1a41.u2.tim@degree.ath.cx>

On Mon, 07 Aug 2000 10:13:33 -0700, Godzilla!
<godzilla@stomp.stomp.tokyo> wrote:
> Keith Calvert Ivey wrote:
> > Except that Jim wasn't wrong initially.  His mistake was to lose
> > confidence in his initial answer (which was right) and change it
> > to another (which was also right, but longer).
> 
> Precisely.
> 
> I suspect Mr. Hammerquist may have some difficulties
> displaying an ego as healthy as Jim's own. Doubtful
> Mr. Hammerquist will correct his mistake.

In my assertation of Jim's answer, I _was_ wrong.

Is that the "inflated-self-image" ego, or the Freudian ego?  =)

> As a relatively warm blooded American Woman, it is
> my long experience, shorter is often not better.

Hence the incredible size of you articles...and head.

-- 
-Tim Hammerquist <timmy@cpan.org>

My life has a superb cast but I can't figure out the plot.
	-- Ashleigh Brilliant


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

Date: Tue, 08 Aug 2000 15:31:43 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: OT: Re: Converting from US dates/numbers to European dates/numbers
Message-Id: <39908A4F.5FF90AE0@stomp.stomp.tokyo>

"Jürgen Exner" wrote:
> 
> Godzilla!
> > Logan Shaw wrote:

> 2,2 + 2,2 (in European notation) is exactly the same 
> as 22*10^-1 + 22*10^-1,  which doesn't contain a single
> decimal separator.

> But what would be the point?


What does this have to do with the original question
of this thread? Well? 

Jeesshh... you boys are mondo beyondo.

Godzilla!


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

Date: 08 Aug 2000 15:47:01 -0700
From: Matthew Emmett <memmett@fraser.sfu.ca>
Subject: Re: OT: Re: Converting from US dates/numbers to European dates/numbers
Message-Id: <yvw9em3zid5m.fsf@fraser.sfu.ca>

"Godzilla!" <godzilla@stomp.stomp.tokyo> writes:

> What does this have to do with the original question
> of this thread? Well? 

Wasn't the original question: What is the best way to get Godzilla! to
make a fool of him/herself?

Apparently the answer is: ask a simple question.

Matt


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

Date: Tue, 08 Aug 2000 16:53:40 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: Parsing name list -- Help!
Message-Id: <39909D84.2A8CBD81@ipac.caltech.edu>

"Paul R. Andersen" wrote:
> 
> Tarun Ramadorai wrote:
> > I'm just learning how to be a perl hacker, and I have the following 
> > problem:
> >
> > I have a list of names, some of which are the same, but mistyped, e.g.
> >
> > MCDONALD'S
> > M.CDONALDS
> > MACDONALDS
> >
> > etc. etc.
> >
> > I'm trying to write a Perl script which will parse this sort of list, in 
> > such a way that
> > if any adjacent names on the list differ by N characters or less, then it 
> > prints OUT the first one
> > instead of the misspelled one. 
> >
> > Any suggestions will be greatly welcome,

> No suggestion for a cure, but some questions.  What will happen when
> Andersen is followed by Anderson.  Both are correct and only differ by
> one letter (the same is true of many names, of course).  How do you
> determine what to print?  For that matter, how did the list get sorted
> such that the first occurance of some arbitrary string was determined to
> be a correctly spelled name?  If you can find that out, your problem
> should be solved since someone already did it in effect.

If you can answer Paul's excellent questions, check out the String::Approx
module at your local CPAN site.

--

-- Tim Conrow         tim@ipac.caltech.edu       626-395-8435


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

Date: Wed, 9 Aug 2000 01:29:50 +0100
From: "." <.@.>
Subject: password protected web pages which?
Message-Id: <8mq8b8$j8s$1@diana.bcn.ttd.net>

plain text, database (MySQL), .htacces, etc.
Which is the best? and How?





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

Date: Tue, 08 Aug 2000 23:35:41 GMT
From: fg19537@my-deja.com
Subject: perl sql (delimited)
Message-Id: <8mq5gd$md8$1@nnrp1.deja.com>

Can anyone tell me how to create a pipe delimited file using SQL in
perl?
#!/home/tools/bin/perl -w
use DBI;
$dbh = DBI->connect("DBI:Informix:pro");
$sth = $dbh->prepare(q%select fname, lname from names%);
$sth->execute();
$ref = $sth->fetchall_arrayref();
$ref)
{print "$$row[0] | $$row[1] |\n";}
$dbh->disconnect;
RESULTS I get:
bob    | jones    |
john   | smith    |
RESULTS I want:
bob|jones|
john|smith|


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 08 Aug 2000 17:11:25 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: perl sql (delimited)
Message-Id: <3990A1AD.2118991D@vpservices.com>

fg19537@my-deja.com wrote:
> 
> Can anyone tell me how to create a pipe delimited file using SQL in
> perl?
> #!/home/tools/bin/perl -w
> use DBI;
> $dbh = DBI->connect("DBI:Informix:pro");

The Informix driver is for the Informix database.  To use delimited
files you will need one of several drivers which handles them.  Here's
one example:

use DBI
my $dbh = DBI->connecti('dbi:RAM:',,,{RaiseError=>1})
          or die $DBI::errstr;
$dbh->func([[
    'names', 'PIPE', 'names.txt',{col_names=>fname,lname}
]],'catalog');
my $sth = $dbh->prepare("SELECT fname, lname FROM names");
 ...

That opens a file called "names.txt" using pipe-delimited ("PIPE")
format, and associating that file with a table called "names".  If the
file doesn't already exist, you can use standard SQL CREATE TABLE syntax
to create it.

Similar things can be done in a bit more complicated way with DBD::CSV
and several other modules as well.

-- 
Jeff


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

Date: Wed, 09 Aug 2000 00:30:48 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: perl sql (delimited)
Message-Id: <3990A66B.FC3179AA@rochester.rr.com>

fg19537@my-deja.com wrote:
> 
> Can anyone tell me how to create a pipe delimited file using SQL in
> perl?
> #!/home/tools/bin/perl -w
> use DBI;
> $dbh = DBI->connect("DBI:Informix:pro");
> $sth = $dbh->prepare(q%select fname, lname from names%);
> $sth->execute();
> $ref = $sth->fetchall_arrayref();
> $ref)
  ^^^^^----what's this??  I assume your real code has the proper
           stuff here to execute the print statement below once
           for each row of data.
> {print "$$row[0] | $$row[1] |\n";}
> $dbh->disconnect;
> RESULTS I get:
> bob    | jones    |
> john   | smith    |
> RESULTS I want:
> bob|jones|
> john|smith|
 ...
Try replacing your print statement with [untested]:

  {
  my $results="$$row[0]|$$row[1]|\n";
  $results=~s/\s//g;
  print $results;
  }

Your database is returning whitespace past the end of your data that you
appear to wish not to have, and the above will remove it.
-- 
Bob Walton
-- 
Bob Walton


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

Date: Tue, 08 Aug 2000 22:03:05 GMT
From: jpalloz@my-deja.com
Subject: Problem with Net::Telnet
Message-Id: <8mq02o$iuv$1@nnrp1.deja.com>

I need to use Net::Telnet to telnet into a propeitary database
interface, similiar to sqlplus.

The idea is to telnet into this database from an outside perl/cgi,
and then either create new records or update existing ones.

The problem is this particular interface has no prompt. The cursor
simply blinks at the beginning of the line waiting for you to issue
your commands.

Here is an example of the proper syntax for the commands in the
interface:

LOGIN
USER:superuser
PASS:hello1234

NEW
USER:newguy123
first:Jim
last:smith
email:jsmith@smithco.com

LOGOUT


After each line a carriage return is issued and after the whole command
is issued two carriage returns need to be issued. Additionally, to
telnet into this database interface I need to telnet into port 10000
Here is an example of one way I've tried it:

$hostname = "foo";

$t = new Net::Telnet(Timeout => 10, Prompt => "/\$/");
$t->open(Host => $hostname) || die "can't open telnet connection: $!" ;
$t->login("someuer","somepassword") || die "can't login as someuser
with password somepassword: $!";

$t->cmd("telnet foo 10000");

@list = ( "LOGIN" , "USER:superuser" , "PASS:hello1234" , "\n" ,
$dir_val, "USER:$alias" , "first:$fname" , "last:$lname" , "password:
$pswd" , "email:$email", "\n" , "LOGOUT" , "\n" );

$t->print(@list) || die "problem printing: $!";

This code creates this error:

Use of uninitialized value in join at
/usr/local/lib/perl5/site_perl/5.6.0/Net/T
elnet.pm line 1464

In the Apache error log

It executes normally, (it doesn't die) but it does not properly execute
my commands on the foreign database, (newguy123 is not created).

Can anyone help me?

Thanks,

John P.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 08 Aug 2000 16:21:51 -0600
From: steve mestdagh <mestdagh@us.ibm.com>
Subject: proximity/adjacency matches w/ regexp?
Message-Id: <399087FF.42430592@us.ibm.com>

Hi,
Any have any experience writing a regex for matching two words near each
other, 
ie. within let's say 5 words.
ex: if I'm matching on six & pack, I'd like to find:
	six word anotherword pack 
or:	pack word six

I searched cpan for modules but didn't find anything explicitly for this
problem. 
TIA,
steve


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

Date: 08 Aug 2000 17:24:04 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: proximity/adjacency matches w/ regexp?
Message-Id: <m3u2cvbddn.fsf@dhcp11-177.support.tivoli.com>

steve mestdagh <mestdagh@us.ibm.com> writes:

> Hi,
> Any have any experience writing a regex for matching two words near each
> other, 
> ie. within let's say 5 words.
> ex: if I'm matching on six & pack, I'd like to find:
> 	six word anotherword pack 
> or:	pack word six
> 

The difficulty of this increases quickly depending on how general a
solution you want (things like line-spanning, handling more than two
words, stemming, etc.).  But a quick-and-dirty solution would be:

(I'm assuming that "within 5 words" means that there can be at most 4
words between the keywords, and that "words" in this context really
means non-whitespace, so "&" counts as a word.)

/\bsix(?:\s+\S+){0,4}\s+pack\b/i || /\bpack(?:\s+\S+){0,4}\s+six\b/i;

This handles the two examples, and skips things like "sixteen pack",
but is fooled by "six, pack".  That is fixable, but where does it end?
:)

-- 
Ren Maddox
ren@tivoli.com


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

Date: Wed, 09 Aug 2000 00:42:42 GMT
From: tim@degree.ath.cx (Tim Hammerquist)
Subject: Re: Reap ?
Message-Id: <slrn8p1ar6.u2.tim@degree.ath.cx>

On Mon, 07 Aug 2000 17:53:20 -0500, Ilja Tabachnik <billy@arnis-bsl.com> wrote:
> Tim Hammerquist wrote:
> > REAP() executes when the program receives a CHLD signal.  Some signal
> > handlers need to reinstall themselves each time they are called; CHLD is
> > one of those.  See perlipc for more info.
> 
> IMHO, better is to say: on some systems signal handlers need
> to reinstall themselves.

Correct.  I incorrectly paraphrased the perlipc doc.  Part of the SysV
vs. BSD/POSIX conflict.

 ...see perlipc for more info...  =)

-- 
-Tim Hammerquist <timmy@cpan.org>

Experience is a good school, but the fees are high.
	-- Heinrich Heine


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

Date: 08 Aug 2000 16:14:27 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Reg Expression multiple parsing
Message-Id: <m3zomnbglo.fsf@dhcp11-177.support.tivoli.com>

G <glchyNOglSPAM@email.com.invalid> writes:

> Hi,
> i want to parse a file and extract config vars (in upper case).
> The vars can actually be $,@,% with '_' in between like
> @THIS_IS_A_CFG_VAR or %SIMPLEVAR.
> 
> I could extract the first occurence but the /m parameter seems
> not to take the single string ($_) and treat it as a multiple
> string. Hence in a line like 'something or {the*other}
> @THIS_IS_A_CFG_VAR other blah&blah&blah %SECONDVAR continuing
> blah', i can only extract @THIS_IS_A_CFG_VAR. How to i get both
> @THIS_IS_A_CFG_VAR  and %SECONDVAR?
> 
> while (<FILE>) {
>   /([\$|@|%][A-Z]*(_?[A-Z]*)*)/mg;
>   $a1 = $1;
>   if ($a1 =~ /[\$|@|%]\S+/) {
>     print "$a1\n";
>   }

It doesn't seem like you ever do anything to grab the second (or more)
occurrences.  Also, I think your RE could use some improvement.  And
I'm not sure what the "if" is buying you.

while (<FILE>) {
  @vars=/([\$@%][A-Z_]+)/g;      # this allows _ at the start
# @vars=/([\$@%][A-Z][A-Z_]*)/g; # while this does not

  print "@vars";
}

Your RE allows underscores at the start and also allows isolated "$", "@", or
"%" (plus "|") to match.

-- 
Ren Maddox
ren@tivoli.com


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

Date: Wed, 09 Aug 2000 00:57:54 GMT
From: decklin+usenet@red-bean.com (Decklin Foster)
Subject: Re: returning error message
Message-Id: <m02k5.14486$f_5.71273@news1.rdc1.ct.home.com>

daemon <daemon@i.am.daemon> writes:

> Yeah, but doing it that way is a lot of extra work. I have to define
> my own error codes and their meanings.  And then, each script which
> uses this module has to understand those error codes.

Actually, this is fine. If you are working on a layer above the C
library, you need not be limited to the C lib's errors (after all, it
will probably be impossible to express a higher-level error in these
terms). I was thinking more specifically about the case of opening a
file, where there is already a well-defined way of communicating
error.

Allow me to suggest something for the implementation:

> 	unless (<more code>) {
> 		$Module_errmsg = "can't find entry blargh!";

                $errmsg = "can't find entry blargh!";

And then depending on your philosophy:

> script.pl:
> 	DoStuff || die "$Module_errmsg\n";

        DoStuff or die "$Module::errmsg\n";

        # or like this

        $module_thingy->DoStuff()
            or die $module_thingy->get_last_error();

(where implementing get_last_error() and related bits is trivial.)

('or die' just being force of habit, I think. TMTOWTDI.)

-- 
There is no TRUTH. There is no REALITY. There is no CONSISTENCY. There
are no ABSOLUTE STATEMENTS. I'm very probably wrong. -- BSD fortune(6)


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

Date: Tue, 08 Aug 2000 22:53:26 GMT
From: wutang_warrior@my-deja.com
Subject: Re: Running other programs in background
Message-Id: <8mq316$krp$1@nnrp1.deja.com>

I've got it working great (WIN32::Process), my argument is a ">" to a
file, it doesn't like this at all!!! and complains that it couldn't
open the file that output is destined for.

How do I capture the output of the program (cmdline utility) to a $var
or do it like above?



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 08 Aug 2000 21:45:57 +0000
From: bobby <donotreply@interbulletin.bogus>
Subject: Send email with attatchment using CGI script?
Message-Id: <39907F95.7BD43E6D@interbulletin.com>


Could anyone please inform me how, if possible, an attatchment can be sent
using Mail::Internet or any other package in a CGI script.  I am fairly new
to Perl/CGI and I have limited documentation.


_______________________________________________
M$ Upgrade: Windows2000 - Windows98 = 2 Windows
Submitted via free WebNewsReader of http://www.interbulletin.com
Any complaints about spamming please send to abuse @ InterBulletin.com



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

Date: Tue, 08 Aug 2000 23:17:04 GMT
From: marcel@codewerk.com (Marcel Grunauer)
Subject: Re: Send email with attatchment using CGI script?
Message-Id: <slrn8p1564.h1e.marcel@gandalf.local>

On Tue, 08 Aug 2000 21:45:57 +0000, bobby <donotreply@interbulletin.bogus>
wrote:

>Could anyone please inform me how, if possible, an attatchment can be sent
>using Mail::Internet or any other package in a CGI script.  I am fairly new
>to Perl/CGI and I have limited documentation.


There are probably loads of ways but I like MIME::Lite. Get it from CPAN.


-- 
Marcel
sub AUTOLOAD{($_=$AUTOLOAD)=~s;^.*::;;;y;_; ;;print} Just_Another_Perl_Hacker();


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

Date: Tue, 08 Aug 2000 17:52:35 -0800
From: "Jeff Yoak" <jeff@yoak.com>
Subject: Re: Send email with attatchment using CGI script?
Message-Id: <8mq32f0ir1@news2.newsguy.com>

In article <39907F95.7BD43E6D@interbulletin.com>, bobby
<donotreply@interbulletin.bogus> wrote:
> 
> Could anyone please inform me how, if possible, an attatchment can be
> sent using Mail::Internet or any other package in a CGI script.  I am
> fairly new to Perl/CGI and I have limited documentation.

To attach the message you'll want to look at the MIME:: modules. 
MIME::Lite will probably serve.

Cheers, Jeff



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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 3956
**************************************


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