[11720] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5321 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 7 15:07:15 1999

Date: Wed, 7 Apr 99 12:01:32 -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           Wed, 7 Apr 1999     Volume: 8 Number: 5321

Today's topics:
    Re: Problems connecting to Oracle 8 from Perl using DBI (Bill Morgan)
    Re: random number ( -w ) (Abigail)
    Re: random number ( -w ) (Abigail)
    Re: random number ( -w ) (Abigail)
    Re: random number (Abigail)
    Re: random number (Abigail)
    Re: Recursion in Perl <aqumsieh@matrox.com>
    Re: regexp matching digits <cassell@mail.cor.epa.gov>
    Re: Seemingly Simple Regexp problem... <cassell@mail.cor.epa.gov>
    Re: Typeglobs broken by threaded perl??? (Bruce R Miller)
    Re: Unpack Question <cassell@mail.cor.epa.gov>
    Re: wanted: elegant inverse operation for vec (Andrew Allen)
        web-based newreader? <jwelsh@nospam_qrtp.quintiles.com>
        Win32 Socket help frankholt@my-dejanews.com
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 7 Apr 1999 15:06:12 GMT
From: wmorgan@nswc.navy.mil (Bill Morgan)
Subject: Re: Problems connecting to Oracle 8 from Perl using DBI
Message-Id: <1999Apr7.150313.10868@relay.nswc.navy.mil>

In article <7edme7$gak$1@agate.berkeley.edu>, jed@socrates.berkeley.edu (Jed Parsons) wrote:
>>$ENV{'ORACLE_HOME'}  = "E:\ORANT";
>
>Isn't that \ going to be treated as an escap character within double quotes?
>
>Jed
>

You're right, but when I change it to $ENV{'ORACLE_HOME'}  = 'E:\ORANT';
the result is still the same:
Cannot connect to Oracle database: ORA-03121: no interface driver connected - 
function not performed (DBD: login failed) 

---------------------------------------------------------------------------
William E. Morgan       NAVAL SURFACE WARFARE CENTER
Code N84                     email: wmorgan@nswc.navy.mil
17320 Dahlgren Rd.     phone: (540)653-6088
Dahlgren, VA  22448   fax: (540)653-1810



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

Date: 7 Apr 1999 18:33:59 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: random number ( -w )
Message-Id: <7eg8en$8ep$6@client2.news.psi.net>

IndexFinger.com (indexfinger@usa.net) wrote on MMXLV September MCMXCIII
in <URL:news:ugDO2.273$xI5.10326@typhoon.nycap.rr.com>:
<> > #!usr/bin/perl -w
<> 
<> What does the "-w" do?


It does what the manual says it does!



Abigail
-- 
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))


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

Date: 7 Apr 1999 18:34:29 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: random number ( -w )
Message-Id: <7eg8fl$8ep$7@client2.news.psi.net>

IndexFinger.com (indexfinger@usa.net) wrote on MMXLV September MCMXCIII
in <URL:news:tuGO2.280$xI5.10449@typhoon.nycap.rr.com>:
&& > I'm now going to assume you are joking...
&& 
&& I'm not.


Then we must assume you're rude.


Go away.



Abigail
-- 
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


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

Date: 7 Apr 1999 18:35:36 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: random number ( -w )
Message-Id: <7eg8ho$8ep$8@client2.news.psi.net>

Jonathan Stowe (gellyfish@gellyfish.com) wrote on MMXLV September
MCMXCIII in <URL:news:370b3846.10690743@news.dircon.co.uk>:
$$ On Wed, 07 Apr 1999 06:52:10 GMT, "IndexFinger.com"
$$ <indexfinger@usa.net> wrote:
$$ 
$$ >> #!usr/bin/perl -w
$$ >
$$ >
$$ >What does the "-w" do?
$$ 
$$ P:\>perl -e "print $fish"
$$ 
$$ P:\>perl -we "print $fish"
$$ Name "main::fish" used only once: possible typo at -e line 1.
$$ Use of uninitialized value at -e line 1.
$$ 
$$ Thats what it does


Indeed, -w enables seafood detection.



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


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

Date: 7 Apr 1999 18:29:48 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: random number
Message-Id: <7eg86s$8ep$4@client2.news.psi.net>

northernnj@my-dejanews.com (northernnj@my-dejanews.com) wrote on MMXLV
September MCMXCIII in <URL:news:7eendd$8uh$1@nnrp1.dejanews.com>:
** Why doesn't the random number generator work?

Because you never call it.

** When I put in:
** 
** #!usr/bin/perl -w
** srand;
** @array = (1 .. 10);
** $random_number = "rand(@array)";
** print = "$random_number\n";
** 
** 
** I get:
** rand 1 2 3 4 5 6 7 8 9 10


What makes you think Perl does evaluation of what's inside a string?
Not that it would work; look up how rand() works.



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
 .qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
 .qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'


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

Date: 7 Apr 1999 18:33:10 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: random number
Message-Id: <7eg8d6$8ep$5@client2.news.psi.net>

Jason Simms (ffchopin@worldnet.att.net) wrote on MMXLV September MCMXCIII
in <URL:news:7eeom4$476$1@bgtnsc01.worldnet.att.net>:
@@ > When I put in:
@@ >
@@ > #!usr/bin/perl -w
@@ > srand;
@@ > @array = (1 .. 10);
@@ > $random_number = "rand(@array)";
@@ > print = "$random_number\n";
@@ >
@@ >
@@ > I get:
@@ > rand 1 2 3 4 5 6 7 8 9 10
@@ 
@@ Well, the " " are doing variable interpolation.  Do this:
@@ 
@@ $random_number = rand(@array);
@@ 
@@ This should work better...


No it doesn't.

Try:

    @array = (100 .. 120);
    $random_number = rand (@array);
    print $random_number, "\n";



Abigail
-- 
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"


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

Date: Wed, 7 Apr 1999 11:19:56 -0400 
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Recursion in Perl
Message-Id: <x3y90c4o3tv.fsf@tigre.matrox.com>


David Delikat <ddelikat@protix.com> writes:

> HMMM, let me venture a guess...
> 
> perldoc recursive

Is that a joke? I don't get it. No such pod exist.



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

Date: Wed, 07 Apr 1999 09:57:45 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: regexp matching digits
Message-Id: <370B8E89.989E6D4D@mail.cor.epa.gov>

Rick Delaney wrote:
> 
> [posted & mailed]

[BTW, thanks]
 
> David L. Cassell wrote:
> >
> > frf wrote:
> > >
> > > Given $filename = sfour030299data.log
> > > I'd like to get $filedate = 030299.
> > >
> > > Thanks much
> >
> > Read up on regexes in perlre.  There's some neat stuff waiting
> > for you.  For instance, you can match digits with \d and you
> > can capture with parens.  Like this:
> >
> > ($date = $filename) =~ /(\d+)/;
> 
> ITYM
> 
>     ($date) = $filename =~ /(\d+)/;
> 
> or maybe
> 
>     ($date = $filename) =~ s/\D//g;
> 
> better written as
> 
>     ($date = $filename) =~ tr/0-9//cd;
> 
> --
> Rick Delaney
> rick.delaney@home.com

D'oh!  As I just said elsewhere, yesterday obviously wasn't a 
good day for me.  I *meant* #1 up there, although that *clearly*
wasn't what I wrote.  And I'm usually careful about checking
my code first too - and now I remember why...
 
David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 07 Apr 1999 11:10:53 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Seemingly Simple Regexp problem...
Message-Id: <370B9FAD.7B43CE5B@mail.cor.epa.gov>

Diggy Tim wrote:
> 
> Here is my problem.. I am trying to delimit a string so that only specified
> allowed characters arn't replaced by an underscore...
> The allowed characters are
> A-Z a-z 0-9 . (fullstop) - @
> 
> I can easliy make a regexp which replaces the allowed characters, but i was
> hoping it would be possible to specifiy it to only replace characters not in
> that group... This has stumped me, this will be in a fairly intensive area
> of operation so it needs to be as fast as possible...
> 
> Is a regexp the best solution??

This can be done by a regex, but it won't be the *best* solution.
tr/// is a better option when making one-character substitutions.

    tr/A-Za-z0-9.@-/_/c

And make sure not to put the dash between two characters there on
the left-hand side.

> Any help will be greatly appreciated.
> 
> Cheers,
> Tim
 
David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 7 Apr 1999 17:17:31 GMT
From: miller@altaira.cam.nist.gov (Bruce R Miller)
Subject: Re: Typeglobs broken by threaded perl???
Message-Id: <7eg3vb$7ld$1@news.nist.gov>

In article <7edsol$r0g$1@mathserv.mps.ohio-state.edu>,
	ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
>
>Apparently, you did not try ${'_'} (no, this is not *just* a smiley).
>If you would, you would see that $_ is a lexical variable in a
>threaded Perl.

Wow! That's a pretty big change (isn't it?)
While I can see how dynamic vars makes threading difficult, this change is going to
break lots of old programs.

Is there any workaround (other than recompiling perl w/o threads) to 
recover the local $_?
Wrapping a
 { local($_)=('');
  ... }
around everything doesn't seem to help.

-- 
--
bruce.miller@nist.gov
http://math.nist.gov/~BMiller/



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

Date: Wed, 07 Apr 1999 10:11:59 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Unpack Question
Message-Id: <370B91DF.A8A0EE52@mail.cor.epa.gov>

Rick Delaney wrote:
> 
> [posted & mailed]
> 
> David L. Cassell wrote:
> >
> > David Delikat wrote:
> > >
> > > first, if there are bits in between, then you have to account
> > > for those in your unpack string.  every bit of information
> > > MUST be accounted for save any trailing info you dont care about.
> > >
> > > if your data looks like this:
> > >
> > > 0001100010000111
> > >
> > > then 'b5 b5 b6' will do fine.
> 
> No, it won't.  Try it.
> 
>     $foo = "\x18\x87";# 0001100010000111
>     @bar = unpack('B5B5B6', $foo);# use B to get high order 1st
>     print "@bar\n";
> 
> gives
> 
>     00011 10000
> 
> Unfortunately pack and unpack byte-align when using b and B.  So if you
> want a bit string of 5 characters, unpack will pull 8 bits and give you
> the first 5 (or last 5 if using b).
> 
> [more stuff snipped]
> 
> Even if (un)?pack's behaviour is corrected at some time in the future,
> this will still not work since x means to skip a *byte*, not a bit.
> 
> One possible solution would be
> 
>     @bar = unpack('A5A5A6', unpack('B16', $foo));
> 
> It's about this time that Steffen Beyer usually steps in touting
> Bit::Vector.  I've not used it but I hear it's good.
> 
> --
> Rick Delaney
> rick.delaney@home.com

Cripes!  That's three!  Rick, you're totally right.  I stepped
in when I saw dav's unpack() solution, and didn't even see 
that the subject was *bits* rather than *bytes*.

I need more caffeine in the late afternoon.

David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 7 Apr 1999 16:33:40 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: wanted: elegant inverse operation for vec
Message-Id: <7eg1d4$74f$1@fcnews.fc.hp.com>

William Blasius #42722 (Wm.Blasius@ks.sel.alcatel.de) wrote:
: Greetings:

: the Subject pretty much says it all. I'm trying to come up with an
: elegant way to turn a sparse bitfield into a set of "bit numbers".
: ie: 00100100 becomes 2 5
: I'd happily settle for an algorithm to get the number for a single
: bit, but I'm having a bit of a bad brain day. There must be a good
: popular idiom for this, iteration seems so...so...so...repetitive!

$_=unpack("b*",$vector);
push(@bits,pos()-1) while /1/g;

Andrew


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

Date: Wed, 07 Apr 1999 13:34:40 -0400
From: Jason <jwelsh@nospam_qrtp.quintiles.com>
Subject: web-based newreader?
Message-Id: <370B9730.37D23060@nospam_qrtp.quintiles.com>

anyone know of a *web-based* perl/cgi script (even Java)
thats free to use that can read/post to news servers?
any help appreciated

remove the nospam_ to reply

jwelsh at qrtp dot quintiles dot com



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

Date: Wed, 07 Apr 1999 18:40:59 GMT
From: frankholt@my-dejanews.com
Subject: Win32 Socket help
Message-Id: <7eg8rq$h77$1@nnrp1.dejanews.com>

I am writing a small server program to run on either NT or Unix. This program
listens on a socket for message strings from clients on remote machines. To
test this program I also wrote a small client to generate the messages.

All was well for several days. Messages were generated by the client and
received by the server. Then the following problem started:

The server does not see any messages. The construct: while (<CLIENT>) { ... }
does not get anything so all code inside the loop is never executed.

The relavent code is:
$port = 2345;
$proto = getprotobyname("tcp");
socket( SERVER,PF_INET,SOCK_STREAM,$proto);
bind(SERVER,sockaddr_in($port,INADDR_ANY)));
listen(SERVER,1);

for ( ; $paddr = accept(CLIENT,SERVER) ; ) {
    print STDOUT "Accepted a connection\n";
    while (<CLIENT>) {
        $data = $_;
        print STDOUT "Saw data: $data\n";
        # ... do processing here ...
    }
    print STDOUT "Closing connection\n";
    close(CLIENT);
}

I see the "Accepted connection" and the "Closing connection" message but I no
longer get the "Saw data" part.

This is all done on Windows NT 4 (Service Pack 3) and Perl 5.00402 binary
distribution.

I would appreciate any replies also be e-mailed to:
frankh@mwes.com
as my newsfeed is unreliable.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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