[17443] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4863 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 10 06:05:45 2000

Date: Fri, 10 Nov 2000 03:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <973854311-v9-i4863@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 10 Nov 2000     Volume: 9 Number: 4863

Today's topics:
    Re: $password = crypt($pass, ar); (Csaba Raduly)
    Re: Backtick problems on Windows98 <bart.lateur@skynet.be>
        changing a string for ODBC use <miriamsmit@zonnet.nl>
    Re: DBI::DBD Oracle OS Authentication <dischner@klch.med.uni-muenchen.de>
        dbm file formats zfer@my-deja.com
    Re: Emailing formatted (ntl)
    Re: Emailing formatted (ntl)
    Re: getting a list of files like in @ARGV <bart.lateur@skynet.be>
    Re: Handling Postcode Ranges <W.Hielscher@mssys.com>
    Re: Hash assignments in loops? gelshocker@my-deja.com
    Re: Hash assignments in loops? gelshocker@my-deja.com
    Re: how do I process multiple selections? (ntl)
    Re: how do I process multiple selections? (ntl)
    Re: how do I process multiple selections? (ntl)
    Re: How to force MSDOS window to stay open after perl? pelle1970@my-deja.com
        Install mod on Win32 with nmake <mediamas@labyrinth.net.au>
        my.cgi.suspended xzhang3388@my-deja.com
    Re: NT4 - How do I display the current userid? <elephant@squirrelgroup.com>
    Re: OOP and information hiding <bart.lateur@skynet.be>
    Re: Perl and mysql <graham@coms.com>
    Re: Please teach how to read binary data in Perl langua (Eric Bohlman)
        Problem with String Substitution <ray.a.lopez2@boeing.com>
    Re: Problem with String Substitution (Rafael Garcia-Suarez)
    Re: Q: Getting program line number? (Csaba Raduly)
    Re: qx(...&); hangs program (Rafael Garcia-Suarez)
    Re: qx(...&); hangs program <skv@iis.nsk.su>
    Re: qx(...&); hangs program (Rafael Garcia-Suarez)
    Re: ref & regexp's don't mix in 5.6? (Ilya Zakharevich)
    Re: ref & regexp's don't mix in 5.6? <elephant@squirrelgroup.com>
    Re: ref & regexp's don't mix in 5.6? <bart.lateur@skynet.be>
    Re: Returning variable from PM <elephant@squirrelgroup.com>
    Re: Secured http ( https) <elephant@squirrelgroup.com>
        Using Perl OLE to edit acrobat annotations. (Fergus McMenemie)
    Re: Using Perl OLE to edit acrobat annotations. (Aandi Inston)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 10 Nov 2000 10:51:07 +0000 (UTC)
From: real.email@signature.this.is.invalid (Csaba Raduly)
Subject: Re: $password = crypt($pass, ar);
Message-Id: <8FE86F88Equuxi@194.203.134.135>

A million monkeys weren't enough! It took ren.maddox@tivoli.com (Ren
Maddox) on 07 Nov 2000 to produce
<m3puk7pkdj.fsf@dhcp11-177.support.tivoli.com>: 

>I hate to step into this quagmire, but...
>
>"EM" <me@privacy.net> writes:
>
[snip]
>
>> $curdec = "0";
>> GETPASS: {
>> $test = crypt($curdec, $salt);
>
>What's up with people posting non-indented code?
>

In EM's post:

X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4132.2800
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4132.2800

Csaba

-- 
Csaba Raduly, Software Developer (OS/2), Sophos Anti-Virus
mailto:csaba.raduly@sophos.com      http://www.sophos.com/
US Support +1 888 SOPHOS 9      UK Support +44 1235 559933
Life is complex, with real and imaginary parts.


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

Date: Fri, 10 Nov 2000 10:36:46 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Backtick problems on Windows98
Message-Id: <lejn0t05kl0euqjp0q0v1uh7np19bp91rs@4ax.com>

Peter Lerup wrote:

>I'm quite sure that the problem is not in Perl but in the "command.com"
>shell. My hope was just that someone else have seen this occur when running
>Perl and had a solution.

 ...

>system("dir");

You've picked a bad example. "dir" is usually a bult-in into the command
line interpreter, and not an external program. I'm pretty sure that is
why it fails, on some systems.

Can't you invoke COMMAND.COM explicitely? There are some command line
switches, "/C" and "/K", which make command.com terminate when finished,
or hanging on. I always forget which is which.

	$result = `command /c dir`;

Yes, that appears to work, on Win98.

Er... only when command.com is available, I guess. Oh, there's the
environment variable COMSPEC, which contains the name of the program.

	$result = `"$ENV{COMSPEC}" /c dir`;

(The quotes are there for the case where that environment variable
contains spaces; which is very unlikely.) Er, yes, that looks like it's
working, too.

-- 
	Bart.


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

Date: Fri, 10 Nov 2000 11:21:49 +0100
From: "Michel Wouterse" <miriamsmit@zonnet.nl>
Subject: changing a string for ODBC use
Message-Id: <gWPO5.31150$tL4.417875@zonnet-reader-1>

Hi Group,

I wrote a simple form and script that allows people to put a line of text in
a database.
I am using Perl for the script, windows NT, Access ODBC for the database.
Everything goes fine until I use characters like ', ", &, @ and so on in my
oneliners...

How do I change those characters into a format accepted? And what format
does it want?

please help me,

Michel




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

Date: Fri, 10 Nov 2000 10:13:32 +0100
From: Anton Dischner <dischner@klch.med.uni-muenchen.de>
Subject: Re: DBI::DBD Oracle OS Authentication
Message-Id: <101120001013322271%dischner@klch.med.uni-muenchen.de>

Hi Bill,

if you are on Unix enter: perldoc DBD::Oracle

In short:

Connect Attributes

$mode = 2; # SYSDBA
$mode = 4; # SYSOBER

DBI->connect($dsn, $user, $passwd, { ora_session_mode => $mode});

This is not the full answer to your question but it may help.
I tried a few combinations with no avail.

regards,

Toni

> What is the correct DBI connect syntax for connect to log in to Oracle
> as sysdba without specifying a password (script running on server).

-- 
ZXR750H, 55 Mm. 
Q: How did the medical community come up with the term "PMS"?
A: "Mad Cow Disease" was already taken.
Posen fuer Anfaenger: http://www.w-klch.med.uni-muenchen.de/dischner


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

Date: Fri, 10 Nov 2000 10:32:39 GMT
From: zfer@my-deja.com
Subject: dbm file formats
Message-Id: <8ugis8$l93$1@nnrp1.deja.com>

Hi,

until yesterday, my CGI Perl script using dbmopen() worked fine on my
local HTTP server and on remote ISP server. I could exchange the *.db
files from the two systems without any trouble.

The ISP has upgraded its Linux system.

Today I've discovered that scripts are still working but the old *.db
files are not readable on new ISP system and the binary compatibility
from local *.db and remote *.db files is missed.

Are there suggestions about how to solve this incompatibility?
Are there suggestions about how to translate data stored in old *.db
format in the new *.db?

Thank you in advance,         \zfer


Here there is a sample of such CGI that I've written for make tests:
----------------------------------------
#!/usr/bin/perl
# open file sample1.db for write some data,
# close it and then open it again for input
# and print same data.

use CGI;
use CGI::Carp qw(fatalsToBrowser);
$q=new CGI;

print $q->header();
print "<h1>sample.db</h1>\n";
print "<h2>Creation of file</h2>\n";

if (dbmopen(%P, "sample1", 0666)) {
    $P{'1'}='one';
    $P{'2'}='two';
    $P{'3'}='three';
    $P{'done'}='false';
    dbmclose(%P);
    print "file created!<br>\n";
} else {
    print "open file for write has failed!<br>";
    exit 1;
}

print "<hr>\n<h2>Open it and read</h2>\n";
print "<b>key</b>, <b>value</b><br>\n";

if (dbmopen(%A, "sample1" , 0666)) {
    foreach $key (keys %A) {
	print "$key, $A{$key}<br>\n";
    }
    dbmclose(%A);
} else {
    print "Error opening sample1.db";
}


exit;

1;
-----------------------------


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


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

Date: Fri, 10 Nov 2000 08:58:35 -0000
From: "Alan Dougall (ntl)" <abaltd@ntlworld.com>
Subject: Re: Emailing formatted
Message-Id: <QNOO5.227$SI1.3647@news6-win.server.ntlworld.com>

Peter Sundstrom <peter.sundstrom@eds.com> wrote in message
news:8ucg5t$fjf$1@hermes.nz.eds.com...
>
> Use MIME::Lite and optionally the pretty recent MIME::Lite::HTML modules
>
Thx, Peter
This looks useful - I managed to download MIME::Lite but cannot see/find the
MIME::Lite::HTML modules

Do you have a url for this per chance?






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

Date: Fri, 10 Nov 2000 09:10:35 -0000
From: "Alan Dougall (ntl)" <abaltd@ntlworld.com>
Subject: Re: Emailing formatted
Message-Id: <4ZOO5.252$SI1.3905@news6-win.server.ntlworld.com>

Thx - got it on "mail & Mime" thread.

Alan Dougall
alan.dougall@virgin.net
http://start.at/the.cross

Alan Dougall (ntl) <abaltd@ntlworld.com> wrote in message
news:QNOO5.227$SI1.3647@news6-win.server.ntlworld.com...
> Peter Sundstrom <peter.sundstrom@eds.com> wrote in message
> news:8ucg5t$fjf$1@hermes.nz.eds.com...
> >
> > Use MIME::Lite and optionally the pretty recent MIME::Lite::HTML modules
> >
> Thx, Peter
> This looks useful - I managed to download MIME::Lite but cannot see/find
the
> MIME::Lite::HTML modules
>
> Do you have a url for this per chance?
>
>
>
>




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

Date: Fri, 10 Nov 2000 10:26:43 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: getting a list of files like in @ARGV
Message-Id: <ivin0t4vu9tjgjrj2ardsujnoocc29s42q@4ax.com>

arno wrote:

>if I start my script with *.LOG on the command line I get all the filenames
>ending with .LOG expanded in @ARGV
>q:
>How can I get a list with filenames from a scalar with the value of *.LOG

The name of the function is "glob". In fact, Perl supports two ways of
doing  this:

	@files = glob("*.LOG");

or

	@files = <*.LOG>;

Personally, I'd like to see the latter to be cut up and hanged to dry.
It's so inconsistent with the rest of Perl, it's hard to believe. Now,
what *I*'d like this to would have done, is that:

	while(<*.LOG>) {
	    # process one line
	}

would be more or less equivalent to:

	@ARGV = glob("*.LOG");
	while(<>) {
	    # process a line from one of the files

	}

except it wouldn't mess with @ARGV.

IT IS NOT THAT WAY!

In short: I only use the form glob($string). I can only hope that one
day, the other one gets fixed. Which is not likely.

-- 
	Bart.


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

Date: Fri, 10 Nov 2000 11:15:54 +0100
From: Wolfgang Hielscher <W.Hielscher@mssys.com>
Subject: Re: Handling Postcode Ranges
Message-Id: <3A0BCADA.331AD33A@mssys.com>

Peter Sundstrom wrote:
> So are you are saying that the cost of setting up a hash would be fairly
> minimal compared to any other method?

No, the costs for setting up a hash, or even better an array as Ian
Boreham pointed out (forget the hash-idea), wouldn't be "minimal"
compared to for example setting up the "@upper_bound" array in the code
I posted.

But the choice of method/implementation for determing your range-id must
be made based upon the characteristics of your problem:

- you want to save memory in the first place
  Well, IMO the @upper_bound array may be one way...

- you want a fast programm and need to reconfigure your postcode ranges
fairly often
  Given a postcode configuration, you do just, let's say 20 lookups and
then change the  configuration. Then the price (in terms of execution
time) for setting up a 10,000 element array seems too high compared to
the time you save by fast lookups.

- you need to reconfigure your ranges not so often
  Let's say you do 200,000 lookups. The fixed setup-costs (time you
spend once) for your 10,000 element array may just become irrelevant
compared to the time you save 200,000 times by fast array-lookups.

So you have to make your own decision what is "efficent" in your special
case. Btw. the Camel book (2nd edition) offers some nice views on
"Efficency" in Chapter 8.


The last thing you might have in mind is the time you spend to choose
and implement your "right" solution compared to the benefits you
expect... ;)

Cheers
	Wolfgang


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

Date: Fri, 10 Nov 2000 06:41:22 GMT
From: gelshocker@my-deja.com
Subject: Re: Hash assignments in loops?
Message-Id: <8ug5ai$b05$1@nnrp1.deja.com>


> >
> >...and to assign (fruit => person) during the loop.
>
>    foreach $_ ( @lines ) {
>       my($k, $v) = split /,/;
>       $h{$k} = $v;  # assign one _element_ of the hash, not the whole
hash
>    }
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@metronet.com                     Perl programming
>     Fort Worth, Texas
>

I have tried that (please see other posts in this thread). I thought
this would work before, but it won't compile for some reason.

Jason Lam


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


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

Date: Fri, 10 Nov 2000 06:52:55 GMT
From: gelshocker@my-deja.com
Subject: Re: Hash assignments in loops?
Message-Id: <8ug605$bfd$1@nnrp1.deja.com>


> >...and to assign (fruit => person) during the loop.
>
>    foreach $_ ( @lines ) {
>       my($k, $v) = split /,/;
>       $h{$k} = $v;  # assign one _element_ of the hash, not the whole
hash
>    }
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@metronet.com                     Perl programming
>     Fort Worth, Texas
>

Sorry Tad, it does work :P

Thank you , thank you, thank you everyone for your help.

Best Regards,

Jason Lam


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


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

Date: Fri, 10 Nov 2000 09:27:40 -0000
From: "Alan Dougall (ntl)" <abaltd@ntlworld.com>
Subject: Re: how do I process multiple selections?
Message-Id: <5dPO5.289$SI1.3387@news6-win.server.ntlworld.com>


Thx Martien for the scoping advice.


Martien Verbruggen <mgjv@tradingpost.com.au> wrote in message
news:slrn90l6ob.22p.mgjv@martien.heliotrope.home...

> > foreach $stuff (@stuff) {
> >   ${$stuff} = $q->param($stuff);
> >   ${$stuff} =~ s/\'//g;
>
> What are you doing here? Or rather, what are you trying to do here? Are
> you using symbolic references to set globals? Why? Why would you do
> that, when you already have access to all these things by directly
> calling param?
>
>        FETCHING THE VALUE OR VALUES OF A SINGLE NAMED PARAMETER:
> [snip]
Because the form fields are many and variable - and configurable - the
original loop was a panacea for the all of the fields.

>
> If I were you, I would try something like:
>
> @stuff = $q->param('whatever_the_name_of_the_parameter_is');
>
> you are doing the evil

Not a very robust generic solution, I accept!

> ${$stuff} = $q->param($stuff};
>
> which is always a scalar. And a global one for that. A scalar cannot
> hold multiple values. Just one.
Clearly, I need to know (and the configurer does provides me with this)
which fields are lists, and treat these accordingly.

It's a question of minimal change to inherited code for now.
Now that I know a bit more about Perl, I accept that I have to localise
variables.
Since it's an application with a global namespace convention (yuk!) - and
not yet modular,
I don't want to rock the boat (yet) for code that appears to work, but
thanks for the direction.






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

Date: Fri, 10 Nov 2000 10:17:30 -0000
From: "Alan Dougall (ntl)" <abaltd@ntlworld.com>
Subject: Re: how do I process multiple selections?
Message-Id: <PXPO5.384$SI1.5344@news6-win.server.ntlworld.com>

<nobull@mail.com> wrote in message news:u9r94lb995.fsf@wcl-l.bham.ac.uk...

> If you want to be able to store multiple values you'll have to store
> them in a fashion that accomodates multiple values.  You can do this
> by storing in an array, in the keys of a hash or in a scalar using the
> join() function to convert the list of values into a delimited string.
>
> If you don't want massive debugging and security problems then ditch
> the symbolic references and use a single hash.  If you really want
> separate variables for each parameter then at the very least use a
> separate namespace (package).
>
> For example:
>
> my @stuff = $q->param;
> foreach my $stuff (@stuff) {
>    s/\'//g for @{"Stuff::$stuff"} = $q->param($stuff); # In package
Stuff::
>    s/\'//g for @{$stuff{$stuff}} = $q->param($stuff); # In hash %stuff
> }
Advice accepted - must plan to localise these!

> > Any tips?
>
> You may want to take a look at the import_names() and Vars() methods
> in CGI.pm since off-the-shelf solutions are usually preferable to
> wheel-reinvention.
I'm looking now...

> You should also get into the habit of using my() to limit the scope of
> all temporary variables to the block of code where the are used.
> Putting "use strict" will tell Perl to throw an exception you when
> you've forgotten[1] my() or used a symbolic reference.  If you need to
> use a sybolic reference then put "no strict 'refs'" in the block where
> you use the sybolic reference.
>
> Enabling warnings also helps.
>
> [1] But don't get complacent - it can't tell you when you've put the
> my() in too wide a scope.
Thx for all of the tips.






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

Date: Fri, 10 Nov 2000 10:52:03 -0000
From: "Alan Dougall (ntl)" <abaltd@ntlworld.com>
Subject: Re: how do I process multiple selections?
Message-Id: <FuQO5.475$SI1.2702@news6-win.server.ntlworld.com>

> I'm not sure that's the best way to start a CGI script - I would
> place the expected parameters into scalars or arrays manually. Using
> these symbolic references is disallowed by "use strict" and it is
> considered safer and generally better style to use strict, so that's
> another reason you might wish to avoid them. The third reason not to
> use this code is that you are discarding all but the first value of
> multiple selections, which is what your question is about.

Thanks, James - not quite ready to "use strict" - but I'll get there...

Presumably (when the code is cleaned up) I just put:

use strict;

in the script, or have I missed something?

--
Alan Dougall
alan.dougall@virgin.net
http://start.at/the.cross




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

Date: Fri, 10 Nov 2000 07:49:26 GMT
From: pelle1970@my-deja.com
Subject: Re: How to force MSDOS window to stay open after perl?
Message-Id: <8ug9a5$dp5$1@nnrp1.deja.com>

In article <8emm0t88nr6c1sebl0vrm1k5kfaq34dv31@4ax.com>,
  Stephen <st@nospam.prnet.hhrnet.jp> wrote:
> I am runnig ActiveState Perl on Win98. When I click on a perl file
> (*.plx), it would execute the script in a popup msdos window. But as
> soon as it finishes, the msdos window would close, making it too fast
> for me to read the output. How do you tell msdos window to stay open
> after executing the Perl script?

Besides changing the properties of the DOS-Window (which is off-topic
here), you could wait for some input in your perl-script. For example
wait for someone pressing the enter key.

Bye,
Carsten.


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


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

Date: Fri, 10 Nov 2000 18:29:41 +1000
From: "ccj" <mediamas@labyrinth.net.au>
Subject: Install mod on Win32 with nmake
Message-Id: <8ug846$bce$1@arachne.labyrinth.net.au>

Hi
I'm trying to install a module in win32 but get this message

D:\temp>nmake xmltodbms.pm
xmltodbms.pm(27) : fatal error U1035 : syntax error : expected ':' or'='
separator
Stop.

Direction deeply appreciated

Thanks
CCJ




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

Date: Fri, 10 Nov 2000 08:23:27 GMT
From: xzhang3388@my-deja.com
Subject: my.cgi.suspended
Message-Id: <8ugb9t$g20$1@nnrp1.deja.com>

I have some perl cgi scripts which simply read some data files and then
display a html page. Those cgi scripts usually work OK, but sometimes
after an execution the web server (on UNIX) renames the executed script
with extension ".suspended".

Once this happens, the system persistently does this (to the same
script) for  hours -- even when I rename it back to original name
manually, the system will add the  ".suspended" extension it again
within
seconds.

What could be the cause and how to prevent this? Thanks in advance.

Best regards

Xiaogang


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


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

Date: Fri, 10 Nov 2000 16:29:36 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: NT4 - How do I display the current userid?
Message-Id: <MPG.147632cff4e8adf898988e@localhost>

Philip Garrett wrote ..
>Bill Border <bill_border@agilent.com> wrote in message
>news:8uchnf$f7k$1@nonews.col.hp.com...
>> Hi All,
>>
>> I am running a Perl pgm that is invoked from a unix server (with
>> the resource kit rsh nt daemon) and in order to get an ODBC
>> Oracle application to work, I need to know what USERID it my
>> task is running under.
>>
>> The $> variable returns 0.     ??????
>
>From perldoc win32:
>
> Win32::LoginName()
>     [CORE] Returns the username of the owner of the current perl
>     process.
>
>For some reason, the Win32 module documentation isn't in the toc frame of my
>ActiveState documentation, but I knew I had seen it before somewhere else.
>Anyway, just "use Win32;", and then Win32::LoginName() will be what you're
>looking for.

you should be able to find it in the Pod section of that TOC

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Fri, 10 Nov 2000 10:01:43 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: OOP and information hiding
Message-Id: <sshn0ts8hic2f95ditltob8g20u89jdfpt@4ax.com>

Damian Conway wrote:

>This is still "privacy by convention", which is no privacy at all.

That's what I call "perlish".  ;-)

-- 
	Bart.


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

Date: Fri, 10 Nov 2000 10:48:58 +0000
From: "Graham Ashton" <graham@coms.com>
Subject: Re: Perl and mysql
Message-Id: <3qQO5.1203$L14.4741@news.colt.net>

In article <8u8m7k$4vh$1@nnrp1.deja.com>, "vivekvp" <vivekvp@spliced.com>
wrote:

> What I am trying to do is create an html form that gets, a unique ID,
> name, phone number and email - store that data, and be able to retrieve
> that data via any query.

You want to have a read of the docs for the DBI and DBD::mysql modules.
You can find them here:

  http://www.symbolstone.org/technology/perl/DBI/

> But I am not sure what any syntax would be used?  How do I pass the
> data?  How do I retrieve it?

Have you done any SQL? Once you've connected to your database (the docs
tell you how) you'll get a database handle. Then you can do things like:

  # Prepare statement ready for execution.
  #
  # The question marks are placeholders; often a good idea to use them.
  # See the docs for more.
  #
  my $sth = $dbh->prepare(q{
      INSERT
        INTO mytable (unique_id, name, phone_number, email)
      VALUES (?, ?, ?, ?)
  });

  $sth->execute($id, $name, $phone_number, $email);

You should have just inserted a row into "mytable".

I always like to set the database handle ($dbh) to raise fatal errors if
it runs into problems. Then you can wrap the above in an eval block to
trap the error and take appropriate action.

So how do you pull it out again? If you want just one record you can say:

  my $sth = $dbh->prepare(q{
      SELECT name, phone_number
        FROM mytable
       WHERE unique_id = ?
  });
  $sth->execute($id_that_i_want);

If you want them all, ordered by name (sorry, straying off topic into SQL
here):

  my $sth = $dbh->prepare(q{
      SELECT name, phone_number
        FROM mytable
    ORDER BY name
  });

  while (my ($name, $phone_number) = $sth->fetchrow)) {
      print "name: $name\tnumber: phone_number\n";
  }

There are other ways of fetching rows. They're in the DBI docs. By the
way, all the above is untested.

--
graham


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

Date: 10 Nov 2000 06:46:46 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Please teach how to read binary data in Perl language.
Message-Id: <8ug5km$phk$3@bob.news.rcn.net>

OJA <naoto21@cronos.ocn.ne.jp> wrote:
> The following is my program.
> #!C:/Perl/bin/perl

A -w and a use strict; would be appreciated here.

> binmode FH;
> binmode FH2;

As Mark-Jason pointed out, you need to do these *after* opening the files.

> open FH,"<test.jpg";

*Always*, yes *always*, check the result of an attempt to open a file, and
display an informative (i.e. including $!) diagnostic if the attempt
fails.

> @stat = stat FH;
> read FH,$data,$stat[7];

Unless this is part of some longer code that really needs more information
about the file than its size, you can just use the -s file test operator
here.

> open FH2,">test2.jpg";
> printf FH2 "$data";

Don't use printf when the first argument can contain binary data; if there
are percent-signs in the data, printf will try to interpret them, mangling
the results.  Use print, and don't needlessly quote variables.



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

Date: Thu, 9 Nov 2000 18:36:48 GMT
From: Ray Lopez <ray.a.lopez2@boeing.com>
Subject: Problem with String Substitution
Message-Id: <3A0AEEC0.84D1C60A@boeing.com>

I am trying to search multiple HTML files across multiple directories
and replace a string "XXXX" with another string.  I believe that I am
spanning the directories/files correctly, but the substitution seems to
be failing.  Can someone point out what I may be doing wrong?

#####################################################

$string = "somestring";
opendir(DIR, $dir) or die "Can't open $dir: $!";

while ( defined($file = readdir(DIR)) ) {
    $file =~ s/XXX/$string/g;
    #print "$file\n";
}

closedir (DIR);

######################################################




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

Date: Fri, 10 Nov 2000 09:42:51 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Problem with String Substitution
Message-Id: <slrn90nh5n.nv4.rgarciasuarez@rafael.kazibao.net>

Ray Lopez wrote in comp.lang.perl.misc:
>I am trying to search multiple HTML files across multiple directories
>and replace a string "XXXX" with another string.  I believe that I am
>spanning the directories/files correctly, but the substitution seems to
>be failing.  Can someone point out what I may be doing wrong?
>
>#####################################################
>
>$string = "somestring";
>opendir(DIR, $dir) or die "Can't open $dir: $!";
>
>while ( defined($file = readdir(DIR)) ) {
>    $file =~ s/XXX/$string/g;

$file is a file name. You need to open the file for reading, open a new
file for writing, copy the old file to the new file (substituting you
string), close the files, unlink the old file, and rename the new file to
the old file.

You also need to test that $file is a regular file. Note that the path
to $file is "$dir/$file" and not simply $file (this is a well-known
mistake), so the test will look like
  if (-f "$dir/$file") {
    open FILE, "$dir/$file" or die...
    ...
  }

If you want to process recursively directories, use the File::Find
module instead of opendir().

If you're on Unix, or if you have Unix command-line utilities installed,
all those steps can be summarized in one useful shell command :

find /base/directory -type f | xargs perl -pi.bak -e 's/XXX/string/g'

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Fri, 10 Nov 2000 10:43:10 +0000 (UTC)
From: real.email@signature.this.is.invalid (Csaba Raduly)
Subject: Re: Q: Getting program line number?
Message-Id: <8FE866D90quuxi@194.203.134.135>

A million monkeys weren't enough! It took mgjv@tradingpost.com.au
(Martien Verbruggen) on 07 Nov 2000 to produce
<slrn90gv5j.7ck.mgjv@verbruggen.comdyn.com.au>: 

>On Tue, 7 Nov 2000 18:10:27 +0000,
>     James Taylor <james@NOSPAM.demon.co.uk> wrote:
>> In article <slrn90g3l3.boe.mgjv@martien.heliotrope.home>, Martien
>> Verbruggen 
>><URL:mailto:mgjv@tradingpost.com.au> wrote:
>>>
>>> Perl. Perl. Perl. Perl. Perl. Perl. Perl.
>>> or perl if you talk about the program. If you want to program in
>>> it, please get used to spelling the name correctly.
>> 
>> I agree that this oft repeated mistake is irritating, but given
>> that the name Perl is supposed to be an acronym I can also see
>> some validity in spelling it PERL.
>
>You might feel that, but, in fact, there isn't. Perl isn't an
>acronym. Any acronymity[1] has been retrofitted to match the name. 

It's a backronym then (as defined in the Jargon file)
This often leads to acronymous disputes :-)

[snip]
>
>Martien
>
>[1] Yes, I made that word up.


-- 
Csaba Raduly, Software Developer (OS/2), Sophos Anti-Virus
mailto:csaba.raduly@sophos.com      http://www.sophos.com/
US Support +1 888 SOPHOS 9      UK Support +44 1235 559933
Life is complex, with real and imaginary parts.


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

Date: Fri, 10 Nov 2000 07:11:29 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: qx(...&); hangs program
Message-Id: <slrn90n89t.ncj.rgarciasuarez@rafael.kazibao.net>

pelle1970@my-deja.com wrote in comp.lang.perl.misc:
>or: Do I really need to fork?
>
>Hello everyone,
>
>(Running on Linux)
>I have a perl-script that watches a bunch of programs and restarts them
>in case any of them stops running. This script contains a line like this
>one:
>
>qx(/MyDir/MyExec $MyArray[$MyIdx] MyParams
>2>/MyLogDir/err$MyArray[$MyIdx] &);
>
>now when that line gets executed, the perl-script waits for the result
>of MyExec.

In fact, it waits for the shell that executes MyExec to terminate.

>I don't need that, since these Execs are supposed to be
>running forever (which IS the reason that I check if they are truly
>running). Is there any way to just start the program without checking on
>it? I'd like to avoid forks!!! (and I don't really care if the attempt
>to start the program is successful)

If you want to restart a program, you'll have to use fork and exec.
Example :
  my $pid = fork;
  defined $pid or die "Can't fork : $!\n";
  $pid or exec("/MyDir/MyExec ....");

>P.S. I read about exec and system, but both seem to wait for the output
>of the executed program, right? - That doesn't help me.

system() waits for the executed program to terminate. exec() *replaces*
the currently executing perl process by the executed program : the perl
script terminates if the exec() call is successful.

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Fri, 10 Nov 2000 14:37:22 +0600
From: "Konstantin Stupnik" <skv@iis.nsk.su>
Subject: Re: qx(...&); hangs program
Message-Id: <8ugc28$1blu$1@nl.novosoft.ru>



"Rafael Garcia-Suarez" <rgarciasuarez@free.fr> wrote in message
news:slrn90n89t.ncj.rgarciasuarez@rafael.kazibao.net...
> pelle1970@my-deja.com wrote in comp.lang.perl.misc:
> >or: Do I really need to fork?
> >
> >Hello everyone,
> >
> >(Running on Linux)
> >I have a perl-script that watches a bunch of programs and restarts them
> >in case any of them stops running. This script contains a line like this
> >one:
> >
> >qx(/MyDir/MyExec $MyArray[$MyIdx] MyParams
> >2>/MyLogDir/err$MyArray[$MyIdx] &);
> >
> >now when that line gets executed, the perl-script waits for the result
> >of MyExec.
>
> In fact, it waits for the shell that executes MyExec to terminate.
>
> >I don't need that, since these Execs are supposed to be
> >running forever (which IS the reason that I check if they are truly
> >running). Is there any way to just start the program without checking on
> >it? I'd like to avoid forks!!! (and I don't really care if the attempt
> >to start the program is successful)
>
> If you want to restart a program, you'll have to use fork and exec.
> Example :
>   my $pid = fork;
>   defined $pid or die "Can't fork : $!\n";
>   $pid or exec("/MyDir/MyExec ....");

I'm afraid this will not help much.
Parent will wait for all childs completition
before it will be finished.
You need to daemonize forked process
to make it independent from it's parent.

perldoc -q daemon

> >P.S. I read about exec and system, but both seem to wait for the output
> >of the executed program, right? - That doesn't help me.
>
> system() waits for the executed program to terminate. exec() *replaces*
> the currently executing perl process by the executed program : the perl
> script terminates if the exec() call is successful.
>
> --
> # Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/

--
Best regards,
  Konstantin.
Brainbench MVP for perl.




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

Date: Fri, 10 Nov 2000 09:29:27 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: qx(...&); hangs program
Message-Id: <slrn90ngcj.npa.rgarciasuarez@rafael.kazibao.net>

Konstantin Stupnik wrote in comp.lang.perl.misc:
>
>
>"Rafael Garcia-Suarez" <rgarciasuarez@free.fr> wrote in message
>news:slrn90n89t.ncj.rgarciasuarez@rafael.kazibao.net...
>> pelle1970@my-deja.com wrote in comp.lang.perl.misc:
>> >or: Do I really need to fork?
>> >
>> >Hello everyone,
>> >
>> >(Running on Linux)
>> >I have a perl-script that watches a bunch of programs and restarts them
>> >in case any of them stops running. This script contains a line like this
>> >one:
>> >
>> >qx(/MyDir/MyExec $MyArray[$MyIdx] MyParams
>> >2>/MyLogDir/err$MyArray[$MyIdx] &);
>> >
>> >now when that line gets executed, the perl-script waits for the result
>> >of MyExec.
>>
>> In fact, it waits for the shell that executes MyExec to terminate.
>>
>> >I don't need that, since these Execs are supposed to be
>> >running forever (which IS the reason that I check if they are truly
>> >running). Is there any way to just start the program without checking on
>> >it? I'd like to avoid forks!!! (and I don't really care if the attempt
>> >to start the program is successful)
>>
>> If you want to restart a program, you'll have to use fork and exec.
>> Example :
>>   my $pid = fork;
>>   defined $pid or die "Can't fork : $!\n";
>>   $pid or exec("/MyDir/MyExec ....");
>
>I'm afraid this will not help much.
>Parent will wait for all childs completition
>before it will be finished.

I didn't include a wait() in my example. But I should have written
  $SIG{CHLD} = 'IGNORE';
before the fork to avoid zombies.

>You need to daemonize forked process
>to make it independent from it's parent.

The forked process is no longer a perl process when the exec() call has
been executed. If the original program is intended to restart daemons,
it's possible that the exec()uted program will daemonize itself.

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: 10 Nov 2000 05:39:31 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: ref & regexp's don't mix in 5.6?
Message-Id: <8ug1mj$4f1$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Noboday at Lucasfilm 
<nb@no.where>],
who wrote in article <3A0B7EF2.FD16F51F@no.where>:
> my $a = 'abc';
> my $b = \$a;
> print "b is: $b\n";  # Prints SCALARetc
> 
> $b=~/.*/;
> print "what matched: $&\n"; # Prints SCALARetc
> my $c = $b =~ /^SCALAR/;
> print "what is c: $c\n";  # $c==1 in 5.004, but is undef in 5.6.0

I thought this was fixed in 5.6.0, but apparently it was not.  [my
fault, btw.  Wanted to fix all the glitches during the public
beta-cycle, but there was not one...]

Ilya


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

Date: Fri, 10 Nov 2000 16:46:29 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: ref & regexp's don't mix in 5.6?
Message-Id: <MPG.147636bd85059dc2989891@localhost>

Noboday at Lucasfilm wrote ..
>I know the proper way of finding the type of a reference is to use "ref"
>
>Saying that, I came across some code that worked in 5.004_04 but not in
>5.6.0- can someone explain to me what's going on here?
>
>thanks,
>-y
>
>#!/usr/bin/perl
>my $a = 'abc';
>my $b = \$a;
>print "b is: $b\n";  # Prints SCALARetc
>
>$b=~/.*/;
>print "what matched: $&\n"; # Prints SCALARetc
>my $c = $b =~ /^SCALAR/;
>print "what is c: $c\n";  # $c==1 in 5.004, but is undef in 5.6.0

you've got something wrong .. it's 1 in my 5.6.0

  NT4 SP6a Perl 5.6.0 build 616

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Fri, 10 Nov 2000 10:59:27 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: ref & regexp's don't mix in 5.6?
Message-Id: <d5ln0tcqq1ea7slm7pig7au04rji8le8pn@4ax.com>

Noboday at Lucasfilm wrote:

>my $c = $b =~ /^SCALAR/;
>print "what is c: $c\n";  # $c==1 in 5.004, but is undef in 5.6.0

Same here (IndigoPerl 5.6.0). What fixes it, is putting the $b between
quotes:

 my $c = "$b" =~ /^SCALAR/;

-- 
	Bart.


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

Date: Fri, 10 Nov 2000 16:43:18 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: Returning variable from PM
Message-Id: <MPG.147635fe2774ffa989890@localhost>

spcman@my-deja.com wrote ..
>Hey guys, i have a question.  I want to send variables to a perl
>module, have the perl module run some code then return a value back to
>the main cgi program.  Im relativly new to cgi learning by cut/paste
>and tearing code apart.  I cannot figure out the correct way to return
>a value.
>
>Heres some basic code...
>
> uses template

'uses' is not a Perl function

module names should begin with capital letters unless they're pragma 
style modules such as 'strict' and 'vars'

each statement in Perl must end in a semi-colon

> $RunTemplate = New template;

it is bad form having your 'new' function begin with a capital letter

> $RunTemplate -> SetVariables(\%VarValues);
> $RunTemplate -> ProcessTemplate(\$FileName);
>
>I want the template.pm to return a value to the program.
>Example...  $RunTemplate = ReturnValue();
>
>Any help appreciated. - Al

take a look at the perlmod section of the documentation

  perldoc perlmod

and the perlboot would also help

  perldoc perlboot

to learn more about the perldoc utility type the following on the 
command line

  perldoc perldoc

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Fri, 10 Nov 2000 16:38:07 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: Secured http ( https)
Message-Id: <MPG.147634c9b1b6e91c98988f@localhost>

Carl Wu wrote ..
>I wonder is it possible to user perl to automate the https transaction.
>Consider the following we normally do using a web browser:
>  A broker's web page requires username and password, after you login you
>can download some stock data. The CGI scripts use https protocol.
>
>My question is: Can this process be automated using Perl (on Linux) ?
>
>Any help greatly appreciated!

  http://search.cpan.org/

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Fri, 10 Nov 2000 09:04:26 +0000
From: fergus@twig.demon.co.uk (Fergus McMenemie)
Subject: Using Perl OLE to edit acrobat annotations.
Message-Id: <1ejvbxt.111zsk2badhfkN%fergus@twig.demon.co.uk>

Hello,

I have a cover page containing a number of annotations, 
lib-number, title etc that should be visable to the user.
These annotations appear as simple text strings on the 
cover page.

I wish to set the value of these annotations via a DB
routine. However I cant the OLE method setContents to
work. What is going wrong?

  $acrobat=Win32::OLE->new("AcroExch.App");
  $doc=Win32::OLE->new("AcroExch.PDDoc");
  $doc->open($filename);

  $page= $doc->AcquirePage(0);
  $acount=$page->GetNumAnnots();
  print "This page has $acount annotations\n";

  for ($c=0; $c < $acount; $c++) {
    $a =  $page->GetAnnot($c);
    $alabel =  $a->GetTitle();
    $a->SetContents( $labels{$alabel} );
    print "Setting $alabel to ",$labels{$alabel},"\n";
    }

The GetTitle() works but the SetContents() call appears
to have no effect when I look at the saved file. Other
changes I make at the same time are saved to the new
file OK.

Any ideas or comments? 


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

Date: Fri, 10 Nov 2000 11:03:36 GMT
From: quite@dial.pipex.com (Aandi Inston)
Subject: Re: Using Perl OLE to edit acrobat annotations.
Message-Id: <3a0bd593.61315110@reading.news.pipex.net>

fergus@twig.demon.co.uk (Fergus McMenemie) wrote:

>Hello,
>
>I have a cover page containing a number of annotations, 
>lib-number, title etc that should be visable to the user.
>These annotations appear as simple text strings on the 
>cover page....

>The GetTitle() works but the SetContents() call appears
>to have no effect when I look at the saved file. Other
>changes I make at the same time are saved to the new
>file OK.

Are your annotations simple text annotations? Unintuitively,
annotations of type "text" are the simple "post-it" variety. They are
definitely NOT annotations of text on the page - which are of type
"FreeText".
---------------------------------------
Aandi Inston  quite@dial.pipex.com
Imposition and booklets for PDF - http://www.quite.com/imposing/


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

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


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