[8619] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2236 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 2 18:07:21 1998

Date: Thu, 2 Apr 98 15:00:32 -0800
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, 2 Apr 1998     Volume: 8 Number: 2236

Today's topics:
        CGI-BIN: Link to other directories within a password se <ralphmoch@swol.de>
        Clarification wanted on FileHandle syntax <kapur@cbl.ncsu.edu>
    Re: current week (Jason Gloudon)
    Re: eval with text files (Craig Berry)
        How do I strip newlines from a var (Bryan Sapot)
    Re: How do I strip newlines from a var (Abigail)
    Re: How should I send a signal 'INT' to a remote server (Jonathan Stowe)
    Re: How to answer "is $this in @that"? (John Erjavec V)
    Re: how to count a list of comma sep. items (Greg Bacon)
    Re: how to count a list of comma sep. items (Greg Bacon)
    Re: how to count a list of comma sep. items (Abigail)
    Re: How to tell if a script was executed directly <brobbins@tis.com>
    Re: How to tell if a script was executed directly (Andrew M. Langmead)
        How to timeout TCP connect? <jc@ral1.zko.dec.com>
    Re: Is there a "Newsgroup" for Newbies to Perl? (Chris Vogel)
        Looking for ANY Suggestions on parsing this line!! randy.paries@avex.com
    Re: Looking for ANY Suggestions on parsing this line!! (Craig Berry)
    Re: Multidimensional Arrays <dboorstein@shopcfn.com>
    Re: Multidimensional Arrays (Jonathan Stowe)
        need help with regexp alternation problem <becca@emrtc.nmt.edu>
    Re: Odd or even function <ajh@rtk.com>
        OLE Methods from a Perl Object gleman@mindspring.com
    Re: Perl and MySQL (Jonathan Stowe)
    Re: Perl applications (Greg Bacon)
    Re: perl Socket module (Greg Bacon)
    Re: Record size of DBM Hashes (M.J.T. Guy)
    Re: Refcounts when XSUB creates PERL objects. (Gurusamy Sarathy)
    Re: Someone put my munged e-mail address on a spam list (Andy Lester)
        Standard units of mesaure (Was: Furlongs, fortnights, a (Paul E. Black)
    Re: Tying a blessed hash (was: Re: Tie/bless vs. bless/ (Todd Lehman)
    Re: unpack vs. substr (was Re: Data Structure for Input (Jason Gloudon)
    Re: unpack vs. substr and SWIG/XS help <Clinton.Bodine@mci.com>
    Re: upload a file to ftp site (Greg Bacon)
    Re: Win32::Internet Problem (Jonathan Stowe)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 02 Apr 1998 21:50:54 +0200
From: Ralph Moch <ralphmoch@swol.de>
Subject: CGI-BIN: Link to other directories within a password secured area
Message-Id: <3523EC1E.5B0A7423@swol.de>

I4ve placed a password CGI-script on a web server, it already runs.
Now my question, if I reach the password protected area by transmitting
password and username I get a new HTML page. Within this page I want zo
place some links which only the user, in this case it4s me, can
connected to. If I click on a link, the server sends me the message: You
have no permission to enter this site.
I think I have to create a file which has got the user datas, how can I
do that?

Thx

e-mail: ralphmoch@swol.de
HP: http://privat.swol.de/RalphMoch



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

Date: 02 Apr 1998 15:38:31 -0500
From: Nevin Kapur <kapur@cbl.ncsu.edu>
Subject: Clarification wanted on FileHandle syntax
Message-Id: <tyhg4cez7c.fsf@cbl.ncsu.edu>

I am a bit confused about the syntax described in the FileHandle
manpage. Consider the following (taken from said manpage):

aries[~]$ perl -we '
>          use FileHandle;
>  
>          $fh = new FileHandle;
>          if ($fh->open "< file") {
>              print <$fh>;
>              $fh->close;
>          }
> '
String found where operator expected at -e line 5, near "->open "< file""
        (Missing operator before "< file"?)
syntax error at -e line 5, near "->open "< file""
syntax error at -e line 8, near "}"
Execution of -e aborted due to compilation errors.

Enclosing "< file" in parens gets rid of these errors. Am I missing
something obvious?
-Nevin


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

Date: Thu, 02 Apr 1998 20:08:24 GMT
From: jgloudon@manitoba.bbn.com (Jason Gloudon)
Subject: Re: current week
Message-Id: <slrn6i7rsq.4dn.jgloudon@manitoba.bbn.com>

Jarkko Hietaniemi <jhi@alpha.hut.fi> wrote:
>
>> FRANCOIS> method I can use to calculate the current
>> FRANCOIS> weeknumber (1 - 52) ?  Can I use the localtime
>
>Nitpick: 1-5.

He meant which week of the year. 52 weeks in a year.

-- 
Jason Gloudon


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

Date: 2 Apr 1998 20:21:41 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: eval with text files
Message-Id: <6g0s0l$cgn$1@marina.cinenet.net>

Andre L. (alecler@cam.org) wrote:
: In article <wb7opEAIZ8I1EwKx@iotp.demon.co.uk>, Soccerweb
: <soccerweb@iotp.demon.co.uk> wrote:
: 
: > Hello, I'm writing a Perl CGI script that enables the webmaster to
: > automatically send various e-mails for administration purposes. All the
: > e-mail content are stored as text files, however the e-mail content
: > states thing like "as researcher for $country" or "Hello $name,". I want
: > to be able to convert the variables in the text file and then attach the
: > headers etc. to the e-mail and post. But, I can't manage to change
: > $country to Spain when $country eq "Spain". So the posted e-mail's still
: > state "as researcher for $country", I've tried eval but it doesn't work,
: > any suggestions?
: 
: Use these on the file's text:
: 
: s/\$country/$country/ge;
: s/\$name/$name/ge;
: 
: Those will evaluate $country and $name to their current values.

No need for the e qualifier on those.

As a generic version, you can do

  s/(\$[A-Za-z]\w*)/$1/gee;

to convert everything that looks like a scalar and starts with a letter into 
that scalar's value.  The 'starts with a letter' constraint allows dollar 
values (e.g., $4.95) to pass through unmodified.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 2 Apr 1998 22:01:19 GMT
From: bsapot@office1.gundaker.com (Bryan Sapot)
Subject: How do I strip newlines from a var
Message-Id: <6g11rf$pmf$1@newsin-1.starnet.net>

how can i strip new lines out at var.

SCO Openserver 5.0 (sorry)
perl 5.004

please email response to bsapot@gundaker.com


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

Date: 2 Apr 1998 22:38:42 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: How do I strip newlines from a var
Message-Id: <6g141i$9cs$1@client3.news.psi.net>

Bryan Sapot (bsapot@office1.gundaker.com) wrote on MDCLXXV September
MCMXCIII in <URL: news:6g11rf$pmf$1@newsin-1.starnet.net>:
++ how can i strip new lines out at var.
++ 

Removing new lines is very tricky, as the manual tells you so.
Ignore the complicated things in the manual, and put in this
neat little trick:

$var=join+q,,,grep{ord${qq$\137$}<10 or+10<ord}split+q,,,$var;

If you're old enough not to read the manual, you won't have a
problem understanding the above line.


Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle 'print +(HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET", "http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content)) =~ /(.*\))[-\s]+Additional/s) [0]'


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

Date: Thu, 02 Apr 1998 16:28:06 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: How should I send a signal 'INT' to a remote server?
Message-Id: <3523ba39.15862504@news.btinternet.com>

On Wed, 01 Apr 1998 11:08:58 +0800, James Yang <James_Yang@via.com.tw>
wrote:

>Hi,
>
>    If I execute a Perl script on server severA and then it do the this
>            exec("rsh $host 'cd $pwd;$prog @ARGV'");
>How should I to send a interrupt signal to this process?
>May I specify the server name in function 'kill'?
>

Er, no.  Signals operate from within the kernel of the system.  Your
best hope is to communicate with your process via a socket connection.
Examples abound in the documentation.

Alternatively you could always rsh a 'kill' command ;-}

/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm


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

Date: 2 Apr 1998 20:49:00 GMT
From: jev@pconline.com (John Erjavec V)
Subject: Re: How to answer "is $this in @that"?
Message-Id: <6g0tjs$5ke$1@bell.pconline.com>

Michael Kairys (kairys@mi.sl.com) wrote:
: There must be a simple way, but I haven't found it, to find out if a given
: scalar is in a list. Of course I can write myself a function like:
Michael-

This is also a FAQ, and is in there under searching arrays.  To start you
off, create a hash from the list, and search the hash.  For a more complete
response, look in the FAQ.

-JEV
-- 
John Erjavec V	PGP fingerprint:
jev@pconline.com	7593 1B5A AE11 C0FE BA09  EB5E 8DE9 D2E5 BF5B 87AD
http://www.pconline.com/~jev/index.html


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

Date: 2 Apr 1998 21:56:29 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: how to count a list of comma sep. items
Message-Id: <6g11id$l7u$9@info.uah.edu>

In article <slrn6i7n7j.4dn.jgloudon@manitoba.bbn.com>,
	jgloudon@manitoba.bbn.com (Jason Gloudon) writes:
: I'm not sure what you were trying to show, but you chose a bad example
: regardless.

Doh!  I promise never again to post under the influence of crack. :-(

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: 2 Apr 1998 21:59:55 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: how to count a list of comma sep. items
Message-Id: <6g11or$l7u$10@info.uah.edu>

In article <3523DFA4.5FD51036@gpu.srv.ualberta.ca>,
	Andrew Johnson <ajohnson@gpu.srv.ualberta.ca> writes:
: print "I have ", scalar (2, 4, 6), " things.\n";

Ouch.  In looking back at my original post (again :-( ), I see that I
meant ``keys in a scalar context'', but the transmission got garbled
on the way to my fingers. :-(

Anyone know of any cool checksum software I can install in the ol'
/dev/fingers?

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: 2 Apr 1998 22:39:47 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: how to count a list of comma sep. items
Message-Id: <6g143j$9cs$2@client3.news.psi.net>

Greg Bacon (gbacon@cs.uah.edu) wrote on MDCLXXV September MCMXCIII in
<URL: news:6g11or$l7u$10@info.uah.edu>:
++ 
++ Anyone know of any cool checksum software I can install in the ol'
++ /dev/fingers?


/usr/bin/axe


Abigail
-- 
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'


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

Date: Thu, 02 Apr 1998 13:22:22 -0500
From: Bert Robbins <brobbins@tis.com>
To: Andrew Brown <atbrown@halcyon.com>
Subject: Re: How to tell if a script was executed directly
Message-Id: <3523D75E.660A@tis.com>

Andrew Brown wrote:
> 
> I have a Perl script which is intended to either be executed directly
> (perl myscript.pl), or invoked indirectly from another Perl script, via a
> "do" statement (do "myscript.pl";).
> 
> My question is this:  is there any way for "myscript.pl" to detect whether
> it has been executed directly or via a "do"?  I could check $0 and compare
> it to the name of the script, but I don't wish to hardcode the script
> name...

Sure, go and take a look at the PPID, parent process id, and parent
process.

Thanks
Bert


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

Date: Thu, 2 Apr 1998 22:48:56 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: How to tell if a script was executed directly
Message-Id: <Eqt61L.GC1@world.std.com>

atbrown@halcyon.com (Andrew Brown) writes:

>My question is this:  is there any way for "myscript.pl" to detect whether
>it has been executed directly or via a "do"?  

You could use caller() inside myscript.pl (but outside of any
subroutines of myscript.pl of course)

When your script is run directly, caller() will return undef, called
from another script, it caller() will return the package of the the
code that called it.

The section for caller() in the perlfunc man page only mentions
subroutines, eval() or require() as things that "call" other code, but
the "do" section describes it being equivalent to eval, so I guess you
can count it, too.
-- 
Andrew Langmead


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

Date: Thu, 02 Apr 1998 17:23:56 -0500
From: John Chambers <jc@ral1.zko.dec.com>
Subject: How to timeout TCP connect?
Message-Id: <35240FFB.D1C6CB0F@ral1.zko.dec.com>

My little web explorer has had a problem for which maybe some expert here
can suggest a solution (or a FAQ or RTFM would be fine).  Everything works
except that a fair number of sites cause a very long (sometimes hours) hang
in the connect() call.  I've tried every sort of timeout mechanism, including
the ALRM signal, and nothing has worked.  Setting up an ALRM handler
itself works; when the alarm goes off, the handler wakes up, tells me
it was called, attempts to close the socket - and it hangs, never to return
until TCP decides much, much later to give up.

I've been wondering if I'd have to go to a multi-programming version,
in which the connects are done in subprocesses, one per URL, but that
seems like an awfully big sledgehammer (with huge cpu costs) to swat
such a silly little fly.

This is mostly on a linux machine, but I've also tried in on a couple of
others (SunOS, OSF1, and even an old ULTRIX machine), and all of
them seem to have the same problem.

Any ideas?  Is there a simple and elegant way to say "If that connection
doesn't succeed in $N seconds, give up"?

--
Q: How does Bill Gates change a light bulb?
A: He doesn't; he declares darkness the new industry standard,
    and users everywhere stop turning on their lights.


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

Date: Thu, 02 Apr 1998 11:12:00 +0100
From: C.VOGEL@LINK-GOE.de (Chris Vogel)
Subject: Re: Is there a "Newsgroup" for Newbies to Perl?
Message-Id: <6r4eQzGntSB@-sweet.link-goe.de>

                                           Goettingen, Stardate 0942.29
Hi there,

It's getting offtopic - any ideas where to put the discussion?

  genepool (Jim Michael) wrote in genepoolEqpsKs.H8D@netcom.com on
  02.04.98 following lines, starting with '*'

* virtual professors

I do not think that a learn group needs a professor. A moderator from
within the group should do. I didn't claim to offer perl courses on
the net. My idea was just to give the people some place to exchange
experiences while learning.

clpm might be a kind of professor to the learn groups. There will be
less questions than now for the same amount of people and the
questions will be more fun to answer because people will not ask
questions for which a single user might have easily overlooked the
answer.

Chris.


--
                           Gebt dem Moment eine Chance!



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

Date: Thu, 02 Apr 1998 15:03:11 -0600
From: randy.paries@avex.com
Subject: Looking for ANY Suggestions on parsing this line!!
Message-Id: <6g0u85$jbe$1@nnrp1.dejanews.com>

Hello,
I have this problem that is drivn me nuts. I am not sure if anyone can help
me, but here it is fur yu gurus.

i have this file, that has been exported that is suppose to be csv(comma
delimited.) below is an example of the lines of output. What I need to do is
parse the line into words.
I have tried spilt and TEXT::ParseWord. The comma in the unqouted values hoses
the split and the parse.

the problem is that the program that does the export(that I do not have
control over) does not put quotes around word 2 and word 8. Even though it is
suppose to be a csv, they put comma's in the values if over 1000. ARG!@!

does anyone have any ideas of how to parse this line into words. The values of
course will be of the same type but different values.

"MGORDON",$1,860.65,"STAR","$539.35","$1,139.35","$1,739.35",0,$1,860.65
"LE GRAVES",$1,822.43,"STAR","$577.57","$1,177.57","$1,777.57",0,$822.43

THANKS!!! if anyone can help me.

randy P

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 2 Apr 1998 21:21:58 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Looking for ANY Suggestions on parsing this line!!
Message-Id: <6g0vhm$cgn$2@marina.cinenet.net>

randy.paries@avex.com wrote:
: i have this file, that has been exported that is suppose to be csv(comma
: delimited.) below is an example of the lines of output. What I need to do is
: parse the line into words.
: I have tried spilt and TEXT::ParseWord. The comma in the unqouted values hoses
: the split and the parse.
: 
: the problem is that the program that does the export(that I do not have
: control over) does not put quotes around word 2 and word 8. Even though it is
: suppose to be a csv, they put comma's in the values if over 1000. ARG!@!
: 
: does anyone have any ideas of how to parse this line into words. The values of
: course will be of the same type but different values.
: 
: "MGORDON",$1,860.65,"STAR","$539.35","$1,139.35","$1,739.35",0,$1,860.65
: "LE GRAVES",$1,822.43,"STAR","$577.57","$1,177.57","$1,777.57",0,$822.43

Well, this is a bit risky, but for the data above it would work fine.  
Exactly what to do depends on whether or not you want to preserve the 
comma in the split fields -- that is, leave (for example) '$1,860.65' 
in the first line as that, or change it to '1860.65'.  Assume the current 
line is in $_; here is how to keep the commas:

  s/(\d),(\d{3})/$1\cA$2/g;        # Turn thousands commas into ctrl-As...
  @fields = split /,/;             # ...split on remaining commas...
  foreach (@fields) { s/\cA/,/g; } # ...then turn them back to commas.

If you're willing to irreversibly ditch the thousands commas, then you 
can use this simpler version:

  s/(\d),(\d{3})/$1$2/g;
  @fields = split /,/;

Be careful, though...this method will fail if a digit is immediately 
followed by a comma then three more digits in a context where it's *not* 
intended as a number.  If your data contains such cases, you have a 
tougher task ahead.

HTH!

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Thu, 02 Apr 1998 15:18:34 -0500
From: Dan Boorstein <dboorstein@shopcfn.com>
Subject: Re: Multidimensional Arrays
Message-Id: <3523F29A.D923EDBE@shopcfn.com>

Jason Gloudon wrote:
> 
> Konstantin Kalaitzidis <kkalaitz@cisco.com> wrote:
> >Hello,
> >How can I create a multidimensional array?
> >I wrote the very short script shown below, but I get errors:
> >
> >"multidim.pl" [Read only] 5 lines, 148 characters
> >     1  #!/usr/bin/perl
> >     2  $multidim = [['1.1', '1.2', '1.3] , ['2.1', '2.2','2.3']];
>                                          ^ you are missing a '
> 
> You can avoid using quotes by using the qq quoting mechanism.
> 
> $multidim = [ [ qw(1.1 1.2 1.3) ]
>               [ qw(2.1 2.2 2.3) ]
>             ];
> 

of course you still need to incude commas. ;)

and, if the original poster is only working with numerical data,
quoting can be tossed out completely

$multidim = [ [ 1.1, 1.2, 1.3 ],
              [ 2.1, 2.2, 2.3 ]
            ];

-- 
# dan boorstein <dboorstein@shopcfn.com>
seek DATA,0,0;print scalar<DATA>,__END__
Just another Perl hacker,


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

Date: Thu, 02 Apr 1998 16:27:29 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Multidimensional Arrays
Message-Id: <3523a646.10959020@news.btinternet.com>

On Thu, 02 Apr 1998 08:35:04 -0800, Konstantin Kalaitzidis
<kkalaitz@cisco.com> wrote:

>Hello,
>How can I create a multidimensional array?
>I wrote the very short script shown below, but I get errors:
>
>"multidim.pl" [Read only] 5 lines, 148 characters
>     1  #!/usr/bin/perl
>     2  $multidim = [['1.1', '1.2', '1.3] , ['2.1', '2.2','2.3']];
>     3  print  "$multidim->[0][2]\n";
>     4  print  "$multidim->[1][1]\n";
>~
>
>When I run the above script, I get:
>parse error in file ./multidim.pl at line 2, next 2 tokens "= ["
>EOF in string at ./multidim.pl line 2.
>
You're missing a quote after the 1.3 

/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm


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

Date: Thu, 02 Apr 1998 15:21:52 -0700
From: Rebecca Ideus <becca@emrtc.nmt.edu>
Subject: need help with regexp alternation problem
Message-Id: <35240F80.D62348E8@emrtc.nmt.edu>

I  have written a script which is supposed to build a regular expression
to match a series of dates.  For instance if I want to match 3/5/98 -
3/27/98,  it builds the following:

/Mar\s{1,2}([5-9]|[1][0-9]|[2][0-7]).{12}98/

It searches through something similar to the unix 'date' ouput; the
\s{1,2} and .{12} is just skipping over stuff.
The above regular expression works great; it matches exactly as it
should.
However, when I want to match 1/5/98 - 3/27/98, it builds:

/(Jan\s{1,2}([5-9]|[1-2][0-9]|[3][0-1]).{12}98|
(Feb)\s{1,2}([1-9]|[1-2][0-9]|[3][0-1]).{12}98|
Mar\s{1,2}([1-9]|[1][0-9]|[2][0-7]).{12}98)/

and it doesn't match anything.  The 3rd line in the above regexp is
almost identical to the first regexp above.  I've tried all combination
of parentheses around everything and it still does not match.  It's as
if putting the | is screwing it up.  Is something wrong, or do I just
not understand alternation right?  Please help.



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

Date: Thu, 2 Apr 1998 14:23:14 -0800
From: "Aaron Harsh" <ajh@rtk.com>
Subject: Re: Odd or even function
Message-Id: <6g135d$pk8$1@brokaw.wa.com>

Tom Christiansen wrote in message <6fqm8t$hm2$1@csnews.cs.colorado.edu>...
>In comp.lang.perl.misc, "Dan Serban" <judas@interprice.com> writes:
>:Is there an odd or even perl function that could be used as a boolean
>:operator?
 ...
>    If you enjoy math puzzles, you will enjoy programming.
>    If you do not enjoy math puzzles, you will not enjoy programming.
>    If you enjoy something, it will seem like fun, not work.
>    If you do not enjoy something, you will never be any good at it.
>    If you are not going to be good at something, find someone who is.

Am I misinterpreting this, or are you actually trying to convince someone
_not_ to program in Perl (or anything else, for that matter)?  Or are you
merely pointing out that they'll never be any good at it?

You don't mention this at your training sessions, do you? :-)

Maybe someone could add a section to the FAQ to discourage graphic
designers, power users, Information Systems types, or anyone else that's
only interested in solutions, from learning Perl :-)

--
Aaron Harsh
ajh@rtk.com





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

Date: Thu, 02 Apr 1998 15:46:13 -0600
From: gleman@mindspring.com
Subject: OLE Methods from a Perl Object
Message-Id: <6g10v5$mtr$1@nnrp1.dejanews.com>

I need a means of finding out what methods/properties are available from an
object created by OLE CreateObject.  I can only find sporadic documentation on
my vendor's OLE implementation.

The following code works fine:

# Create an OLE Object with the Microstation session
my $ustation = CreateObject OLE "Microstation.application";

# Send a command to fit view
$ustation->MbeSendCommand("FIT VIEW EXTENDED 1");

The problem is that I was only able to use the MbeSendCommand method because I
guessed what is was from knowledge of other interfaces to the product.

Does anyone know how to enumerate the methods/properties that are available in
an object created by OLE CreateObject?

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Thu, 02 Apr 1998 16:27:41 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Perl and MySQL
Message-Id: <3523a886.11534854@news.btinternet.com>

On Thu, 02 Apr 1998 00:43:27 -0500, Alexander Dukat <dukat.2@osu.edu>
wrote:

>I have gotten the following error and am wondering if anyone can explain
>in general what it means, or if someone knows how to resolve it that
>would also be great.  If not if I could be pointed in the right
>direction.  Thanks
>
>Can't load '/usr/lib/perl5/site_perl/i586-linux/auto/DBD/mysql/mysql.so'
>for module DBD::mysql: File not found at
>/usr/lib/perl5/i586-linux/5.00404/DynaLoader.pm line 166.
>

It appears that your installation of DBD::MySQL is broken.  The module
is using a dynamic extension (the mysql.so file) which is not where it
is expected to be.  I would suggest 2 remedies in order of preference:

1)  Re-install the module completely in the usual manner ( if you no
longer have the distribution files you will to download it from CPAN )
This will recompile the module and place everything where it *should*
be.

2) Find the missing file with the command " find /usr/lib -name
mysql.so -print" .  Then you can copy the file from the location
reported to where it is supposed to be (see the error message).  Of
course it may have been removed completely then you will have to
resort to method one.  There is no guarantee that other things havent
been removed either.

Good luck....

/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm


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

Date: 2 Apr 1998 22:04:43 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Perl applications
Message-Id: <6g121r$l7u$11@info.uah.edu>

In article <3523D5C6.2DF12F44@bellatlantic.net>,
	"Jayant V. Gokhale" <jayantg@bellatlantic.net> writes:
: I would appriciate if you could provide me information on reasanobly
: sized customer using PERL based commercial software.

Perl does not discriminate on the basis of age, height, weight, creed,
color, or national origin. :-)

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: 2 Apr 1998 22:06:27 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: perl Socket module
Message-Id: <6g1253$l7u$12@info.uah.edu>

In article <tciEqs91u.7vI@netcom.com>,
	tci@netcom.com (John Tolson) writes:
: I am trying to run a spam filter from my shell account, the filter is
: a perl script.  It uses Socket to mail out.  I get an error on the:

Why?  Don't reinvent the wheel.  Open a pipe to sendmail and let it do
the unfun work for you.

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: 2 Apr 1998 20:20:32 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Record size of DBM Hashes
Message-Id: <6g0rug$pjd$1@lyra.csx.cam.ac.uk>

In article <3521E4FE.7A06698A@madison.tds.net>,
Chaviv & Shaily  <csperl@madison.tds.net> wrote:
>I am using a DBM Hash. Seems like when the key and data size of a single
>entry is larger than 1024 Bytes - I get an error when trying to close
>the DB files with dbmclose.
>    How can I enlarge the block size to accept larger records. Is there
>another DBM library that solve this problem?
>
>    Thanks,
>    Haviv.
>

The AnyDBM_File manpage (perldoc AnyDBM_File) compares and contrasts
the alternatives.    Berkeley DB is undoubtedly the best choice, but
you have to install it separately, and before you install Perl.


Mike Guy


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

Date: 2 Apr 1998 22:51:15 GMT
From: gsar@engin.umich.edu (Gurusamy Sarathy)
Subject: Re: Refcounts when XSUB creates PERL objects.
Message-Id: <6g14p3$38j@srvr1.engin.umich.edu>

  [ mailed and posted ]

In article <6ftle3$7n91@eccws1.dearborn.ford.com>,
Ken Fox <kfox@pt0204.pto.ford.com> wrote:
>> So I made a "sv_2mortal" call on everything.
>
>You should only mortalize things going on the stack.

You make excellent points.

The above advice is more in the nature of a thumbrule though.
There _are_ situations where you may want to mortalize
things even when you're not going anywhere near the stack with
them.  One example is when you are using a temporary SV that
must be cleaned up, but the code you may call will C<die>
and result in a non-local exit out of your code (before you
have a chance to clean up the temporary yourself).  In such
a case, mortalization is an elegant way to clean up temporaries.

Another general rule is to never mortalize anything that you
did not create yourself, or did not stake a claim to (by
incrementing its refcount).

 - Sarathy.
   gsar@umich.edu



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

Date: 2 Apr 1998 20:36:08 GMT
From: petdance@maxx.mc.net (Andy Lester)
Subject: Re: Someone put my munged e-mail address on a spam list
Message-Id: <6g0sro$366$1@usenet76.supernews.com>

Bart Lateur (bart.mediamind@tornado.be) wrote:
: John Stanley wrote:

: >I have yet to have a munged address waste any of my bandwidth.

: YOUR bandwidth?

: I've heard estimates that over half of Internet's total bandwidth is
: wasted on transferring spam emails. Which is EVERBODY's bandwidth.

: BTW this has nothing to do with arguments pro or con address munging.
: It's just to show that just not receiving spam isn't the solution. The
: spam getting sent is the real problem.

: 	Bart.

--
--
Andy Lester:        <andy@petdance.com>       http://tezcat.com/~andy/
Chicago Shows List: <shows@ChicagoMusic.com>  http://ChicagoMusic.com/



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

Date: 02 Apr 1998 12:46:15 -0700
From: black@luwak.cs.byu.edu (Paul E. Black)
Subject: Standard units of mesaure (Was: Furlongs, fortnights, acres, chains, etc.)
Message-Id: <u9k998hurc.fsf_-_@luwak.cs.byu.edu>

dpbsmith@world.std.com (Daniel P. B. Smith) writes:
> Daniel P. B. Smith wrote:
> > It was recently pointed out to me that "one furlong per fortnight"
> > is almost exactly 1 centimeter per minute.  How's that for useful?
> 
> A furlong is ...  A yard is ...  a meter is ...

NIST has a nice page on constants, units, and uncertainty at
	http://physics.nist.gov/cuu/
It deals with SI (metric) units, so doesn't give the length of a
furlong, yard, or chain, but may be of interest in any case.

-paul-
-- 
Paul E. Black (p.black@acm.org)      NIST North, Room 517
paul.black@nist.gov                  Gaithersburg, Maryland  20899
voice: +1 301 975-4794               fax: +1 301 926-3696
Web: http://hissa.ncsl.nist.gov/~black/black.html           KC7PKT


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

Date: Thu, 02 Apr 1998 20:19:02 GMT
From: lehman@javanet.com (Todd Lehman)
Subject: Re: Tying a blessed hash (was: Re: Tie/bless vs. bless/tie and segmentation fault)
Message-Id: <WoSU.99$T51.325104@ptah.visi.com>

John Porter wrote:
>
> Todd Lehman wrote:
> > 
> > package Foo;
> > 
> > sub new
> > {
> >    my $class = shift;
> >    my $self = {};
> >    tie %$self, $class, @_;
> >    return bless $self, $class;
> > }
>
> Mind if I chip in and clarify a bit for you?

Hey, be my guest.  Thanks for the suggestions and reminders.  Unfortunately,
I need something a little fancier than the standard tie methodologies
because I don't want to put unnecessary burdens on clients of the package.
(I'm the one writing all the client code.  :-)


> When you tie a hash to a class, the tie blesses an
> object of that class.

True, but it is a different object within that package/class.  Notice that
the object that tie returns is the object created by TIEHASH(), which is
quite different from $self, unless $self is passed as an argument to tie
and used inside TIEHASH(), which I haven't done.

It's almost a dilemma; what TIEHASH() creates is an untied hash, but what
new() creates is a tied hash.  I actually need both.  Twisted, huh?  :-)


> Your blessing, above, is redundant.

Hmm.  If I left off the bless, then new() would return the object that
TIEHASH() created, which has no tie properties and would defeat the whole
purpose of the tie in the first place.  I'm doing the tie inside the
constructor so the client doesn't have to do it.  It's extremely important
to me that the clients of this package not be asked to do the tie.


> Try just returning $self from new() and
> see what happens.  Should be the same.

Without the tie?  Wouldn't that force the tie to happen somewhere outside of
a package constructor (undesirable)?


> It should be remembered that tie returns the newly
> blessed object, so, without using new(), you could
> simply do this:
>
> my %DB;
> my $DB_obj = tie %DB, 'Foo';
>
> # use %DB for hash ops:
> $DB{Person}{1}{FirstName} = 'John';
>
> # use $DB_obj to access other methods you may have defined,
> # besides the hash ones (FETCH, etc.):
> print $DB_obj->full_name;

Your code looks correct, but it violates my design criteria #4 and #5
below.  Of course, I omitted the criteria in earlier postings, so it's
not your fault.  :-)

Here are my criteria for this module:

1.  One package/class.  I figured out how to do it in one, so I know it's
    possible, so it's a firm requirement.  It makes subclassing so much
    easier when it's one class instead of two, and it doesn't run any
    slower except in DESTROY(), where it has to check whether it's the
    tied object or the main object.

2.  One object per node, if possible; otherwise two is acceptable.  I know
    how to do it in two objects (one package/class) per node, but I'm
    skeptical about it being possible in one object per node without some
    really gunky infinite-recursion avoidance in FETCH, and even then FETCH
    would be called twice for every fetch.  But I'd love to be proven wrong.

3.  Objects in this package/class must have an untied store of "private"
    data as well as a tied store of "public" data.

4.  Clients of the package must not be asked to do the tie; the tie must
    happen transparently inside the package.

5.  Entities (object pairs) created by this package must look and act like
    regular objects to clients, but the data inside the hash must be tied
    for magical behavior.  It's OK if the object used for member function
    calls is different from the object used for hash access as long as they
    appear to be the same object to the client in "normal" use.  That is,
    it's OK if

        $DB->{foo}

    is a different object from

        tied %{$DB->{foo}}

    as long as they're different objects in the same class and the client
    can't tell the difference without comparing the refs.


> Since you didn't define any extra methods in Foo,

Not explicitly, but through AUTOLOAD it creates them.  In the real
incarnation it'll fetch & eval perl code on-the-fly from its database.

But in any case, it's not the need for custom methods which leads to the
use of two objects and thus the tie of the blessed hash -- it's the need
for a separate data space distinct from the tied hash.  If I didn't need
to track other things besides the data being stored, I could have new()
pass its hash ref to tie and have tie do the only blessing:

   sub new
   {
      my $class = shift;
      my $self = {@_};
      return tie %$self, $class, $self;
   }
   sub TIEHASH
   {
      my ($class, $self) = @_;
      return bless $self, $class;
   }

*BUT* -- and this is crucial -- that code creates only one object:  a tied
hash.  These objects need to be able to store untied private data.  Private
data could be simulated through some kludges in FETCH, but I'd like to avoid
that at all costs.

(When I say "private" here, I don't really mean "private" as in C++.  I just
mean private in the usual sense of a regular Perl object which has internal
data that's not intended to be looked at from outside the class:  things
like filenames and caches and references to related objects.)


> I don't
> see the advantage of caring about or keeping the blessed
> object.  Why not just use the normal hash access method?

The advantage is a much simpler, smoother, more natural syntax for a client
of the package.

--Todd


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

Date: Thu, 02 Apr 1998 20:04:08 GMT
From: jgloudon@manitoba.bbn.com (Jason Gloudon)
Subject: Re: unpack vs. substr (was Re: Data Structure for Input File)
Message-Id: <slrn6i7rkp.4dn.jgloudon@manitoba.bbn.com>

Clinton Bodine <Clinton.Bodine@mci.com> wrote:
>You were right, it wasn't fair.... but it did emphasize an important point
>in my program.  If I use substr, I can pick and choose which fields I want
>very easily.  If I use unpack, I'm going to have to read the entire record
>and then pick and choose.

Final word from me:

unpack may be faster in this case, but you're comparing a torque driver to a
swiss army knife.  How would you extract a network byte order integer stored at
a non-zero offset in one of your records ?

-- 
Jason Gloudon


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

Date: Thu, 02 Apr 1998 20:44:38 GMT
From: Clinton Bodine <Clinton.Bodine@mci.com>
To: jgloudon@bbn.com
Subject: Re: unpack vs. substr and SWIG/XS help
Message-Id: <3523F88E.A1D30B59@mci.com>

Jason Gloudon wrote:

> How would you extract a network byte order integer stored at
> a non-zero offset in one of your records ?

This is a very interesting point you bring up and is the main reason I'm
interested in this speed issue.

I now have to read a file that DOES have long/short signed/unsigned
integers packed in it.  The solution I've been working on is to do
something like this:

$RecID = join("",stou_short(unpack("n*", substr($m, 27, 6))));
                                     2-bytes per short  ^  
where

sub stou_short {
        return unpack("S*",pack("S*",@_));
}

which converts signed to unsigned.

My problem is that I'm not convinced that I'm converting my C struct
properly for some reason.  By the end of the struct I'm setting up to read
in Perl, I'm approxiamtely 11-Bytes off from where it *looks* like I should
be (by just counting chars, shorts, and longs in the C source).

I was hoping to use the unpack to get everything properly, but I don't want
to waste the time if I suffer such a huge performance hit.  (Some of the
files I'm reading contain millions of records!)

I was hoping that I could use SWIG or XS to, at best, create a Perl
structure I could easily use and, at worst, create a function to read and
parse each record so i could easily read the fields.  But I don't have any
experience with SWIG or XS and I don't have a C++ compiler to make SWIG
(which is what I think I want to use).

So if anyone has any pointers on THIS issue, I'd appreciate it.

-- 
Clinton Bodine
Email: Clinton.Bodine@mci.com


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

Date: 2 Apr 1998 22:10:23 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: upload a file to ftp site
Message-Id: <6g12cf$l7u$13@info.uah.edu>

In article <19980402.065722.5447.0.vwong5@juno.com>,
	vwong5@juno.com (victor wasloki) writes:
: I've been working with some simple scripts in perl but I think I've come
: across something a little bit more than I can understand. What I
: ultimately want to do is to upload a file to an FTP site. I have seen
: this done before using some JAVA script, but I wanted to see it done
: using a perl script. Is there a way to write a perl script that will
: upload a file from your computer's C drive to the FTP server?

Take a look at the libnet distribution, which you can find in

    http://www.perl.com/CPAN/modules/by-module/Net/

Once you've installed it, you'll be able to use a module called Net::FTP
from your Perl programs.  Read perldoc Net::FTP for the gory details.

Hope this helps,
Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Thu, 02 Apr 1998 16:27:54 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Win32::Internet Problem
Message-Id: <3523abfc.12421673@news.btinternet.com>

On Wed, 01 Apr 1998 17:46:49 -0600, carruda@propub2.com wrote:

>I'm using the Win32::Internet module and it works fine with FetchURL,
>but not with OpenRequest.  I really need help with this one.
>
<snip>
> $INET = new Win32::Internet();
> $HTTP = $INET->HTTP("$host", "$user", "$pass");
> $HTTP->OpenRequest($REQ, "$path$extra");
> $REQ->AddHeader("Accept: text/html");
> $REQ->SendRequest();
> $file = $REQ->ReadEntireFile();
> $REQ->Close();
> $HTTP->Close();
>
>But I get the following error:
>
>"Can't call method "OpenRequest" without a package or object reference..."

It would appear that your HTTP object is not being instantiated.  I
would suggest that you check that $HTTP is a valid  object reference
(with ref()) before using it.  I am not familiar with Win32::Internet
so I cant really suggest what might be wrong beyond the arguments to
the HTTP method.
>

<snip>
>
>Is there another way to stop the server from giving me an "Error 406"?
>
Leaving out the "Accept" header might prevent the error if there is a
server mis-configuration - but the solution to that is a problem
better addressed in another NG.

You might consider using the libwww-perl suite of modules from CPAN.
Obviously they lack the MS specific stuff but they are tried and
tested and if anything easier to use.

/J\
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 2236
**************************************

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