[16993] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4405 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 22 14:05:29 2000

Date: Fri, 22 Sep 2000 11:05:12 -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: <969645911-v9-i4405@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 22 Sep 2000     Volume: 9 Number: 4405

Today's topics:
    Re: "system" running cmd with mult args (Sean McAfee)
    Re: "system" running cmd with mult args (Abigail)
    Re: Accessing Objects in an array <mike_hopkins_us@yahoo.kom>
    Re: Auto-Execute Perl in HTML ??? <maureen927@my-deja.com>
        Filter::bcrypt <ahoehma@inatec.com>
        Hashes, references, anonymous arrays <jstone211@my-deja.com>
    Re: Hashes, references, anonymous arrays (Mark-Jason Dominus)
    Re: Hashes, references, anonymous arrays <lr@hpl.hp.com>
    Re: HELP: "$line =~ s|; \$\$\$TEXT|\$\$\$TEXT|;" <lr@hpl.hp.com>
    Re: How to process bin file (Clay Irving)
    Re: Is there a DBI that will connect to MS SQL Server? <fty@mediapulse.com>
    Re: Life of a perl script (Richard J. Rauenzahn)
    Re: MD5 Apache Password Encryption? <franl-removethis@world.omitthis.std.com>
    Re: Newbie CGI question:  LWP not installed module, can nobull@mail.com
        Pattern Matching Question <bg229@scn.org>
    Re: Perl script to dynamically update page? <rga@io.com>
    Re: perl/dbi/mysql problem <jeff@vpservices.com>
    Re: perl/dbi/mysql problem <hartleh1@westat.com>
    Re: Portability of Perl/Tk programs? (Tim Hammerquist)
        Question to the wise - Reading From File desertedge@my-deja.com
    Re: Question to the wise - Reading From File <yanick@babyl.sympatico.ca>
    Re: range operator in scalar context (Mark-Jason Dominus)
    Re: range operator in scalar context <tim@ipac.caltech.edu>
    Re: Regex standards: ranges <toddg@linux46.ma.utexas.edu>
    Re: Regex standards: ranges <lr@hpl.hp.com>
    Re: sending attachment not in body of email (Mark-Jason Dominus)
    Re: serial port communication (windows) <jdb@wcoil.com>
    Re: system() not working as expected. new to perl (Mark-Jason Dominus)
        thread safety when running multiple interpreters <jdoyle@spyglass.com>
    Re: Threads are broken in ActiveState Perl v5.6. (Helgi Briem)
        Trouble using scalar vs number with Win32::OLE ltriz@my-deja.com
    Re: use CGI qw(standard); vs. use CGI qw(:standard); <fty@mediapulse.com>
    Re: Using SSI in PERL-CGI <rga@io.com>
    Re: Very newbie! <red_orc@my-deja.com>
    Re: Warning message in Win32::ODBC module <hartleh1@westat.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 22 Sep 2000 15:10:26 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: "system" running cmd with mult args
Message-Id: <CDKy5.4243$O5.94155@news.itd.umich.edu>

In article <8qfq9k$tte$1@nnrp1.deja.com>,
Hardy Merrill  <hmerrill@my-deja.com> wrote:
>In article <4mJy5.769$fa2.62011@eagle.america.net>,
>  garry@america.net wrote:
>>     $rc = system("my_cmd", "-file", "/path/to/file", "-color",
>"green");

>Ok, I got that to work.  Now the kicker - I want to kick off
>"my_cmd" in the background.  When I try to add the ampersand
>parameter as the last parameter, it croaks.  I've tried
>escaping the ampersand - no dice.

That's because using the ampersand to put a process in the background is a
shell feature.  You're (wisely) avoiding the shell, so you get no special
shell processing.

>Any ideas?

You'll have to do the fork and exec yourself:

defined(my $pid = fork()) or die "Can't fork: $!\n";
if ($pid == 0) {
    exec 'my_cmd', '-file', '/path/to/file', '-color', 'green';
    die "Couldn't exec: $!\n";
}

-- 
Sean McAfee                                                mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!


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

Date: 22 Sep 2000 15:33:13 GMT
From: abigail@foad.org (Abigail)
Subject: Re: "system" running cmd with mult args
Message-Id: <slrn8smurg.5fq.abigail@alexandra.foad.org>

Hardy Merrill (hmerrill@my-deja.com) wrote on MMDLXXIX September MCMXCIII
in <URL:news:8qfri8$vn0$1@nnrp1.deja.com>:
][ 
][ One additional problem that I didn't mention earlier - I want
][ to kick my_cmd off in the background, but when I try to add the
][ ampersand as the last parameter to system, it croaks.  Ideas?


Well, does my_cmd take '&' as a parameter and puts itself in the
background? Probably not. '&' is recognized by the _shell_. If you
want the shell dealing with stuff then use system in a way it passes
things to the shell. Alternatively, fork() and exec().



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: Fri, 22 Sep 2000 16:53:32 GMT
From: "Mike Hopkins" <mike_hopkins_us@yahoo.kom>
Subject: Re: Accessing Objects in an array
Message-Id: <g8My5.13124$nk3.638485@newsread03.prod.itd.earthlink.net>

thanks much for to all your helpful advice.
I see from Jeff's post that I was doing it corectly. I must have an error in
my code before my call to the array that was fooling me.
I am still not comfortable enough with perl to be sure of my self.  At least
now I have a little better understanding about refrences.
Thaks again
mike





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

Date: Fri, 22 Sep 2000 15:48:36 GMT
From: maureen <maureen927@my-deja.com>
Subject: Re: Auto-Execute Perl in HTML ???
Message-Id: <8qfv0b$41d$1@nnrp1.deja.com>



Hi:
   Thanks for the input but this is not working either.
I changed the html to shtml and when I tried to open
it in a browser I get a prompt box asking if I want
to save the file --- it won't open.

   Can you suggest something else. .?

                  Thanks.............Maureen



In article <8qe6f9$3rv$1@nnrp1.deja.com>,
  Mark <mtaylorlrim@my-deja.com> wrote:
> let's see if I can remember the syntax...
>
> Change your html file to  filname.shtml
>
> then where you want the cgi to run add the line...
>
> <!--#exec cgi="path/to/sctipt" -->
>
> I think that is right...
>
> Mark
>
> In article <8qe3ha$eh$1@nnrp1.deja.com>,
>   maureen <maureen927@my-deja.com> wrote:
> > Hi:
> >   I have a perl script that executes successfully when
> > executed via a hyperlink from a webpage. The script
> > generates another webpage.
> >
> >   I'd like to know how/if I can reference this script (which
> > will be altered) in my html document so that as the html
> > is rendering, the script executes and creates more html in
> > the same html document and then the rest of the html is rendered.
> >
> >   I just can seem to find the correct syntax for this.
> > It will be on a UNIX server.
> >
> >                              Thanks...!
> >
> >                                    Maureen
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
> >
>
> --
> Please reply to this newsgroup as my Deja mail
> is used as a spam catcher only!
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


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


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

Date: Fri, 22 Sep 2000 18:44:14 +0200
From: "Andreas Höhmann" <ahoehma@inatec.com>
Subject: Filter::bcrypt
Message-Id: <8qg224$fe940$1@ID-25523.news.cis.dfn.de>

hi folks,

i have write my own filter.
my filter should decrypt a crypte perlmodule, like the Filter::decrypt module.
and it seems to work with a single file but if  a crypted file is include (use blabla) in
a
crypted file then the encryption failed.

the problem is, for my decryption algorithm is save a "last" value, from
the last decrypted block.

last='' # empty
b1=decrypt(b); b2= last ^ b1; last = b1;
c1=decrypt(c); c2= last ^ c1; last = c1;
 ....

ok, independent file decrypting works fine, but in other case they don't work.

example:

package A
use B
print "A";
1;

package B
print "B";
1;

if A encrypted and B not encrypted, all is fine :-)
if B also encrypted, then encryption of A will interrupted and if
we come back from B encryption then my "last" buffer has changed
(the last from B is now equal to the last from A) :-(

any ideas, how i can save my lastbuffer before the decryption of B startet ?
is  there any documentation about filters in perl?

cu andreas




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

Date: Fri, 22 Sep 2000 16:07:56 GMT
From: J. Stone <jstone211@my-deja.com>
Subject: Hashes, references, anonymous arrays
Message-Id: <8qg04a$5hj$1@nnrp1.deja.com>

I have 50 fields I need to load to a Sybase table.  It was suggested to
me that I use a hash in the following way:

$hash{$key} = [ ];

My questions are:

1) How can I assign one array to the value of $hash{$key}, and print
them out.  I am having some issues w/ the references where the hash
VALUE is concerned.

2) When I traverse my hash, for a particular key I need to print/access
all VALUES in the array.

Any tips would be appreciated.
J. Stone


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


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

Date: Fri, 22 Sep 2000 16:55:34 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Hashes, references, anonymous arrays
Message-Id: <39cb8f06.1b81$117@news.op.net>

In article <8qg04a$5hj$1@nnrp1.deja.com>,
J. Stone  <jstone211@my-deja.com> wrote:
>I have 50 fields I need to load to a Sybase table.  It was suggested to
>me that I use a hash in the following way:
>
>$hash{$key} = [ ];
>
>My questions are:
>
>1) How can I assign one array to the value of $hash{$key}, and print
>them out. 

        @array = @{$hash{$key}};
        print @array;

or just

        print @{$hash{$key}};

>2) When I traverse my hash, for a particular key I need to print/access
>all VALUES in the array.

It's just the same:

        for $value (@{$hash{$key}}) {
          # do something with $value
        }

>Any tips would be appreciated.

You may want to have a look at 

        http://www.plover.com/~mjd/perl/FAQs/References.html

which is a short tutorial on reference syntax.



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

Date: Fri, 22 Sep 2000 10:48:49 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Hashes, references, anonymous arrays
Message-Id: <MPG.14353b5716f150d698adb5@nntp.hpl.hp.com>

In article <8qg04a$5hj$1@nnrp1.deja.com> on Fri, 22 Sep 2000 16:07:56 
GMT, J. Stone <jstone211@my-deja.com> says...
> I have 50 fields I need to load to a Sybase table.  It was suggested to
> me that I use a hash in the following way:
> 
> $hash{$key} = [ ];
> 
> My questions are:
> 
> 1) How can I assign one array to the value of $hash{$key}, and print
> them out.  I am having some issues w/ the references where the hash
> VALUE is concerned.
> 
> 2) When I traverse my hash, for a particular key I need to print/access
> all VALUES in the array.
> 
> Any tips would be appreciated.

  perldoc perldsc

(which will undoubtedly refer you also to `perldoc perlref`)

To access an individual element:

  $hash{$key}->[$index]

which can more concisely be written simply as:

  $hash{$key}[$index]

To access the entire array:

  @{$hash{$key}}

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 22 Sep 2000 10:34:48 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: HELP: "$line =~ s|; \$\$\$TEXT|\$\$\$TEXT|;"
Message-Id: <MPG.14353816eaf27adc98adb4@nntp.hpl.hp.com>

In article <slrn8smptt.5fq.abigail@alexandra.foad.org> on 22 Sep 2000 
14:09:09 GMT, Abigail <abigail@foad.org> says...
> Kourosh A Mojar (kmojar@bmjgroup.com) wrote on MMDLXXIX September
> MCMXCIII in <URL:news:39CB4301.B309E973@bmjgroup.com>:
> // ive been trying hard to do some find and replace on the following
> // expression (dollar signs are normal text): 
> // 
> // $line =~ s|; \$\$\$TEXT|\$\$\$TEXT|;
> // 
> // could anyone help me with this problem, im sure there is a simple
> // solution i have over looked.

 ...

>     s|; \$\$\$TEXT|\$\$\$TEXT|;

One might prefer to minimize redundant typing (with concomitant error 
possibilities) by using a forward look-ahead:

      s/; (?=\$\$\$TEXT)//;

> Note that use of '|' as a delimiter isn't the smartest choice.

I'll say!  See above.  Why not use '/' whenever there are no '/'s to 
escape?

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 22 Sep 2000 16:26:08 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: How to process bin file
Message-Id: <slrn8sn210.nm5.clay@panix3.panix.com>

On Fri, 22 Sep 2000 13:31:09 GMT, Bernd Hanses <bhanses@t-online.de> wrote:

>I want to process a file with binary data under Win98.
>The file is the netscape.hst file and contains all URL-adresses visited in
>a certain timeframe. I want to extract the URL-names into an  ACSII file for
>further processing via normal text editors.
>I can extract the URL's so far, but each lines contains at the end  various 
>binary data which gives me hard problems. 
>Can someone tell me a simple and fast method to get rid of this data?
>The unwanted data is always at the end of the extracted string. 
>I have tried to translate all character lower than space to a not used value,
>but this is to timeconsuming in this case.
>Thanks, Bernd 

Take a look at the Netscape::History module. :)

   http://www.perl.com/CPAN/authors/id/NEILB/

-- 
Clay Irving <clay@panix.com>
When people are free to do as they please, they usually imitate each
other. 
- Eric Hoffer 


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

Date: Fri, 22 Sep 2000 11:18:41 -0400
From: "Jay Flaherty" <fty@mediapulse.com>
Subject: Re: Is there a DBI that will connect to MS SQL Server?
Message-Id: <8qftcc$q9i$1@news3.icx.net>

If you connected to a SQL Server on NT via DBD::ODBC on a linux box, what
ODBC driver for SQL Server did you install on your linux box? I had to use
freeTDS and DBD::Sybase.

jay
<zirconx@my-deja.com> wrote in message news:8q7ok2$dpq$1@nnrp1.deja.com...
> In article <7Nxx5.5161$Vu5.278728@newsread2.prod.itd.earthlink.net>,
>   "Captain Ahab" <cublai@earthlink.net> wrote:
> >
> > > but can I connect
> > > to a modern SQLServer (is that like 7.0 or 2000?) via DBD/DBI
> > > Perl on linux? Which one?
> > >
> > > Can I just reach it with DBD:ODBC? Thanks for any help.
> >
> > I have had no problems connecting to MSSQL 7.0/2000 with DBI/DBD::ODBC
> on
> > NT.
>
> Thank you.
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.



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

Date: 22 Sep 2000 16:39:51 GMT
From: nospam@hairball.cup.hp.com (Richard J. Rauenzahn)
Subject: Re: Life of a perl script
Message-Id: <969640791.167811@hpvablab.cup.hp.com>

mufy@my-deja.com writes:
>> # perldoc -f sleep
>>
>> This is the age of the self-answering questions. We've been getting
>
>I do not have telnet access to the server nor own a server myself :-(
>so how to perldoc -f sleep ?

Certainly you're accessing deja and your free service through a PC?
Maybe you could install Perl on that machine?  www.activestate.com

>Know of Any links on the web where perl api is documented ?

www.perl.com/www.perl.org/www.perldoc.com?

Rich

-- 
Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant     | I speak for me,     |   19055 Pruneridge Ave. 
Development Alliances Lab|            *not* HP |                MS 46TU2
ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014


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

Date: Fri, 22 Sep 2000 17:32:35 GMT
From: Francis Litterio <franl-removethis@world.omitthis.std.com>
Subject: Re: MD5 Apache Password Encryption?
Message-Id: <m3zol0z618.fsf@franl.andover.net>

"William A. Rowe, Jr." <wrowe@rowe-clan.you.know.why.net> writes:

> Does anyone have an example of how to 'seed' MD5

From the MD5 package documentation:

	The MD5 module is depreciated.  Use Digest::MD5 instead.

> or Digest::MD5
> for password encryption?  crypt() is useless in this specific situation,
> so I must use MD5 encryption.

You don't "seed" the MD5 algorithm.  You feed it data using either:

	Digest::MD5::add()
or
	Digest::MD5::addfile()

After giving it all the data, you fetch the hash using one of:

	Digest::MD5::digest()
	Digest::MD5::hexdigest()
	Digest::MD5::b64digest()

Example:

	#!/usr/bin/perl -w
	use strict;
	use Digest::MD5;

	my $md5 = Digest::MD5->new();
	$md5->add("Daisy, Daisy, give me your answer do.");
	$md5->add("I'm half crazy over the love of you.");
	$md5->add("It won't be a stylish marriage.");
	$md5->add("I can't afford a carriage.");
	$md5->add("But you'll look sweet upon the seat");
	$md5->add("of a bicycle built for two.");
	$md5->add("Good day, gentlemen.");

	print "The hash is: ", $md5->hexdigest(), "\n";

Output of the above program is:

	The hash is: f33ec51da8a82bcf6f1712cb1a9f30e1
--
Francis Litterio
franl-removethis@world.std.omit-this.com
PGP public keys available on keyservers.


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

Date: 22 Sep 2000 17:40:26 +0100
From: nobull@mail.com
Subject: Re: Newbie CGI question:  LWP not installed module, can I simply upload it to my subdirectory?
Message-Id: <u91yycfkhx.fsf@wcl-l.bham.ac.uk>

"David Sisk" <davesisk@ipass.net> writes:

> My ISP supports Perl/CGI scripts, but doesn't have the LWP module installed.
> They said there's some security problem with it (anyone know any details
> about this?).

Not I.

> Anyway, I was wondering if I could just upload the LWP module (which I'd
> assume is just a .pm file)

Yes I believe it's pure Perl - but it's actually a lot of files.

> into a subdirectory under the one containing my
> perl script, and change the USE statement to point to the LWP module I
> uploaded, will this work, or no?

Not quite, you should leave the "use LWP" alone and put a "use lib" on
the front.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 22 Sep 2000 12:27:38 -0400
From: "Scott Snella" <bg229@scn.org>
Subject: Pattern Matching Question
Message-Id: <8qg18f$4t0$1@rmsrv1.aexis.net>

Hi, I am having a problem.  I have a string being passed to a CGI script
with "/"'s in it.  I need to compare that string to another.  Although I
print out both strings and they are the same, the PERL pattern matching
doesn't evaluate correctly.  I am assuming that is because of the /'s in
there.  Is there any special way that I can tell PERL to just take the whole
string and match it without having the /'s screw it up?  If not, is there a
way to iterate through each of the characters until I find a / and take it
out?  It doesn't seem as though pattern matching works at all with this
situation.  Can anyone help?  Please email me... thanks.

Scott





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

Date: Fri, 22 Sep 2000 12:06:31 -0500
From: "RGA" <rga@io.com>
Subject: Re: Perl script to dynamically update page?
Message-Id: <qlMy5.42019$XT1.669966@news5.giganews.com>



Your absolute Root:

#!/usr/bin/perl
print "Content-Type: text/html\n\n";
$ENV{DOCUMENT_ROOT};
exit;

Also, make sure you are not trying to print to another server
You can't print to http://bla bla

 only /home/bla/bla ...


> It has been suggested the full path is not specified but I dont know this
> and the host doesn't always reply to emails.
> If the root directory is indeed the problem does anyone know this servers
> path please?= http://www.portland.co.uk




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

Date: Fri, 22 Sep 2000 09:23:48 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: perl/dbi/mysql problem
Message-Id: <39CB8794.F6F8E87@vpservices.com>

Trevor Ward wrote:
> 
> <jnk@kenobiz.com> wrote in message
> news:39cb7669.67788508@news.acronet.net...
> > #!/usr/local/bin/perl
> >
> > use DBI;
> >
> > $dbh = DBI->connect("DBI:mysql:db_kenobiz_com", 'kenobiz_com', '***');
> > $dbh->do("CREATE TABLE testing (user VARCHAR(15), pass VARCHAR(10))");
> > $dbh->do("INSERT INTO testing VALUES ('misener', '78dh9as4')");
> > $dbh->disconnect;
> 
> The basic create statement will work to make the table

WRONG.  "user" is a SQL reserved word, it can not be used as a column
name.

> but using standard
> sql the insert statement is invalid.
>
> INSERT into testing   (user, pass) VALUES ('misener', '78dh9as4');
> 
> need to specify the fields as well.

WRONG.  one *may* specify the fields, but inserting without specifiying
them is perfectly valid.

-- 
Jeff


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

Date: Fri, 22 Sep 2000 13:25:28 -0400
From: Henry Hartley <hartleh1@westat.com>
Subject: Re: perl/dbi/mysql problem
Message-Id: <39CB9608.2B0E82C2@westat.com>


Jeff Zucker wrote:
> Trevor Ward wrote:
> > <jnk@kenobiz.com> wrote in message
> > > #!/usr/local/bin/perl
> > > use DBI;
> > > $dbh = DBI->connect("DBI:mysql:db_kenobiz_com", 'kenobiz_com', '***');
> > > $dbh->do("CREATE TABLE testing (user VARCHAR(15), pass VARCHAR(10))");
> > > $dbh->do("INSERT INTO testing VALUES ('misener', '78dh9as4')");
> > > $dbh->disconnect;
> >
> > The basic create statement will work to make the table
> 
> WRONG.  "user" is a SQL reserved word, it can not be used as a column
> name.

For kicks (too much time on my hands, I guess) I issued the above
referenced CREATE statement in the MySQL Monitor (or whatever they call
their command line thing) and it created a table with two fields, "user"
and "pass".  Then, the INSERT command as listed created a new record. 

Next, I wrote a short script as above (with -w and use strict; just to
be sure) and it created the table and added a record with no warnings or
errors.  

I am NOT recommending that the OP use the word "user" as a field name. 
Just that the code originally posted seems to work here.  Perhaps there
is a permissions issue?


> > INSERT into testing   (user, pass) VALUES ('misener', '78dh9as4');
> > need to specify the fields as well.
> 
> WRONG.  one *may* specify the fields, but inserting without specifiying
> them is perfectly valid.

Correct.  I might say one *should* specify the fields, however.  Imagine
what will happen when you (or some other poor soul) comes in later and
recreats the table with the fields in a different order or with an
additional field before those originally included.  The same is also
true for select statements like "SELECT * FROM testing;".  Better to
specify fields.

Henry Hartley


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

Date: Fri, 22 Sep 2000 16:56:06 GMT
From: tim@degree.ath.cx (Tim Hammerquist)
Subject: Re: Portability of Perl/Tk programs?
Message-Id: <slrn8sn4ib.m7.tim@degree.ath.cx>

Clinton A. Pierce <clintp@geeksalad.org> wrote:
> > I'm not expecting it to do anything.  I haven't even booted up my Win32
> > partition for anything except Tomb Raider 4 in months.  My impression
> > came from the inordinate amount of "problem with fork" posts on
> > ActiveState's Perl-Win32-* lists.
> 
> I'm on those lists and most of those problems are related to the 
> fact that you've now got a bunch of Win32 weenies trying to use 
> something that's completely out of their normal way of thinking.
> 
> The remainder is the kind of crap you'd see in Unix lists of the 
> same nature.

Granted.  I apologize for the misinformed post.

> 
> The fork() function works fine.  Win32's just got a bunch of 
> programmers that need to be debugged.  :)

Don't forget what Larry said:
	"People get annoyed when you try to debug them."  =)

Thx.

-- 
-Tim Hammerquist <timmy@cpan.org>
The world is a tragedy to those who feel,
but a comedy to those who think.
	-- Horace Walpole


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

Date: Fri, 22 Sep 2000 16:46:20 GMT
From: desertedge@my-deja.com
Subject: Question to the wise - Reading From File
Message-Id: <8qg2ck$8he$1@nnrp1.deja.com>

I know this is a very easy question, but either my lack of patience (3
hours of searching through doc's), or my lack of intelligence has
prohibited me from figuring this simple step out.

I simply want to open a file, and print the contents.

Here is my attempt code:

open(FILE,"test.txt") or &dienice ;
while (<FILE>) {
   print"$FILE\n";
}
close(FILE) ;

Thanks.


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


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

Date: Fri, 22 Sep 2000 17:18:59 GMT
From: Yanick Champoux <yanick@babyl.sympatico.ca>
Subject: Re: Question to the wise - Reading From File
Message-Id: <7wMy5.260015$Gh.6592775@news20.bellglobal.com>

desertedge@my-deja.com wrote:
: I know this is a very easy question, but either my lack of patience (3
: hours of searching through doc's),

'perldoc perlsyn' is probably what you are looking for here.

: I simply want to open a file, and print the contents.

: Here is my attempt code:

: open(FILE,"test.txt") or &dienice ;
: while (<FILE>) {
:    print"$FILE\n";
: }
: close(FILE) ;

You almost had it.

Explicit way:

open FILE, "text.txt" or die "Tu quoque, file? $!";

while( defined( $line = <FILE> ) )
{
	print $line;
}
close FILE;

Typical way:

open FILE, "text.txt" or die "Tu quoque, file? $!";
while( <FILE> )
{
	print;
}
close FILE;

Short way:

open FILE, "text.txt" or die "Tu quoque, file? $!";
print while <FILE>;
close FILE;

Sick way:
print `cat text.txt`;


Joy,
Yanick

-- 
eval" use 'that poor Yanick' ";
print map{ (sort keys %{{ map({$_=>1}split'',$@) }})[hex] }
qw/8 b 15 1 9 10 11 15 c b 13 1 12 b 13 f 1 c 9 a e b 13 0/;


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

Date: Fri, 22 Sep 2000 16:39:35 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: range operator in scalar context
Message-Id: <39cb8b46.1aec$2be@news.op.net>

In article <39CA5FD7.D5230878@ipac.caltech.edu>,
Tim Conrow  <tim@ipac.caltech.edu> wrote:
>By coincidence, I was just considering code similar to this:
>
># -w and strict on
>print if /ad/..."af" for ("aa".."az");
>
>This prints:
>
>adaeafagahaiajakalamanaoapaqarasatauavawaxayaz
>
>The docs do not explicitly cover what happens if one of the expressions is not
>either a match op nor a numeric. 

Yes, they do.  If it is a constant expression, it is compared with $.,
and if it is not, it is evaluated.  That is an exhaustive enumeration
of all possibilities.

"af" is a constant expression, so it is implicitly compared with $. .

>a) the string "af" should be coerced into a numeric to compare it to $., which
>will never be true, or 

Right.

>b) the string is evaluated as a boolean true and only the "adae" should be
>printed, or

No, because "af" is a constant expression.

>c) the string "af" is somehow interpreted as an RE (as for split) and
>will thus print "adaeaf".

The manual certainly does not say anything about interpreting strings
implicitly as regexes in the range operator.

> But why no warning for attempting to coerce a non-numeric string
>into a numeric? 

That turns out to be interesting.  It is because perl is not coercing
the string.  Why not?  Because it is skipping the comparison.  Why is
it skipping the comparison?  Because you have never done any
filehandle read at all, so examining $. is meaningless.

Try this instead:

        perl  -we '<DATA>; for ("aa" .. "az") { print if /ad/..."af" }'  

        perl  -we '        for ("aa" .. "az") { print if /ad/..."af" }'  


The first program delivers the warning as you would expect; the second
does not.


This incidentally means that 

        ($. == 0) .. $foo

and

        0 .. $foo

are not quite identical. 



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

Date: Fri, 22 Sep 2000 10:52:05 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: range operator in scalar context
Message-Id: <39CB9C45.FC64C387@ipac.caltech.edu>

Mark-Jason Dominus wrote:
> 
> In article <39CA5FD7.D5230878@ipac.caltech.edu>,
> Tim Conrow  <tim@ipac.caltech.edu> wrote:
> >By coincidence, I was just considering code similar to this:
> >
> ># -w and strict on
> >print if /ad/..."af" for ("aa".."az");
> >
> >This prints:
> >
> >adaeafagahaiajakalamanaoapaqarasatauavawaxayaz
> >
> >The docs do not explicitly cover what happens if one of the expressions is
> >not either a match op nor a numeric.
> 
> Yes, they do.  If it is a constant expression, it is compared with $.,
> and if it is not, it is evaluated.  That is an exhaustive enumeration
> of all possibilities.

Well, except for the fact that, as you make clear below, it isn't *excactly*
correct, depending on how one might choose to interpret "compared".

> > But why no warning for attempting to coerce a non-numeric string
> >into a numeric?
> 
> That turns out to be interesting.  It is because perl is not coercing
> the string.  Why not?  Because it is skipping the comparison.  Why is
> it skipping the comparison?  Because you have never done any
> filehandle read at all, so examining $. is meaningless.

Wow, a previously unknown (to me) optimization. Thanks for the news.

In trying to understand this by reading perlop and trying out code, a sentence
like this would certainly have been helpful: "If no filehandle has ever been
read, constant expressions are never compared and are always false." An edge
case perhaps, but one I think should be documented.

--

-- Tim Conrow         tim@ipac.caltech.edu                           |


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

Date: 22 Sep 2000 16:17:54 GMT
From: Todd Gillespie <toddg@linux46.ma.utexas.edu>
Subject: Re: Regex standards: ranges
Message-Id: <8qg0ni$dkb$1@geraldo.cc.utexas.edu>

Bart Lateur <bart.lateur@skynet.be> wrote:
: Todd Gillespie wrote:

:>Question: is there functionality in a CPAN module to tokenize something
:>like this problem; or is there a written theory on what generally
:>constitutes legal ranges?

: I'd simply try to write a regex for each individual syntax you'd accept.
: How hard can it be?

It's not hard to write the program, it's hard to design a system that
won't turn away 90% of the users with "I don't understand $_".  I can
write the regexs no problem, I was wondering if there was some kind of
repository of design patterns for regexes, from which I might find that
someone has found the general solution.
But thanks for your help.


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

Date: Fri, 22 Sep 2000 10:19:37 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Regex standards: ranges
Message-Id: <MPG.143534825503708b98adb3@nntp.hpl.hp.com>

In article <l3smss8rhip71pjssu0sv037lc3hlbs7g7@4ax.com> on Fri, 22 Sep 
2000 14:50:37 GMT, Bart Lateur <bart.lateur@skynet.be> says...
+ Todd Gillespie wrote:
+ 
+ >I'm trying to write a regex that takes a user string with their
+ >bizarre concept of ranges: 'R1..8','R1-R8','R[1-8]',etc,etc (I might
+ >not be creative enough to think of more parser-breaking combos).
+ >
+ >Question: is there functionality in a CPAN module to tokenize
+ >something like this problem; or is there a written theory on what
+ >generally constitutes legal ranges?

Not that I know of.

+ I'd simply try to write a regex for each individual syntax you'd
+ accept.  How hard can it be?
+ 
+   while(<DATA>) {
+       if(/^R(\d+)(?:-|\.\.)(\d+)$/
+          || /^R(\d+)(?:-|\.\.)R(\d+)$/
+          || /^R\[(\d+)(?:-|\.\.)(\d+)\]$/) {
+           print "Got a range: from $1 to $2\n";
+       } else {
+           print "I don't understand \"$_\"\n";
+       }
+   }
+ __DATA__
+ R1..8
+ R1-R8
+ R[1-8]

As this solution doesn't cover 'more parser-breaking combos', how about 
a more tolerant approach:  Any 'R' (or even 'r'), followed somehow by 
two sequences of digits (unanchored):

   /[Rr].*(\d+).+(\d+)/

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 22 Sep 2000 16:01:19 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: sending attachment not in body of email
Message-Id: <39cb824e.1968$1a5@news.op.net>

In article <39CB2A98.B5EEF44F@fractalgraphics.com.au>,
Hugo Bouckaert  <hugo@fractalgraphics.com.au> wrote:
>PS: (to Gwyn): What is the terrible thing I said?   

Gwyn puts that in every article.    It is very tiresome.




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

Date: 22 Sep 2000 16:03:16 GMT
From: "Josiah Bryan" <jdb@wcoil.com>
Subject: Re: serial port communication (windows)
Message-Id: <8qfvs4$rme$0@206.230.71.22>

perldoc -q serial

hth,

--
Josiah Bryan <jdb@wcoil.com>

eval' use" :perl hacks by Josiah  "';$.=000250000;@_=map{substr($@,hex,1)}
qw/3b 3c 3d 3e 3f 40 2c 06 01 07 03 06 04 02 03 0a 40 07 08 06 2d 07 08 14
06 40 04 34 35 07 08/;$Jj=@_/2;for(0..$Jj){$/=$_[$Jj-$_],$_[$Jj-$_]=$_[$Jj
+$_],$_[$Jj+$_]=$/;print@_,"\r";for(0..$.){}}for($_=$Jj;$_>-1;$_--){$/=$_[
$Jj-$_],$_[$Jj-$_]=$_[$Jj+$_],$_[$Jj+$_]=$/;print@_,"\r";for(0..$.*2){}}

Bob M <slipper@canada.com> wrote in message
news:EKJy5.6408$gi1.125081@news.magma.ca...
> Any hints on how to read and write (and set baud rates, etc) to a serial
port
> on a windows machine?
>
> thanks
> Bob




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

Date: Fri, 22 Sep 2000 16:05:37 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: system() not working as expected. new to perl
Message-Id: <39cb8350.198c$328@news.op.net>

In article <8qf4fh$5g1$1@nnrp1.deja.com>,  <tjmurphy9677@my-deja.com> wrote:
>system("uuencode file1 file2 | mail -s summary
>tony.murphy@start.de") i get a mail as expected
>with a file - but there is no data in the file.

Perhaps the perl program has not been executed in the same directory
as 'file1', and you did not provide a complete path to the file?

Try doing this instead:

system("uuencode file1 file2 2>&1 | mail -s summary tony....");

The 2>&1 will redirect the error output of the uuencode command into
the mail command.  Then if uuencode fails, you will get a mail message
explaining why.



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

Date: Fri, 22 Sep 2000 10:19:41 -0500
From: "Joe Doyle" <jdoyle@spyglass.com>
Subject: thread safety when running multiple interpreters
Message-Id: <vIKy5.2567$z77.179798@news.goodnet.com>

After looking at a few sources (perlembed man page, Advanced Perl
Programming by Srinivasan), it looks like building Perl with -DMULTIPLICITY
will make running separate interpreters in separate threads a safe thing to
do. In other words, this is OK:

#include <EXTERN.h>
#include <perl.h>

#define SAY_HELLO "-e", "print qq(Hi, I'm $^X\n)"

void* run_interpreter(void* args)
{
    char** these_args = (char **) args;

    PerlInterpreter *one_perl = perl_alloc(),
    perl_construct(one_perl);
    perl_parse(one_perl, NULL, 3, these_args, (char **)NULL);
    perl_run(one_perl);
    perl_destruct(one_perl);
    perl_free(one_perl);
}

char *one_args[] = { "one_perl", SAY_HELLO };
char *two_args[] = { "two_perl", SAY_HELLO };

 int main(int argc, char **argv, char **env)
 {
     pthread_create(NULL, NULL, run_interpreter, one_args);
     pthread_create(NULL, NULL, run_interpreter, two_args);
  .
  .
  .



However, neither of these sources explicitly states that to be true, and I
would like to hear it from an expert before spending a lot of time on it.

So, is running separate interpreters in separate threads safe?






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

Date: Fri, 22 Sep 2000 16:51:03 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: Threads are broken in ActiveState Perl v5.6.
Message-Id: <39cb8b25.603689519@news.itn.is>

On 21 Sep 2000 08:41:24 GMT, "Josiah Bryan" <jdb@wcoil.com>
wrote:

>I have this test script:
>
>use Thread;
>$a = new Thread \&sub1;
>$b = new Thread \&sub2;
>
>sub sub1 {
>print "in thread 1\n";
>}
>
>sub sub1 {
>print "in thread 2\n";
>}
>__END__
>
>And it immediatly prints the error message (when run):
>
>"No threads in this perl at threads.test line 2." (no quotes)
>
>Any clues/hints/pointers/etc? It obviously says it is threads-enabled,
>(see output of perl -v  and perl -V, below), and it is ActiveState build
>613.
>It is very troubling. Latest release of perl and latest release of perl from
>AS,
>and threads STILL dont work! Argggggggggg. Any suggestions?

Well, it says in the docs:

NAME
Thread - manipulate threads in Perl (EXPERIMENTAL, subject
to change)

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

SUPPORTED PLATFORMS
NOTE: The Thread extension requires Perl to be built in a
particular way to enable the older 5.005 threading model.
ActivePerl is not built this way, which means this extension
will not work under ActivePerl. If you wish to use the 5.005
threading model, you will need to compile Perl from the
sources to enable this feature. 

and

DESCRIPTION
    WARNING: Threading is an experimental feature.  
Both the interface and implementation are subject 
to change drastically.  In fact, this documentation
describes the flavor of threads that was in version
5.005.  Perl 5.6.0 and later have the beginnings of 
support for interpreter threads, which (when finished) is
expected to be significantly different from what is
described here.  The information contained here may
therefore soon be obsolete.  Use at your own risk!
The Thread module provides multithreading support 
for perl.

and

Basic Thread Support
Thread support is a Perl compile-time option-it's something
that's turned on or off when Perl is built at your site,
rather than when your programs are compiled. If your Perl
wasn't compiled with thread support enabled, then any
attempt to use threads will fail.

So the upshot is, recompile perl.exe with the
command line option that allows threads.  
What that is I don't know.  

Regards,
Helgi Briem


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

Date: Fri, 22 Sep 2000 16:57:37 GMT
From: ltriz@my-deja.com
Subject: Trouble using scalar vs number with Win32::OLE
Message-Id: <8qg31k$9as$1@nnrp1.deja.com>

I'm having a hard time passing a scalar variable to the Win32::OLE
module -- it only works when the actual number is passed, not a scalar.

my $num = 3;
my $sheet = $self->{book}->Worksheets($num) or die Win32::OLE->LastError
();

doesn't work. However,

my $sheet = $self->{book}->Worksheets(3) or die Win32::OLE->LastError();

does. It only works when a hard number is inserted, not a scalar
containing a number, even if it's the same number.

Does anyone see why/how this doesn't work? The error is:

Win32::OLE(0.14) error 0x8002000b: "Invalid index"    in
METHOD/PROPERTYGET "Worksheets" at ...

Am I missing something obvious?  Thanks for any help you can offer.


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


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

Date: Fri, 22 Sep 2000 11:32:38 -0400
From: "Jay Flaherty" <fty@mediapulse.com>
Subject: Re: use CGI qw(standard); vs. use CGI qw(:standard);
Message-Id: <8qfu6h$on4$1@news3.icx.net>

Read the documentation on the Exporter module (Chap. 7 Programming Perl).
Look at how
%EXPORT_TAGS is used.

jay
"Ron Grabowski" <ronnie@catlover.com> wrote in message
news:39C826CD.80B15BD1@catlover.com...
> How are the two lines above different? What does the ':' signify?



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

Date: Fri, 22 Sep 2000 11:50:52 -0500
From: "RGA" <rga@io.com>
Subject: Re: Using SSI in PERL-CGI
Message-Id: <plMy5.42018$XT1.669966@news5.giganews.com>


No can do.

SSI is server implimented includes, executes, primitive.
 and inherantly security risky

CGI is a non related process, doesn't recognize SSI

Just do as plain file include from your script.

Whatever you can include via SSI, you can include
 a thousand times more powerful in CGI ..

> And the when the perl script reads the file it
> don't execute the SSI-command.




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

Date: Fri, 22 Sep 2000 15:25:56 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: Very newbie!
Message-Id: <8qftl8$2ek$1@nnrp1.deja.com>

In article <1cKy5.3056$6b2.52052@news6-win.server.ntlworld.com>,
  "vertical.reality" <vertical.reality@ntlworld.com> wrote:
> I have installed Active Perl onto my machine (win98)
>
> Does this mean I can run the script locally to view the results
> without uploading them and then viewing them ?????

depending on what your perl script does, and assuming that 'locally'
means 'on the machine just mentioned', yes.

> Probably a silly question!

no.

>
> Is it something to do with the first line in the script ......?

on my system, I type:

  perl my-script-path-and-name

regardless of the path specified on the shebang line.




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


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

Date: Fri, 22 Sep 2000 13:34:17 -0400
From: Henry Hartley <hartleh1@westat.com>
Subject: Re: Warning message in Win32::ODBC module
Message-Id: <39CB9819.A6C627F@westat.com>


Philip Lees wrote:
> 
> Hi. I'm using Win32::ODBC to read data from a database and insert it
> into an html file for output. It's working fine, except that I get the
> following warnings:
> 
> Use of uninitialized value at C:/Perl/site/lib/Win32/ODBC.pm line 261.
>     foreach (@Results){
>         s/ +$//; # HACK
>         $self->{'data'}->{ ${$self->{'fnames'}}[$num] } = $_;
>         $num++;
>     }
> 

Somewhere above the "foreach (@Results){" line there will be a line that
starts with "my" and contains "$num".  I don't remember the exact
wording, I think it was:

my(@Results, $num);

Replace that single line with the two lines:
my @Results;
my $num = 0;

Now, you don't have an uninitialized value of $num when you get to the
reference below it.  This really should be fixed in the source.  Dave
Roth, if you are listening...

Henry Hartley


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

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


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