[25300] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7545 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 21 00:05:41 2004

Date: Mon, 20 Dec 2004 21:05:07 -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           Mon, 20 Dec 2004     Volume: 10 Number: 7545

Today's topics:
    Re: generating a session id ioneabu@yahoo.com
    Re: generating a session id ioneabu@yahoo.com
        Good practice to detect empty string? ipellew@pipemedia.co.uk
    Re: Good practice to detect empty string? <kkeller-usenet@wombat.san-francisco.ca.us>
        Howto covert to Hash structure? ipellew@pipemedia.co.uk
    Re: Howto covert to Hash structure? <jkeen_via_google@yahoo.com>
        HowTo tell if from cmd_line || httpd ipellew@pipemedia.co.uk
    Re: HowTo tell if from cmd_line || httpd <flavell@physics.gla.ac.uk>
    Re: HowTo tell if from cmd_line || httpd <nospam@bigpond.com>
    Re: inserting a line into the body of an eMail before f <dlr93612@yahoo.com>
    Re: Is zero even or odd? <a.newmane.remove@eastcoastcz.com>
    Re: Is zero even or odd? <a.newmane.remove@eastcoastcz.com>
    Re: Is zero even or odd? <a.newmane.remove@eastcoastcz.com>
    Re: Is zero even or odd? <shawn.corey@sympatico.ca>
    Re: Is zero even or odd? <thegreatone@example.com>
    Re: Is zero even or odd? <see@sig.com>
    Re: Is zero even or odd? <nospam@nospam.com>
    Re: Is zero even or odd? <a.newmane.remove@eastcoastcz.com>
    Re: Is zero even or odd? <a.newmane.remove@eastcoastcz.com>
    Re: Is zero even or odd? <tomcatpolka@NyOaShPoAoM.com>
    Re: Is zero even or odd? (Richard Tobin)
    Re: Is zero even or odd? <emurphy42@socal.rr.com>
    Re: Is zero even or odd? <a.newmane.remove@eastcoastcz.com>
    Re: Is zero even or odd? <a.newmane.remove@eastcoastcz.com>
    Re: Is zero even or odd? <no@spam.please>
        odbc howto <sconnet@chokecoxspam.net>
    Re: odbc howto <matthew.garrish@sympatico.ca>
    Re: Open file, print into file, what variable is used? <bustanut2020@yahoo.com>
    Re: Parsing Large Files xhoster@gmail.com
        Why does this work? <emschwar@fc.hp.com>
    Re: Why does this work? <1usa@llenroc.ude.invalid>
    Re: Why does this work? <noreply@gunnar.cc>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 20 Dec 2004 15:06:34 -0800
From: ioneabu@yahoo.com
Subject: Re: generating a session id
Message-Id: <1103583994.898085.109340@z14g2000cwz.googlegroups.com>

Sorry about lack of indenting.  'Worthless' is a strong criticism for a
simple piece of code which works even if it is ugly.  A google groups
search reveals that code is rarely referred to as worthless in
comp.lang.perl.misc.  In fact, you have never called a piece of code
worthless in this group until this post.  I don't know if I should feel
shamed or honored.
Wouldn't 

my @array = ('a' .. 'z', '0' .. '9');

work also?



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

Date: 20 Dec 2004 15:14:23 -0800
From: ioneabu@yahoo.com
Subject: Re: generating a session id
Message-Id: <1103584463.301281.180310@f14g2000cwb.googlegroups.com>

I should clarify.  I would create the id, and then query the MySQL
table of existing ids to see if the one created already exists
(unlikely but possible).  If it already exists, I would just create
another and repeat until I have a unique id.  It is unlikely that this
will go on for long with my long, randomly generated id strings.  The
reason for not using 123 is the same reason for not using a simple
password.  Someone might start trying to get in on a current session by
guessing a valid id.  Thanks for   @array = ('a' .. 'z', 0 .. 9);  I am
now beating myself with a stick for not thinking of that myself.
That's the problem with Perl, you can't hide your code away in compiled
classes where no one can see what a mess it is :-)


Thanks!

wana



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

Date: 20 Dec 2004 16:04:34 -0800
From: ipellew@pipemedia.co.uk
Subject: Good practice to detect empty string?
Message-Id: <1103587474.137545.215560@c13g2000cwb.googlegroups.com>

Hi all;

Pls advise the perlophiliacs method of deciding a string is empty.

I am using
if ( $@ || $c_var eq "" ) {
but constantly read `eq` is expensive.

For example is
if ( $@ || ! length $c_var ) {
better, faster, cheaper 

Regards
Ian



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

Date: Mon, 20 Dec 2004 16:37:18 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: Good practice to detect empty string?
Message-Id: <vq7k92xjqo.ln2@goaway.wombat.san-francisco.ca.us>

On 2004-12-21, ipellew@pipemedia.co.uk <ipellew@pipemedia.co.uk> wrote:
>
> Pls advise the perlophiliacs method of deciding a string is empty.
>
> I am using
> if ( $@ || $c_var eq "" ) {
> but constantly read `eq` is expensive.

 ...and using $@ in the absence of an eval is silly.

Is there something wrong with

if ($c_var)

?  It's not exactly the same, but since you provide no context it's
hard to know what you really need.

--keith

-- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom



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

Date: 20 Dec 2004 16:03:33 -0800
From: ipellew@pipemedia.co.uk
Subject: Howto covert to Hash structure?
Message-Id: <1103587413.299297.45670@f14g2000cwb.googlegroups.com>

Hi all;

Whats the fastest way to convert the likes of:-
it var=`A` list=who;loves;"me"
it list='D|"abc.htm"|Abc dynamite;B|xyz.htm|Here =go' var=C
it var=S list="Multi|S001|S103|Saxsoph
maybe;Mono|S84|S634|Pea=\"green\";|S011|S973|'Informix';";
it etc etc

To sumthing like:-
%HoH= {
it0 => {
val => {A1=>'who',
A1=>'loves',
A1=>'me'},
it1 => {
val => {C1=>'D',
C2=>'"abc.htm"',
C3=>'Abc dynamite'},
{C1=>'B',
C2=>'xyz.htm',
C3=>'Here =go'}},
it2 => {
val => {S1=>'Multi',
S2=>'S001',
S3=>'S103',
S4=>'Saxsoph maybe'},
{S1=>'Mono',
S2=>'S84',
S3=>'S634',
S4=>'Pea=green'},
{S1=>'',
S2=>'S011',
S3=>'S973',
S4=>'Informix'}}
it3 => etc
}

The quote variations are me trying to allow sysadmin loose choice of
defining the variables.
My skills are not good enough to get this to work in Perl.
Maybe theres a module that would do it for me?

Regards
Ian



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

Date: Tue, 21 Dec 2004 03:55:47 GMT
From: Jim Keenan <jkeen_via_google@yahoo.com>
Subject: Re: Howto covert to Hash structure?
Message-Id: <79Nxd.7133$EL5.4907@trndny09>

ipellew@pipemedia.co.uk wrote:
> Hi all;
> 
> Whats the fastest way to convert the likes of:-
> it var=`A` list=who;loves;"me"
> it list='D|"abc.htm"|Abc dynamite;B|xyz.htm|Here =go' var=C
> it var=S list="Multi|S001|S103|Saxsoph
> maybe;Mono|S84|S634|Pea=\"green\";|S011|S973|'Informix';";
> it etc etc


> [snip]


> My skills are not good enough to get this to work in Perl.

Then improve your skills by learning to use the documentation supplied 
with Perl.

     perldoc -f split

     perldoc perlvar

     perldoc perlreftut

etc.

Jim Keenan


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

Date: 20 Dec 2004 16:05:42 -0800
From: ipellew@pipemedia.co.uk
Subject: HowTo tell if from cmd_line || httpd
Message-Id: <1103587542.071028.220550@c13g2000cwb.googlegroups.com>

Hi all;

Whats a sure fire way to tell I am executed from either httpd or
command line? At the moment, I decide on HTTP_USER_AGENT having a
value to say I am from httpd.
This needs to work whatever the platform / server.

Regards
Ian



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

Date: Tue, 21 Dec 2004 03:13:25 +0100
From: "Alan J. Flavell" <flavell@physics.gla.ac.uk>
Subject: Re: HowTo tell if from cmd_line || httpd
Message-Id: <Pine.LNX.4.58.0412210303240.17729@lxplus029.cern.ch>

On Tue, Dec 20, ipellew@pipemedia.co.uk inscribed on the eternal
scroll:

> Whats a sure fire way to tell I am executed from either httpd or
> command line? 

You can't, really, since anything you care to test could equally be 
faked from the command line.

> At the moment, I decide on HTTP_USER_AGENT having a
> value to say I am from httpd.

There's no absolute mandate to set that to a non-null value, so I'd 
have to advise against that...

Seems to me that the closest specified item to what you're
asking for would be the GATEWAY_INTERFACE :

http://cgi-spec.golux.com/draft-coar-cgi-v11-03-clean.html#6.1.4

> This needs to work whatever the platform / server.

Indeed.  If you'd suggested otherwise, you'd have found yourself 
contradicted ;-)

GATEWAY_INTERFACE -is- a bona fide feature of the CGI specification,
right from way back: http://hoohoo.ncsa.uiuc.edu/cgi/env.html

Any so-called CGI interface which fails to provide it would be 
seriously deficient.  Of course, it could be faked from the command 
line, as I mentioned before: but anyone who does that gets, 
presumably, just what they asked for.

-- 
                   Procrastination gives you something to look forward
                           to putting off tomorrow.  -spotted on ahbou


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

Date: Tue, 21 Dec 2004 12:46:29 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: HowTo tell if from cmd_line || httpd
Message-Id: <32ph45F3inj4fU1@individual.net>

ipellew@pipemedia.co.uk wrote:

> Hi all;
> 
> Whats a sure fire way to tell I am executed from either httpd or
> command line? At the moment, I decide on HTTP_USER_AGENT having a
> value to say I am from httpd.
> This needs to work whatever the platform / server.
> 
> Regards
> Ian

You could do that, or use the following (may not work in some platforms):

sub batch() {
        open(TTY, "/dev/tty");
        return 0 if tcgetpgrp(fileno(*TTY)) == getpgrp();
        return 1;
}

sub interactive {
        return !batch();
}

gtoomey


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

Date: 20 Dec 2004 19:52:59 -0800
From: "Lisa" <dlr93612@yahoo.com>
Subject: Re: inserting a line into the body of an eMail before forwarding
Message-Id: <1103601178.982508.113080@c13g2000cwb.googlegroups.com>


Gunnar Hjalmarsson wrote:
> > my $part = '(?:;\\s*charset=\\S+)?\\s+Cont\S+Encoding: *\\S+\\n';
>
> I've tweaked that row:
>
>      my $part = '(?:;\s*charset=\S+)?\s+Cont\S+Encoding:\s\S+\n';
>
> Now, when I run the code below, it does insert "Original addressee:
 ..."
> as expected.
> 
That was the fix right there!! thank you very much.

Lisa



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

Date: Mon, 20 Dec 2004 15:18:47 -0800
From: "Alfred Z. Newmane" <a.newmane.remove@eastcoastcz.com>
Subject: Re: Is zero even or odd?
Message-Id: <32p4urF3puupoU1@individual.net>

BB wrote:
> Josef Moellers wrote:
>>
>> Gactimus wrote:
>>> I know 0 is neither negative or positive but what about odd/even? I
>>> think it's even.
>>>
>>> Odd numbers start at 1 and go every other number
>>> 1,3,5,7;1,-1,-3,-5,-7 Even starts at 2 and go every other number
>>> 2,4,6,8;2,0,-2,-4,-6,-8
>>
>> As it can be divided by 2 without a remainder, it is obviously even.
>
> The divisor would have to be something smaller than 0 like -2.
> Therefore zero is both even and negative.

I'm sorry, sir, but 0 is universally defined in math to be neither - nor
+, it's jsut 0. Many graphing and soem scientific calculators have a
sign function. On any calc I've tried this on, it gives -1 for any
negative number, it gives a 1 for ant positive value, and 0 (zero) for,
well, 0 (zero.) As is defined in basic math.




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

Date: Mon, 20 Dec 2004 15:21:14 -0800
From: "Alfred Z. Newmane" <a.newmane.remove@eastcoastcz.com>
Subject: Re: Is zero even or odd?
Message-Id: <32p53dF3paevvU1@individual.net>

Nicholas O. Lindan wrote:
> "John Sefton" <john@petcom.com> wrote
>
>> 0 can't be divided by itself,
>
> Sure it can: 0 / 0 = 0 * (1 / 0) = 0 * infinity = 1
>
> It works if the only three numbers in the universe are
> 0, 1, and infinity -- A number system that seems very
> suited to usenet.

Except for the fact that: 0 / 0 = undefined

Or actually more correct: n / 0 = undefined




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

Date: Mon, 20 Dec 2004 15:25:26 -0800
From: "Alfred Z. Newmane" <a.newmane.remove@eastcoastcz.com>
Subject: Re: Is zero even or odd?
Message-Id: <32p5b9F3or7lmU1@individual.net>

John Woodgate wrote:
> I read in sci.electronics.design that David Kastrup <dak@gnu.org>
> wrote (in <x5mzw8k8f1.fsf@lola.goethe.zz>) about 'Is zero even or
> odd?', on Mon, 20 Dec 2004:
>
>> Ah, so 1 = 0/0 = (0+0)/0 = (0/0) + (0/0) = 2 ?
>
> 0/0 can take ANY value.

n / 0 = undefined




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

Date: Mon, 20 Dec 2004 19:21:43 -0500
From: Shawn Corey <shawn.corey@sympatico.ca>
Subject: Re: Is zero even or odd?
Message-Id: <x%Jxd.9604$GK5.651998@news20.bellglobal.com>

Nicholas O. Lindan wrote:
> 
> 1 + 1 = 0/0 + 0/0 = (0 + 0)/0 = 2 * 0/0 = 2
> 

          a = b
        a^2 = ab
  a^2 - b^2 = ab - b^2
(a+b)(a-b) = b(a-b)
       a+b  = b
but a = b
        a+a = a
         2a = a
          2 = 1

What could be clearer?

    --- Shawn


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

Date: Mon, 20 Dec 2004 17:32:31 -0700
From: Jim Thompson <thegreatone@example.com>
Subject: Re: Is zero even or odd?
Message-Id: <nnres0dujt8679dp7cimhmsah5iojuonpb@4ax.com>

On Mon, 20 Dec 2004 19:21:43 -0500, Shawn Corey
<shawn.corey@sympatico.ca> wrote:

>Nicholas O. Lindan wrote:
>> 
>> 1 + 1 = 0/0 + 0/0 = (0 + 0)/0 = 2 * 0/0 = 2
>> 
>
>          a = b
>        a^2 = ab
>  a^2 - b^2 = ab - b^2
>(a+b)(a-b) = b(a-b)
>       a+b  = b
>but a = b
>        a+a = a
>         2a = a
>          2 = 1
>
>What could be clearer?
>
>    --- Shawn

I remember that one from when I was in high school ;-)

                                        ...Jim Thompson
-- 
|  James E.Thompson, P.E.                           |    mens     |
|  Analog Innovations, Inc.                         |     et      |
|  Analog/Mixed-Signal ASIC's and Discrete Systems  |    manus    |
|  Phoenix, Arizona            Voice:(480)460-2350  |             |
|  E-mail Address at Website     Fax:(480)460-2142  |  Brass Rat  |
|       http://www.analog-innovations.com           |    1962     |
             
I love to cook with wine.      Sometimes I even put it in the food.


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

Date: Tue, 21 Dec 2004 01:05:34 GMT
From: "Nicholas O. Lindan" <see@sig.com>
Subject: Re: Is zero even or odd?
Message-Id: <yFKxd.5373$Z47.3517@newsread2.news.atl.earthlink.net>

"Shawn Corey" <shawn.corey@sympatico.ca> wrote
>           a = b
>         a^2 = ab
>   a^2 - b^2 = ab - b^2
> (a+b)(a-b) = b(a-b)
>        a+b  = b
> but a = b
>         a+a = a
>          2a = a
>           2 = 1

Now if we can just get the IRS to agree.

-- 
Nicholas O. Lindan, Cleveland, Ohio
Consulting Engineer:  Electronics; Informatics; Photonics.
Remove spaces etc. to reply: n o lindan at net com dot com



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

Date: Tue, 21 Dec 2004 01:08:55 GMT
From: Fred Bloggs <nospam@nospam.com>
Subject: Re: Is zero even or odd?
Message-Id: <41C77754.7070800@nospam.com>



Alfred Z. Newmane wrote:
> Nicholas O. Lindan wrote:
> 
>>"John Sefton" <john@petcom.com> wrote
>>
>>
>>>0 can't be divided by itself,
>>
>>Sure it can: 0 / 0 = 0 * (1 / 0) = 0 * infinity = 1
>>
>>It works if the only three numbers in the universe are
>>0, 1, and infinity -- A number system that seems very
>>suited to usenet.
> 
> 
> Except for the fact that: 0 / 0 = undefined
> 
> Or actually more correct: n / 0 = undefined
> 
> 

0/0={ SET OF ALL INTEGERS }

n/0= NULL SET  for n<>0

It is very well-defined.



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

Date: Mon, 20 Dec 2004 17:40:24 -0800
From: "Alfred Z. Newmane" <a.newmane.remove@eastcoastcz.com>
Subject: Re: Is zero even or odd?
Message-Id: <32pd7rF3q16ikU1@individual.net>

David Kastrup wrote:
> John Woodgate <jmw@jmwa.demon.contraspam.yuk> writes:
>
>> I read in sci.electronics.design that Gactimus <gactimus@xrs.net>
>> wrote (in <10sdnunotbnere2@corp.supernews.com>) about 'Is zero even
>> or odd?', on Mon, 20 Dec 2004:
>>> I know 0 is neither negative or positive but what about odd/even? I
>>> think it's even.
>>>
>>> Odd numbers start at 1 and go every other number
>>> 1,3,5,7;1,-1,-3,-5,-7 Even starts at 2 and go every other number
>>> 2,4,6,8;2,0,-2,-4,-6,-8
>>
>> There is other evidence. Even powers of negative numbers are
>> positive, and (-x)^0 = 1, which is usually positive. (;-)
>
> (-0)^2 = -0

No, it's just 9. You dont have +0 or -0, it's just 0 (zero.) Writing it
as +0 or -0 still is jsut 0 sicne 0 has no sign. You have +, -, and 0.
Or for what you get from any proper sign function, either 1, -1, or 0.




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

Date: Mon, 20 Dec 2004 17:44:11 -0800
From: "Alfred Z. Newmane" <a.newmane.remove@eastcoastcz.com>
Subject: Re: Is zero even or odd?
Message-Id: <32pdeuF3p8isbU1@individual.net>

Franz Heymann wrote:
> "David Kastrup" <dak@gnu.org> wrote in message
> news:x5d5x4nbx9.fsf@lola.goethe.zz...
>
> [snip]
>
>> (-0)^2 = -0
>
> Not on my Casio calculator.

Thats becuase, when translated to reality, that statement becomes (0)^2
= 0, because 0 has no sign. I really wish people would stop trying to
spread the false hood that0 actually has a sign.




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

Date: Mon, 20 Dec 2004 21:24:05 -0500
From: Jim Ward <tomcatpolka@NyOaShPoAoM.com>
Subject: Re: Is zero even or odd?
Message-Id: <o62fs0t3plvfsvjspr6q8frupcppg4b5rq@4ax.com>

On Mon, 20 Dec 2004 14:21:11 -0000, Gactimus <gactimus@xrs.net> wrote:

>I know 0 is neither negative or positive but what about odd/even? I think
>it's even.

0 has no flat edges, so it can't be even.


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

Date: 21 Dec 2004 02:36:55 GMT
From: richard@cogsci.ed.ac.uk (Richard Tobin)
Subject: Re: Is zero even or odd?
Message-Id: <cq8287$rrv$1@pc-news.cogsci.ed.ac.uk>

In article <32pd7rF3q16ikU1@individual.net>,
Alfred Z. Newmane <a.newmane.remove@eastcoastcz.com> wrote:

>You dont have +0 or -0, it's just 0 (zero.)

No, you *do* have +0 and -0, and they are both equal to 0.

-- Richard


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

Date: Tue, 21 Dec 2004 02:44:00 GMT
From: Ed Murphy <emurphy42@socal.rr.com>
Subject: Re: Is zero even or odd?
Message-Id: <pan.2004.12.21.02.47.17.90895@socal.rr.com>

On Mon, 20 Dec 2004 19:21:43 -0500, Shawn Corey wrote:

> Nicholas O. Lindan wrote:
>> 
>> 1 + 1 = 0/0 + 0/0 = (0 + 0)/0 = 2 * 0/0 = 2
>> 
>> 
>           a = b
>         a^2 = ab
>   a^2 - b^2 = ab - b^2
> (a+b)(a-b) = b(a-b)
>        a+b  = b
> but a = b
>         a+a = a
>          2a = a
>           2 = 1
> 
> What could be clearer?

I used to know a proof along these lines:

-----

      x = +1
A = [integral] f(x) dx
      x = -1

By examining a graph, it is obvious that A > 0.

Let y = 1/x, therefore x = 1/y, and substitute this into the equation:

      x = +1
A = [integral] f(1/y) f'(y) dy
      x = -1

The right-hand side is clearly equivalent to -A

A = -A

A = 0

-----

Unfortunately, I don't remember which f(x) causes this to work.  I'm
pretty sure it was a fairly simple trigonometric operation.



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

Date: Mon, 20 Dec 2004 18:47:18 -0800
From: "Alfred Z. Newmane" <a.newmane.remove@eastcoastcz.com>
Subject: Re: Is zero even or odd?
Message-Id: <32ph4vF3ppkimU1@individual.net>

Jim Ward wrote:
> On Mon, 20 Dec 2004 14:21:11 -0000, Gactimus <gactimus@xrs.net> wrote:
>
>> I know 0 is neither negative or positive but what about odd/even? I
>> think it's even.
>
> 0 has no flat edges, so it can't be even.

It does on my digital clock (as does my digital watch) :-P




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

Date: Mon, 20 Dec 2004 18:48:23 -0800
From: "Alfred Z. Newmane" <a.newmane.remove@eastcoastcz.com>
Subject: Re: Is zero even or odd?
Message-Id: <32ph70F3r17joU1@individual.net>

Richard Tobin wrote:
> In article <32pd7rF3q16ikU1@individual.net>,
> Alfred Z. Newmane <a.newmane.remove@eastcoastcz.com> wrote:
>
>> You dont have +0 or -0, it's just 0 (zero.)
>
> No, you *do* have +0 and -0, and they are both equal to 0.

Well I basically said that in the part you didn't quote :-)




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

Date: Tue, 21 Dec 2004 14:43:17 +1100
From: Clifford Heath <no@spam.please>
Subject: Re: Is zero even or odd?
Message-Id: <32pkemF3p3b5bU1@individual.net>

John Woodgate wrote:
>>>Lim{x->0}[(-x^)2] = 0
>>Either you mangled your parentheses, or this is a insidious way of 
>>sneaking in a smilie.
> Nothing is mangled if you view plain text.

Perhaps you could explain what (-x^)2 means then?


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

Date: Mon, 20 Dec 2004 18:21:12 -0700
From: Average Joe <sconnet@chokecoxspam.net>
Subject: odbc howto
Message-Id: <bUKxd.58222$DC.25101@fed1read03>

I am using a Sun Sparc Solaris 8 or Linux x86, doesn't matter. I want to 
be able to modify a database via perl. The only way to get to the 
database is via a Win32 DSN. I'm new to this so can I access the 
database directly? I do not know what DB server is running, just that it 
is ODBC compliant. Is there a perl ODBC module that allows me to connect 
to an ODBC compatible database via a Win32 DSN name from the Sun or Linux?

--
Average Joe


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

Date: Mon, 20 Dec 2004 22:02:47 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: odbc howto
Message-Id: <onMxd.8095$Z%3.383207@news20.bellglobal.com>


"Average Joe" <sconnet@chokecoxspam.net> wrote in message 
news:bUKxd.58222$DC.25101@fed1read03...
>I am using a Sun Sparc Solaris 8 or Linux x86, doesn't matter. I want to be 
>able to modify a database via perl. The only way to get to the database is 
>via a Win32 DSN. I'm new to this so can I access the database directly? I 
>do not know what DB server is running, just that it is ODBC compliant. Is 
>there a perl ODBC module that allows me to connect to an ODBC compatible 
>database via a Win32 DSN name from the Sun or Linux?
>

You're probably better off finding out exactly what type of database you're 
connecting to and using the appropriate DBD driver.

If you have to go the ODBC route, you'll still need to know what type of 
database it is so you can get the appropriate ODBC driver. You'll also need 
unixODBC or some other manager and the Perl DBI and DBD::ODBC modules.

Matt 




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

Date: Tue, 21 Dec 2004 02:34:28 GMT
From: "Billy" <bustanut2020@yahoo.com>
Subject: Re: Open file, print into file, what variable is used?
Message-Id: <UYLxd.535970$wV.272787@attbi_s54>


"Joe Smith" <joe@inwap.com> wrote in message
news:e6uxd.214515$5K2.173433@attbi_s03...
> Billy wrote:
> > Is this line put into a variable? If so what is it?
 >   while (<FILE>) {
> >     print SCRIPTLOG;
> >   }
>
> Sounds like you don't realize that those three lines
> and the following three lines are equivalent.
>
>    while (defined($_=<FILE>)) { # Read one line at at time into $_
>        print SCRIPTLOG $_; # $_ is default for many things
>    }
> -Joe

Joe,

Thank you... Civil answers and a push in the right direction is very well
appreciated. When your new around here and ask a beginner question some
people act as though you just kicked their dog (cat, favorite animal).

Thank you again,
Billy




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

Date: 21 Dec 2004 02:44:33 GMT
From: xhoster@gmail.com
Subject: Re: Parsing Large Files
Message-Id: <20041220214433.418$GI@newsreader.com>

BigDaDDY <ihatespam@hotmail.com> wrote:
> All,
>
> I recently received a reply to a previous post which is almost the answer
> I needed.  The problem is, when I tried it at work, it wouldn't work.
> The reason it didn't work was because we have an early version of Perl at
> work which does not support "values" as in:

Thats highly unlikely.

>
> my(%nid, %id);
>
> foreach (values %id) {
>   foreach my $y (keys %$_) {
>      foreach (values %{$_->{$y}}) {
>         die "duplicate $_!" if exists $nid{$_};
>         $nid{$_}=$y;
>      }
>   }
> }

You could use "keys" insteads of "values", but of course then you would
have to change the corresponding accesses:

foreach my $x (keys %id) {
  foreach my $y ( keys %{$id{$x}}) {
etc.

But since values *does* work, figure out what makes you think it doesn't.
Maybe my code has an error I overlooked.

>
> Can this be done in a different way that doesn't use values?  Also, I do
> care about the x-values as well, so I don't think the code above will
> work as is.  Basically, I'm parsing one file to get an ID given an x,y,z
> cartesian coordinate.  This gives me the hash %id which is keyed by
> {"x"}{"y"}{"z"} coordinates, whose values are id numbers.

Rather than massaging %id after the fact, just change the way you parse the
first file so that you get the proper data structure right from the start.
Since you want to search the second (big) file by ID, ID should be the
hash key.  Since you want to have the Y and X (And possibly Z), store
both the Y and X (and Z).  I'd probably just store them as ordered
3-element arrays nested in the hash (slot 0 is X, slot 1 is Y, slot 2 is
Z), but I think most would prefer to use hashes with labels, rather than
ordered arrays, so that is what I'll show:

my %hash;
while (<$file1>) {
  chomp;
  my ($id,$x,$y,$z) =split; # or whatever it takes to parse
  die "Duplicate $id" if exists $hash{$id};
  $hash{$id} = {X=>$x, Y=>$y, Z=>$z};
};

> Then I close
> this file, and open a large results file which only contains ids with
> results.  I want to pull out all values for a unique y into a separate
> file

Probably not a separate file yet.  It is easier to sort in memory than
to sort files from perl. (Assuming, like before, that all the *relevant*
data from the big file can fit in memory)

%y_stuff; # hash by Y of hash by X of list of data

while (<$file2>) {
  chomp;
  my ($id,$data)=split; #or whatever it takes to parse
  next unless $hash{$id}; #don't store lines we don't care about

  # just to make thing clearer, I'll use intermediate variables
  # Otherwise there are just too darn many braces in the push...
  my $x = $hash{$id}{X};
  my $y = $hash{$id}{Y};

  push @{$y_stuff{$y}{$x}}, $data;
};

foreach my $y (keys %y_stuff) {
  ## open your file for this Y
  foreach my $x ( sort {$a<=>$b} keys %{$y_stuff{$y}} ) {
     ## format and print your data
     ###  (it is still not clear how you want the data sorted
     ###   within each X-Y group.  I'll assume it is order it was
     ###   first seen)
     print "@{$y_stuff{$y}{$x}}\n";
  };
  ## close your file
};


Xho

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


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

Date: Mon, 20 Dec 2004 16:57:13 -0700
From: Eric Schwartz <emschwar@fc.hp.com>
Subject: Why does this work?
Message-Id: <etowtvcwmjq.fsf@wilson.emschwar>

Why does this pass a perl -c?  Shouldn't the call to catch() fail on
an unquoted bareword?  It's kinda cool in that it lets me do things
like that, but I'm a bit nervous that it might magically go away some
day.

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

sub catch
{
  return 1;
}

catch( -force, "this shouldn't work, should it?");

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: 21 Dec 2004 01:43:15 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Why does this work?
Message-Id: <Xns95C5D2C95CC5Fasu1cornelledu@132.236.56.8>

Eric Schwartz <emschwar@fc.hp.com> wrote in 
news:etowtvcwmjq.fsf@wilson.emschwar:

> Why does this pass a perl -c?  Shouldn't the call to catch() fail on
> an unquoted bareword?  It's kinda cool in that it lets me do things
> like that, but I'm a bit nervous that it might magically go away some
> day.
> 
> #!/usr/bin/perl
> use warnings;
> use strict;
> 
> sub catch
> {
>   return 1;
> }
> 
> catch( -force, "this shouldn't work, should it?");

Does this help?

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

use Data::Dumper;

my @array = -force;
print Dumper \@array;

my %hash = ( -force, 1 );
print Dumper \%hash;
__END__


C:\Dload> t4.pl
$VAR1 = [
          '-force'
        ];
$VAR1 = {
          '-force' => 1
        };

I have been pulling my hair out trying to remember where this behavior is 
described, but I remember seeing a note somewhere regarding the 
autoquoting of words that start with a dash.

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



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

Date: Tue, 21 Dec 2004 02:54:51 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Why does this work?
Message-Id: <32pe2oF3p24tsU1@individual.net>

Eric Schwartz wrote:
> Why does this pass a perl -c?  Shouldn't the call to catch() fail on
> an unquoted bareword?  It's kinda cool in that it lets me do things
> like that, but I'm a bit nervous that it might magically go away some
> day.
> 
> #!/usr/bin/perl
> use warnings;
> use strict;
> 
> sub catch
> {
>   return 1;
> }
> 
> catch( -force, "this shouldn't work, should it?");

 From "perldoc perlop":

"Unary ``-'' performs arithmetic negation if the operand is numeric. If 
the operand is an identifier, a string consisting of a minus sign 
concatenated with the identifier is returned. Otherwise, if the string 
starts with a plus or minus, a string starting with the opposite sign is 
returned. One effect of these rules is that -bareword is equivalent to 
"-bareword"."

-- 
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.  

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


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