[17551] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4971 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 27 06:05:34 2000

Date: Mon, 27 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: <975323111-v9-i4971@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 27 Nov 2000     Volume: 9 Number: 4971

Today's topics:
    Re: Any Method for copying files to multiple servers. <schwern@pobox.com>
    Re: Backtick problems on Windows98 (Villy Kruse)
    Re: Can you check File Size Before Storing (Tad McClellan)
    Re: Can't install modules in ActiveStates v5.6.0 for Wi <graham@letsgouk.com>
    Re: Check File Size (Tad McClellan)
    Re: desperate pls help me! <bart.lateur@skynet.be>
    Re: Help Needed: SORT function (Tad McClellan)
    Re: Imbedding POD in script? <zardoz@infoserve.net>
    Re: Mime type - Binary File <jeff@vpservices.com>
    Re: Perl beginner (Joe Smith)
        Perl modules for Win32 <mg@mail.magelan.ru>
        Perl modules for Win32 <mg@mail.magelan.ru>
    Re: Perl modules for Win32 <jeff@vpservices.com>
    Re: Perl not executing from Cron job <paul@NOSPAM.multibase.com.au>
    Re: Perl not executing from Cron job (Brian)
    Re: Perl not executing from Cron job (Chris Fedde)
    Re: Perl not executing from Cron job <paul@NOSPAM.multibase.com.au>
        Perl, Mysql and large datasets <hazi@blackeyes.org>
    Re: Perl, Mysql and large datasets (Abigail)
    Re: Perl, Mysql and large datasets <hazi@blackeyes.org>
    Re: sending a signal to a process which I don't own <nospam@jsoft.xs4all.nl>
    Re: setuid/setgid with perl? (Villy Kruse)
        Should { } always indicate a scope? <johnlin@chttl.com.tw>
    Re: Should { } always indicate a scope? nobull@mail.com
    Re: Strange behavior from localtime() Oct31 2000 or lat (Joe Smith)
    Re: trim() equivalent in Perl? (Abigail)
    Re: trim() equivalent in Perl? (Abigail)
    Re: Unwanted Characters found in Script <friedman@math.utexas.edu>
    Re: Unwanted Characters found in Script <bart.lateur@skynet.be>
        What if $SIG{__DIE__} is occupied by other module? <johnlin@chttl.com.tw>
    Re: What if $SIG{__DIE__} is occupied by other module? nobull@mail.com
    Re: Will most servers know/have access to DATE-CALC and (Tad McClellan)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 27 Nov 2000 09:55:37 GMT
From: Michael G Schwern <schwern@pobox.com>
Subject: Re: Any Method for copying files to multiple servers.
Message-Id: <3A222FE7.42DA5D43@pobox.com>

David Riskind wrote:
> Challenge:
> Find all occurences of Oracle sqlnet client on all NT servers in 4 different
> workgroups, where account is trusted on some, and must logon to server on
> most.  Once found, copy sqlnet.ora and tnsnames.ora to a saved copy and
> replace with fresh copies of these 2 files.  Once copied, verify files are
> same as source.

Umm, why?  Sounds like an X/Y problem (ie. asking how to do X while
really needing to do Y).  I'm no Oracle DBA ($count = @blessings), but I
presume sqlnet.ora and tnsnames.ora contain some sort of
configuration/user information that you're trying to keep synchronized
across multiple machines.  There's gotta be a better way to do this.

First thing that comes to mind... with all the whiz-bang crap that
Oracle comes with, they've got to have a utility or technique to do this
for you.  Hit the books, call up tech support, hit the Oracle newsgroup
or find an Oracle guru and find out.

Failing that, you'll probably want your Oracle servers to pull the new
files rather than push.  Set up a cron job on each machine (or whatever
NT's idea of cron is) to scp (or whatever NT's idea of secure-copy is)
those files from a central file server.  This is a bit harder to set up
and maintain (as you have to maintain a cron job on all your Oracle
servers rather than just one) but its much more robust and much much
more secure.  The idea of thrashing about your network looking for
Oracle servers and overwriting their configuration files just seems wrong.

Another idea is to have all your Oracle machines mount some central
network drive and read their .ora info off of that.


PS  Come to the next Pittsburgh.pm meeting.


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

Date: 27 Nov 2000 10:20:26 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: Backtick problems on Windows98
Message-Id: <slrn924dba.3rq.vek@pharmnl.ohout.pharmapartners.nl>

On 26 Nov 2000 07:30:05 GMT, Joe Smith <inwap@best.com> wrote:
>In article <8uhmr7$g11$1@newstoo.ericsson.se>,
>Peter Lerup <peter.lerup@ecs.ericsson.se> wrote:
>>Yes, well the strange thing is that on the machines where the backticks did
>>work, NAV was also installed. Not to sure about possible differences in
>>program versions though, but will check.
>
>If Norton AntiVirus is installed, and it is configured to look for
>viruses in memory, and you use backticks or system() in perl, then
>strange things happen.  Including four quick accesses to the A: drive
>for no apparent reason.  Disabling scan-for-viruses-in-memory changes
>the symptoms.



Wonder why this happens.  We are not using Norton, but Mcafee but we
still get these unexplained access to the floppy drive, also when opening
the command as a pipe as in: "open (PIPE 'command |');"



Villy


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

Date: Sun, 26 Nov 2000 23:46:58 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Can you check File Size Before Storing
Message-Id: <slrn923pq2.cdd.tadmc@magna.metronet.com>

BUCK NAKED1 <dennis100@webtv.net> wrote:

>Now, can I
>get an answer? 


Sheesh!

Your followup to yourself was 2 hours after you asked the
original question.

It may take 2 *days* for your question to get to some people.

Then hours or days for the answer to come back to you.

That's how Usenet works.

Wait at least a *week* before asking the same question over again.
( and first check:     http://www.plover.com/~mjd/perl/Questions.html)

If you need answers faster than that, then Usenet is not
the right place. Go find someplace else (like IRC or hire
a contractor).

If you need answers in the *least possible* amount of time,
then read the docs that came with the software that you
are using!

You could have answered this yourself in about 30 seconds.

It probably took you longer than 30 seconds to type in your Usenet post!


Work smart. Use the docs.


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 27 Nov 2000 08:13:56 +0000
From: Graham Stow <graham@letsgouk.com>
Subject: Re: Can't install modules in ActiveStates v5.6.0 for Win32
Message-Id: <rWwgFDAEfhI6Ewll@letsgouk.com>

>Certainly ppm is the way to go for modules that have a ppd prepared for
>them.  Certainly you should use it when you can.  I assumed you would
>know that since it is promeninetly mentioned in the basic documentation
>for ActivePerl.
There's so much info out there - I work on a need-to-know basis

>But there are many many modules that do not have a ppd and can not be
>installed using ppm.  Those modules can be installed (depending on their
>requirements) either with just nmake or with some version of make and a
>C++ compiler *if* one is not using  a defective build of ActiveState. 
>The error message you showed is a documented bug in earlier ActiveState
>builds and prevents any use of make or its relatives.  That bug will go
>away if one upgrades the version of ActiveState.  It is also related to
>other bugs in the build so there are other reasons to upgrade.  Just
>because you found a way around the particular problem that brought that
>bug to your attention does not mean that the bug has disappeared or that
>it will not bite you in some other form later.
>
OK Jeff - I'm sold!
Any particular version/build you recommend?
-- 
Graham Stow


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

Date: Sun, 26 Nov 2000 23:39:03 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Check File Size
Message-Id: <slrn923pb7.cdd.tadmc@magna.metronet.com>

BUCK NAKED1 <dennis100@webtv.net> wrote:

>I'm trying to check the size of a file from user input, before allowing
>it to be stored. In this instance, if it's over 12K, I want it to print
>a message that the "directory is full". 
>
>I'm using CGI qw(param). Also, I'm  using LWP/Simple
                                           ^^^^^^^^^^

   perldoc LWP::Simple

       ...

       head($url)
          Get document headers. Returns the following 5 values if
          successful: ($content_type, $document_length,
                                      ^^^^^^^^^^^^^^^^
                                      ^^^^^^^^^^^^^^^^
          $modified_time, $expires, $server)

          Returns an empty list if it fails.  In scalar context
          returns TRUE if successful.


( my underlining )


Puhleeze check the docs before posting here.

I'd rather not put you back in my "special file"  :-)

('cause "second timers" are in there for good)


>What am I doing wrong? 


Using code without reading the documentation for the code you are using.

Stop that!


>$file = "\.\./TEMP/temp_file"; 
          ^ ^
          ^ ^

Those backslashes serve no purpose, and so should not be there.


>### check filesize
>while (<$URL*>) { 


You should use the named version like the docs say to:

while ( glob "$URL*" ) {  


>     $filesize+=-s $_; 


Space characters are not a scarse resource. Feel free to use
all you want to help make your code more readable.

   $filesize += -s $_;

File tests (like -s) only work on files. You are not working
with files. You are working with URLs. A URL is not a file.


>Please help. ... and thanks.


You better start helping yourself damn quick.

We are not here to read the docs to you.


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 27 Nov 2000 08:56:23 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: desperate pls help me!
Message-Id: <a9742tk20thkanmu13r63hfsis3ha05n15@4ax.com>

M Lambert wrote:

>Im trying to write a cgi that will allow users to run a reporting tool and
>have the report emailed to them... the problem is the reports can take up to
>3 hours to generate.  How do I background a process in Perl that will allow
>users to visit a cgi and leave while the pro finoishes up without them...

What I would do is:

 * fork

 * Let the parent return the CGI, "Your request has been submitted"

 * Let the child first close off STDERR and STDOUT, so the webserver no
longer expects any output from it, and then, through exec(), start up
the external program.

That's it. If you want to see the source for similar scripts, look at
<http://web.stonehenge.com/merlyn/WebTechniques/>, Randal uses such
tricks on a regular basis.

But I wouldn't ignore the advice of Joe Smith. If a report takes hours
to generate, the risk of overloading your server with having too many
reports generated at the same time, is very real. These should be
queued, and limited to at most a few at the same time. Gee, I think you
need something like a spooler.

-- 
	Bart.


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

Date: Sun, 26 Nov 2000 23:22:45 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help Needed: SORT function
Message-Id: <slrn923ocl.cdd.tadmc@magna.metronet.com>

Genesis Montano <genesis@magictraders.com> wrote:

>Please email me back at genesis.montano@intel.com


Why?

If we did that then only one person has access to the answer.

If we post here then thousands of people get to see it.

Hoarding answers is selfish.

Let the answers be public.

Ask it here, get the answer here (maybe).


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 27 Nov 2000 06:43:47 GMT
From: Una Personn <zardoz@infoserve.net>
Subject: Re: Imbedding POD in script?
Message-Id: <3A22038D.9F8CCEC@infoserve.net>

POD is a little finicky, you have to have a completely blank line (not
even a space)
before and after each =pod and =cut.  I have a 5Kb perl template which is
a complete
POD example for a perl module, if anyone wants it, send me an email at
zardoz@infoserve.net

Chas Friedman wrote:

> I thought that if I put text in a script (say "test.pl") surrounded by
> "=pod" and "=cut", then
> "perldoc test.pl" would extract and exhibit this. I've never been able
> to get anything like
> this to work (usually get a message that no documentation was found;
> also the directories searched
> don't seem to include the one containing test.pl, and I can't seem to
> make this included.)
> Any comments/suggestions would be much appreciated! Thanks in advance!
>                                                           chas friedman





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

Date: Sun, 26 Nov 2000 21:21:45 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Mime type - Binary File
Message-Id: <3A21EF69.4BBCF471@vpservices.com>

[please put your response below a suitably trimmed version of the thing
you are responding to, thanks]

h wrote:
> 
> This information uses a specific mime type with a particular format. We have
> seen the header format for the mime type but would like to see an example
> with appropriate data to illustrate the format more effectively to us.

Perl only does what you tell it to.  If you want to tell it to do
something that will make a server or a browser behave a certain way,
then you first need to find out what the server or the browser needs to
be told, and then have Perl tell it that.  Ask in newsgroup about
servers or browsers to find out that information.
 
> > The instruction from NEtscape are as follows...
> > application/x-netscape-autoconfigure-dialer-v2

Haven't you already answered your own question?  That looks like the
Mime type right there. So you need to open or create the binary data,
then print the data along with that Mime type as a content header like
this:

my $file_content = $however_you_get_the_binary_data;
my $mime_type = "application/x-netscape-autoconfigure-dialer-v2";
binmode STDOUT;
print "Content-type: $mime_type\n\n$file_content";

-- 
Jeff


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

Date: 27 Nov 2000 06:37:04 GMT
From: inwap@best.com (Joe Smith)
Subject: Re: Perl beginner
Message-Id: <8vsveg$2ekd$1@nntp1.ba.best.com>

In article <8vciav$kjs$1@bob.news.rcn.net>,
David Marvil <captmarvil@rcn.com> wrote:
>Thanks to all of those that were kind enough to help. Some day I hope to be
>able to do the same. This is what I ended up with.
>#!/usr/bin/perl -w
>open (FILE, "/user_info2")||die "File not found:$!";
> while (<FILE>) {
> chomp;
> ($name, $netbios) = split (/\s+-\s+/,$_);
> $a{$name} = $netbios;
>}
>print "Enter user name: ";
> chomp ($user = <STDIN>);
> $name = $user;
>if (keys(%a)) {
> print "$name\t$a{$name}\n";
>}

It is not appropriate to use keys(%a) there.

Those last three lines should be:
  if (exists $a{$name}) {
    print "$name\t$a{$name}\n";
  } else {
    print STDERR "Name '$name' not found\n";
  }
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Mon, 27 Nov 2000 08:34:10 +0300
From: "Yoom" <mg@mail.magelan.ru>
Subject: Perl modules for Win32
Message-Id: <8vss3r$1v1$1@news247.cnt.ru>

Hi group,

I would appreciate if you advise where can i find FREE Perl modules such as
DBI and CGI for Win32


Yoom

mg@mail.magelan.ru




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

Date: Mon, 27 Nov 2000 08:46:26 +0300
From: "Yoom" <mg@mail.magelan.ru>
Subject: Perl modules for Win32
Message-Id: <8vss40$1v1$2@news247.cnt.ru>

Hi group,

I would very appreciate if you advise where can i find FREE Perl modules
such as DBI and CGI for Win32


--
Yoom

yoom@hotmail.ru




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

Date: Sun, 26 Nov 2000 22:05:43 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Perl modules for Win32
Message-Id: <3A21F9B7.E6693B99@vpservices.com>

Yoom wrote:
> 
> Hi group,
> 
> I would appreciate if you advise where can i find FREE Perl modules such as
> DBI and CGI for Win32

If you are using anything other than activePerl, get it from
http://www.activestate.com/.  Then use the PPM module that comes with it
to download and install DBI and other precompiled modules for Win32. 
You don't need to download CGI.pm, it comes pre-installed with
activePerl.  If you don't know how to use PPM, see 

http://velocity.activestate.com/docs/ActivePerl/faq/ActivePerl-faq2.html

p.s. if you voted for Tudor you can't have my advice, please give it
back.

-- 
Jeff


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

Date: Mon, 27 Nov 2000 15:27:35 +1000
From: "Paul Mulloni" <paul@NOSPAM.multibase.com.au>
Subject: Re: Perl not executing from Cron job
Message-Id: <3a21f0c4@grissom>

Absolutely.... The first thing I checked.


Randy Harris <harrisr@bignet.net> wrote in message
news:t23p1dgt6b7k85@corp.supernews.com...
> Paul Mulloni <paul@NOSPAM.multibase.com.au> wrote in message
> news:3a21b2e1@grissom...
> > Hello all,
> > System:
> >     Red hat 6.1
> >     Perl 5.005_03
> >
> > The perl script will execute from the command line but when the perl
> scripts
> > is run from a cron job it does not work.  It looks like it wants to
> run the
> > script file using the /usr/sh shell instead of the perl shell even
> though
> > the "#!/usr/bin/perl" line is set. I have found that a SHELL
> environment
> > variable can be set within the cron job so setting it  to
> "/usr/bin/perl"
> > has the perl script working to a certain extent.  When this is set
> then the
> > perl script is executed as if the -c option is set so it does not
> actually
> > execute the script only compiles it!!!
> >
> > Not sure why this is happening??
> >
> > Paul.
> >
>
> Perhaps an obvious question...  Are you certain that the #!/usr/bin/perl
> is on the very first line of your program file?
>
>
>
>




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

Date: Mon, 27 Nov 2000 05:32:28 GMT
From: pontz@channel1.com (Brian)
Subject: Re: Perl not executing from Cron job
Message-Id: <3a21f0d3.27807986@news.ne.mediaone.net>

On Mon, 27 Nov 2000 11:03:32 +1000, "Paul Mulloni"
<paul@NOSPAM.multibase.com.au> wrote:

>The perl script will execute from the command line but when the perl scripts
>is run from a cron job it does not work.  It looks like it wants to run the
>script file using the /usr/sh shell instead of the perl shell even though
>the "#!/usr/bin/perl" line is set.

Make sure the file is chmoded correctly. It needs to executable if
running from a cron.
chmod 755 filename
depending on who you want to be able to execute it.

Brian


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

Date: Mon, 27 Nov 2000 06:23:07 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Perl not executing from Cron job
Message-Id: <f5nU5.95$QX6.179510784@news.frii.net>

In article <3a21b2e1@grissom>,
Paul Mulloni <paul@NOSPAM.multibase.com.au> wrote:
>Hello all,
>System:
>    Red hat 6.1
>    Perl 5.005_03
>
>The perl script will execute from the command line but when the perl scripts
>is run from a cron job it does not work.  It looks like it wants to run the
>script file using the /usr/sh shell instead of the perl shell even though
>the "#!/usr/bin/perl" line is set. I have found that a SHELL environment
>variable can be set within the cron job so setting it  to "/usr/bin/perl"
>has the perl script working to a certain extent.  When this is set then the
>perl script is executed as if the -c option is set so it does not actually
>execute the script only compiles it!!!
>
>Not sure why this is happening??
>

This sounds like realy broken behavior.  Can you post an example of what our
crontab line looks like?  

Thanks
chris
-- 
    This space intentionally left blank


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

Date: Mon, 27 Nov 2000 17:38:59 +1000
From: "Paul Mulloni" <paul@NOSPAM.multibase.com.au>
Subject: Re: Perl not executing from Cron job
Message-Id: <3a220f90@grissom>

This is the cron job entry.

SHELL="/usr/bin/perl"
* * * * * /usr/local/ereport/burst.pl

The crontab enrty is created under the user ereport.  If the SHELL variable
is missing the cron job produces an error.

Sample "burst.pl"
******************************
#!/usr/bin/perl
#
# This module takes format reports from system inbox,
# rewrites them to common format,
# and distributes to mailboxes named by referrer codes
#

my $user        = getlogin;
my $home        = "/home/$user";
my $mailprog    = "/usr/bin/mail";
my $mailcmd     = "$mailprog -u $user";
my $nocode      = "nocode";
my $prefix      = "02";
my $tempfile    = "$home/report.tmp";

sub get_message1 {
        return `echo t 1 | $mailcmd`;
};

sub move_message1 {
        my $name = shift(@_);
        `rm $name`;
        return `echo w 1 $name | $mailcmd`;
};

# my stuff
`echo $home >> /log.txt`;

while (my $message = get_message1)
{
        move_message1($tempfile);

        my $report = `/usr/local/ereport/qxr.rewrite.perl`;
#       `rm $tempfile`;

#       my $datestamp = `date`;
#       chomp $datestamp;
#       $report = "From burstmail.perl $datestamp\n" . $report;

        my ($field1, $field2) = split /refcode:/, $report;
        ($field1, $field2) = split /\n/, $field2;

        my $mailbox;

        if ($field1) {
                $mailbox = $field1;
        } else {
                $mailbox = $nocode;
        };
        $mailbox =~ s/ //g;     # remove blanks
        $mailbox = "m_$mailbox";

#       # normalise numbers
#       $fax =~ s/ //g; # remove blanks
#       if ($fax) {
#               if ((substr $fax, 0, 1) ne '0') {
#                       $fax = $prefix . $fax;
#               };
#       } else {
#               $fax = $nofax;
#       };

#       my $mbox = "$mboxroot$mailbox";
#
#       open MBOX, ">>$mbox" or die;
#       flock MBOX, 2;
#       seek MBOX, 0, 2;        # in case someone appended
#
#
#       print MBOX "$report\n";
#
#       flock MBOX, 8;
#       close MBOX;

        open MAILER, "| /usr/bin/mail $mailbox" or die "cannot fork
/usr/bin/mail";
        print MAILER "$report\n" or die "cannot forward report to $mailbox";
        close MAILER or die;
};

****************************
End sample



Chris Fedde <cfedde@fedde.littleton.co.us> wrote in message
news:f5nU5.95$QX6.179510784@news.frii.net...
> In article <3a21b2e1@grissom>,
> Paul Mulloni <paul@NOSPAM.multibase.com.au> wrote:
> >Hello all,
> >System:
> >    Red hat 6.1
> >    Perl 5.005_03
> >
> >The perl script will execute from the command line but when the perl
scripts
> >is run from a cron job it does not work.  It looks like it wants to run
the
> >script file using the /usr/sh shell instead of the perl shell even though
> >the "#!/usr/bin/perl" line is set. I have found that a SHELL environment
> >variable can be set within the cron job so setting it  to "/usr/bin/perl"
> >has the perl script working to a certain extent.  When this is set then
the
> >perl script is executed as if the -c option is set so it does not
actually
> >execute the script only compiles it!!!
> >
> >Not sure why this is happening??
> >
>
> This sounds like realy broken behavior.  Can you post an example of what
our
> crontab line looks like?
>
> Thanks
> chris
> --
>     This space intentionally left blank




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

Date: Mon, 27 Nov 2000 10:16:01 +0100
From: Hazi Gharagozlou <hazi@blackeyes.org>
Subject: Perl, Mysql and large datasets
Message-Id: <3A222651.A7E0F264@blackeyes.org>

I have finally gotten things under control (CGI, Perl and Mysql) what a
diffrent world from Client-Server database application development.

However I will thank anybody in advance if they can shed light on how to
handle large datasets.

In the past I controlled the result of a query by using database
cursors. From my understanding Mysql does not support cursors and on top
of that the my Perl script is connected to the database while the script
is running. Once the page is on the client the database has been
disconneceted.

I have come with a solution of saving the query result on the server's
hard disk, but this seems to be a big waste of bandwidth if the user
decides to abandon the query after the first page.

Thanks in advance

hazig@compuserve.com / hazi@Blackeyes.org

Nature, and Nature's Laws lay hid in night
God said, Let Newton be! and All was Light.



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

Date: 27 Nov 2000 10:29:22 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Perl, Mysql and large datasets
Message-Id: <slrn924ds2.kvs.abigail@tsathoggua.rlyeh.net>

On Mon, 27 Nov 2000 10:16:01 +0100, Hazi Gharagozlou (hazi@blackeyes.org) wrote in comp.lang.perl.misc <URL: news:<3A222651.A7E0F264@blackeyes.org>>:
++ I have finally gotten things under control (CGI, Perl and Mysql) what a
++ diffrent world from Client-Server database application development.
++ 
++ However I will thank anybody in advance if they can shed light on how to
++ handle large datasets.

Well, if I would have to handle large datasets, I wouldn't be using mysql.

++ In the past I controlled the result of a query by using database
++ cursors. From my understanding Mysql does not support cursors and on top
++ of that the my Perl script is connected to the database while the script
++ is running. Once the page is on the client the database has been
++ disconneceted.

Cursors are *not* the way to handle large datasets. Avoid cursors
at all costs if performance is an issue. 

++ I have come with a solution of saving the query result on the server's
++ hard disk, but this seems to be a big waste of bandwidth if the user
++ decides to abandon the query after the first page.

"abandon the query after the first page"? What do you mean with that?



Abigail


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

Date: Mon, 27 Nov 2000 11:55:26 +0100
From: Hazi Gharagozlou <hazi@blackeyes.org>
Subject: Re: Perl, Mysql and large datasets
Message-Id: <3A223D9E.B2662B2D@blackeyes.org>

Thanks for the reply. I am not going to debate the merits of Mysql (your comments are deja on record).

Let's say that my dataset returns between 200 to 300 records (thumbnails of pictures included) My script does a count of the number of records and
determins that all the records will be over 20 html pages. Next I execute the query and have all the dataset stored in an array and proceed to do next
and previous page navigation. I would think this is a big waste of bandwidth if the user decides that what he or she is looking is on the first page.

Maybe I am hoping but I am looking for a more elegant solution.

Abigail wrote:

> On Mon, 27 Nov 2000 10:16:01 +0100, Hazi Gharagozlou (hazi@blackeyes.org) wrote in comp.lang.perl.misc <URL: news:<3A222651.A7E0F264@blackeyes.org>>:
> ++ I have finally gotten things under control (CGI, Perl and Mysql) what a
> ++ diffrent world from Client-Server database application development.
> ++
> ++ However I will thank anybody in advance if they can shed light on how to
> ++ handle large datasets.
>
> Well, if I would have to handle large datasets, I wouldn't be using mysql.
>
> ++ In the past I controlled the result of a query by using database
> ++ cursors. From my understanding Mysql does not support cursors and on top
> ++ of that the my Perl script is connected to the database while the script
> ++ is running. Once the page is on the client the database has been
> ++ disconneceted.
>
> Cursors are *not* the way to handle large datasets. Avoid cursors
> at all costs if performance is an issue.
>
> ++ I have come with a solution of saving the query result on the server's
> ++ hard disk, but this seems to be a big waste of bandwidth if the user
> ++ decides to abandon the query after the first page.
>
> "abandon the query after the first page"? What do you mean with that?
>
> Abigail



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

Date: Wed, 22 Nov 2000 09:48:39 +0100
From: "Willem Joosten" <nospam@jsoft.xs4all.nl>
Subject: Re: sending a signal to a process which I don't own
Message-Id: <8vg1b8$e18$1@news.tudelft.nl>


"Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
news:slrn91ltfd.r2.mgjv@verbruggen.comdyn.com.au...

> Another solution would be to have the CGI fork a child that does the
> processing, and dissociate that child fromt he parent. Of course, the
> CGI user would need write permissions anywhere that it needs them.

Two reasons I don't like this approach. The persmissions and I want to be
able to run the 'deamon' on a console to see what it's doing. Can this be
done from a forked process?

> I do suppose you've taken care of the possibility that while you're
> processing some other CGI process tries to update the file again? It
> sounds like you probably have, but I thought I'd just put up a warning
> flag :)

Yep have some experience in multithreaded programming on Win32 using C++.
Have learned some good things while completely locking up my machine :)

> create a named pipe
> make sure permissions are sufficient for CGI user to write to it
> while (! end)
> {
> read (blocking) a line from the pipe
> open the text file for read
> LOCK_SH the text file
> PROCESS
> close text file
> }

This is pretty much what my first version looked like. The problem is that I
must be able to interrupt the processing update the text file and continue
or restart the processing depending on what has changed.

Version two forks and the child will loop a read on the FIFO (don't ask why
it's called FIFO :). Only took me two hours to find out the filehandle for
the named pipe is no longer valid when the write has closed it :)

Raw version of version 2 (no locking etc)

$SIG{'HUP'} = 'setfileupdate';

my $childpid = fork();
die "Can't fork, reason $!" unless defined $childpid;
if($childpid){
 # we're the player
 while (! $stopped){
  if($updatefile){
   reloadfile();
   # processing in blocks
  }
  sleep 1;
 }

} else {
 # we're the child so wait for some input and signal parent
 while(! $stopped){
  open FIFO, "< playerd.fifo" or die "Can't open playerd.fifo for reading,
reason $!";
  my $line = <FIFO>; # blocking
  print "Line: $line -\n";
  kill ('HUP', $parentpid);
  close FIFO;
  sleep 1;
 }
}

waitpid($childpid, 0);
$SIG{'HUP'} = 'DEFAULT';



Willem Joosten




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

Date: 27 Nov 2000 10:35:40 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: setuid/setgid with perl?
Message-Id: <slrn924e7r.3rq.vek@pharmnl.ohout.pharmapartners.nl>

On Sun, 26 Nov 2000 21:23:27 GMT, Garry Williams <garry@ifr.zvolve.net> wrote:
>On Sun, 26 Nov 2000 19:33:18 +0100, Marten Lehmann <lehmann@cnm.de>
>wrote:
>>I'm looking for a solution to use the standard system functions setuid
>>and setgid as known from C and C++. The functions themselves with the
>>same name doesn't exist in perl, 
>
>But they do.  See the POSIX manual page.  
>


The POSIX::setuid workd differently from the C function setuid().  Don't
know if that was by mistake of intentionally.

In C the setuid() function sets the effective user id, and if run as 
superuser it sets the real user id as well in such a way that super
user privileges is permanently lost.

In Perl the POSIX:setuid function attempts to set the real user id,
but on some systems this isn't allowed by the kernel.


Also check the variables $( and $).  Usualy you need to set both
simultaniously to accomplish the same as the C function setuid() does
for example:

  ( $(, $) ) = ($newuid, $newuid);

But this doesn't work identically on all systems.


Villy


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

Date: Mon, 27 Nov 2000 12:03:16 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Should { } always indicate a scope?
Message-Id: <8vsuo2$s0m@netnews.hinet.net>

Dear all,

For the lines of code:

    sub foo { 1..10 }
    my ($a,$b) = (my @x = foo)[3,4];
    print "$a $b $x[5]\n";

I wrote an equivalent array-reference version:

    sub foo { [1..10] }
    my ($a,$b) = @{my $x = foo}[3,4];
    print "$a $b $$x[5]\n";

and got an error message when use strict:

    Global symbol "$x" requires explicit package name at line 3.

I just need the @{} for coercing, but it forms a scope and make
"my $x" invisible from outside.  Personally I think it is not reasonable.

Just like

    my $x = { 2 => my $a = 1 };
    print $x->{ my $b = 2 };
    print $a,$b;

The $a,$b are still visible outside.
For what benefit is @{} designed like this?  (Is it documented?)

Thank you.

John Lin





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

Date: 27 Nov 2000 08:51:45 +0000
From: nobull@mail.com
Subject: Re: Should { } always indicate a scope?
Message-Id: <u91yvxenfi.fsf@wcl-l.bham.ac.uk>

"John Lin" <johnlin@chttl.com.tw> writes:

> I just need the @{} for coercing, but it forms a scope and make
> "my $x" invisible from outside.  Personally I think it is not reasonable.

I'm sure as many people would find the opposite unreasonable.  I
sometimes write code with @{ } surrounding several lines. I would
upset if it didn't act as a BLOCK.

> For what benefit is @{} designed like this?

There are enough distinct syntactic elements that use {} in Perl
syntax already we don't need another.  The {} in @{} is syntactically
either a BLOCK or an identifier.  If we were to adopt your syntax then
it would be yet another distinct syntactic element.

> (Is it documented?)

Have you not looked at the manual where the @{} syntax is introduced?

perldoc perlref/"Using References" method 2:

       2.  Anywhere you'd put an identifier (or chain of
           identifiers) as part of a variable or subroutine name,
           you can replace the identifier with a BLOCK returning
           a reference of the correct type.

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


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

Date: 27 Nov 2000 06:36:22 GMT
From: inwap@best.com (Joe Smith)
Subject: Re: Strange behavior from localtime() Oct31 2000 or later
Message-Id: <8vsvd6$2ejt$1@nntp1.ba.best.com>

In article <3A1899E8.2A52537A@bellsouth.net>,
Matt  <softh@bellsouth.net> wrote:
>with a localtime() parsing script to determine dates for use in an array
>... But dang if things
>don't seem to fall apart on/around Halloween 2000.

What do you mean "fall apart"?  I ran your script, and could not
see any problems with 31-Oct-2000 nor with 31-Oct-2001.

(home/inwap) inwap@shell3% perl test2.pl
Sat Jan  1 06:00:01 2000 946706401 +30 years 2000 New Year Time
Sat Jan  1 12:00:00 2000 946728000 +30 years
Tue Oct 31 18:31:00 2000 973017060 +30 years 2001 Oct 31 10:31am PST
Sun Dec 31 18:00:00 2000 978285600 +31 years
Sat Sep  1 06:00:01 2001 999324001 +31 years 2001 Sep 01 (86400x31=2678400)
Mon Oct  1 06:00:01 2001 1001916001 +31 years 2001 Oct 01 (86400x30=2592000)
Thu Nov  1 05:53:21 2001 1004594001 +31 years 2001 Nov 01 (86400x31=2678400)
Sat Dec  1 05:53:21 2001 1007186001 +31 years 2001 Dec 01 (86400x30=2592000)
(home/inwap) inwap@shell3% cat test2.pl
#!/usr/local/bin/perl5
$ENV{TZ} = "GMT";
while (<DATA>)  {
   ($DateString, $Interval) = split(/::/, $_ );
   {$Date=localtime($DateString)};
   print "$Date $DateString $Interval";
}
__DATA__
946706401::+30 years 2000 New Year Time
946728000::+30 years
973017060::+30 years 2001 Oct 31 10:31am PST
978285600::+31 years
999324001::+31 years 2001 Sep 01 (86400x31=2678400)
1001916001::+31 years 2001 Oct 01 (86400x30=2592000)
1004594001::+31 years 2001 Nov 01 (86400x31=2678400)
1007186001::+31 years 2001 Dec 01 (86400x30=2592000)



What exactly are you seeing that you think is wrong?
	-Joe
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: 27 Nov 2000 10:18:24 GMT
From: abigail@foad.org (Abigail)
Subject: Re: trim() equivalent in Perl?
Message-Id: <slrn924d7g.ipn.abigail@tsathoggua.rlyeh.net>

On Tue, 21 Nov 2000 10:49:29 -0500, Jeff Pinyan (jeffp@crusoe.net) wrote in comp.lang.perl.misc <URL: news:<Pine.GSO.4.21.0011211021200.714-100000@crusoe.crusoe.net>>:
++ On Nov 21, Tom Christiansen said:
++ 
++ >    $string = join(" ", split(" ", $string));
++ >
++ >which is like
++ >
++ >    for ($string) {
++ >	s/^\s+//;
++ >	s/\s+$//;
++ >	s/\s+/ /g;
++ >    } 
++ 
++ I'm just pedantic here, but I prefer
++ 
++   tr/\n\r\f\t / /s;
++ 
++ to
++ 
++   s/\s+/ /g;
++ 
++ in most cases.


I wouldn't. It would require to memorize what \s is. While doable for 
ISO 8859, it wouldn't for Unicode.

s/\s+/ /g; should work fine with UTF8, tr/\n\r\f\t / /s; will fail.



Abigail


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

Date: 27 Nov 2000 10:22:25 GMT
From: abigail@foad.org (Abigail)
Subject: Re: trim() equivalent in Perl?
Message-Id: <slrn924df1.ipn.abigail@tsathoggua.rlyeh.net>

On Mon, 20 Nov 2000 13:00:28 +0930, Wyzelli (wyzelli@yahoo.com) wrote in comp.lang.perl.misc <URL: news:<pQ0S5.24$Is1.2514@vic.nntp.telstra.net>>:
++ 
++ Well that is a different fish altogether.
++ 
++ $string= 'This is a great newsgroup';
++ $chars = $string =~ tr/a-zA-Z/a-zA-Z/;
++ print $chars;
++ 
++ 
++ $chars now has the number of characters in the string, excluding spaces
++ and all other things.  Fast too.


a-zA-Z are only 52 letters. There are a lot more. Even with ISO 8859.


Abigail


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

Date: Sun, 26 Nov 2000 23:21:02 -0600
From: Chas Friedman <friedman@math.utexas.edu>
Subject: Re: Unwanted Characters found in Script
Message-Id: <3A21EF3E.97CA5CA8@math.utexas.edu>

"Return" characters on Windows machines are printed as ^M in many editors (can
be seen using vi in binary
mode, for example.) I have noticed that C source code written on a Windows
machine which is pasted into
a file on a Linux system (or FTP'd using binary mode) sometimes won't compile
until the ^M's are removed.
The same may well be true for Perl code.
This can be confusing since these characters are invisible in some contexts.
Pasting from a browser may
cause them to be displayed as you indicated, and such pasted text sometimes has
other whitespace such as
tabs imbedded.
           chas friedman

jelly belly wrote:

> Just an oddity that perhaps a few of you have noticed before;
>
> I just imported two scripts;  one is a .cgi and the other a .pl file.  Both
> were cut 'n' pasted from a browser.  When they didn't work properly on the
> Windows server, I moved them to a Linux box.  Before setting permissions,
> though, I noticed that each script had a strange carriage-return character ~
> an underscored capital-M   at the end of each line.  Once these characters
> were removed from all 150 lines, the scripts worked well.
>
> I'm sure this is not new to the folks in this newsgroup.  Any comments would
> be welcome.
>
> Kev
>
> --
> www.workmonster.bc.ca



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

Date: Mon, 27 Nov 2000 10:15:18 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Unwanted Characters found in Script
Message-Id: <9fc42t038tekdc3i9u8e7gje416or46oju@4ax.com>

jelly belly wrote:

>I just imported two scripts;  one is a .cgi and the other a .pl file.  Both
>were cut 'n' pasted from a browser.  When they didn't work properly on the
>Windows server, I moved them to a Linux box.  Before setting permissions,
>though, I noticed that each script had a strange carriage-return character ~
>an underscored capital-M   at the end of each line.  Once these characters
>were removed from all 150 lines, the scripts worked well.

It could be that you just didn't swicth to Ascii mode before FTP'ing
your script to the Unix server. It could also be that there is more to
it than just that: often, stuff (text or html) you get through a
browser, contains TWO CR's for each NL. And it could just be that that
second CR is the reason why it fails.

I think that newer versions of perl (5.6) may be more tolerant for this
superfluous junk. I'm not sure.

Anyway: I have a little .BAT file on my Win98 PC, which I put in the
SendTo menu in c:\windows. That way, you can "drop" a downloaded text
file on the script, by rightclicking on the file, and selecting this BAT
file in the "Send To..." menu. It deletes this extra junk. In addition,
it can turn Unix bare linefeeds into CRLF pairs. This is the whole
script:

	@perl -wpi.bak -e "tr/\r//d" %1

(as I said: save this as a ".BAT" file)

On PC-Win32, the -i option doesn't work properly without extension. SO
you always get a backup file.

But at least, long file names are preserved, for the final file -- not
for the backup file.

-- 
	Bart.


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

Date: Mon, 27 Nov 2000 10:08:50 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: What if $SIG{__DIE__} is occupied by other module?
Message-Id: <8vsuo0$s0m@netnews.hinet.net>

Dear all,

My problem can be narrowed down to three lines of code:

    use DBI;
    $SIG{__DIE__} = sub { print "@_ to log file" and exit };
    my $db = DBI->connect('dbi:Oracle:mydatabase','scott','tiger');

I got the following error message:

    Can't locate SetDualVar.pm in @INC (@INC contains: [snip])
    at D:/Perl/site/lib/Win32/TieRegistry.pm line 42.

If I remove my $SIG{__DIE__}, the error is gone.  But I really need
to catch the __DIE__ exceptions.  What shall I do?

Thank you.

John Lin






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

Date: 27 Nov 2000 08:46:36 +0000
From: nobull@mail.com
Subject: Re: What if $SIG{__DIE__} is occupied by other module?
Message-Id: <u93dgdeo13.fsf@wcl-l.bham.ac.uk>

"John Lin" <johnlin@chttl.com.tw> writes:

> Dear all,
> 
> My problem can be narrowed down to three lines of code:
> 
>     use DBI;
>     $SIG{__DIE__} = sub { print "@_ to log file" and exit };
>     my $db = DBI->connect('dbi:Oracle:mydatabase','scott','tiger');
> 
> I got the following error message:
> 
>     Can't locate SetDualVar.pm in @INC (@INC contains: [snip])
>     at D:/Perl/site/lib/Win32/TieRegistry.pm line 42.
> 
> If I remove my $SIG{__DIE__}, the error is gone.  But I really need
> to catch the __DIE__ exceptions.  What shall I do?

eval{} is the proper (stackable) way to catch exceptions.

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


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

Date: Sun, 26 Nov 2000 23:50:56 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Will most servers know/have access to DATE-CALC and DATE-MANIP?
Message-Id: <slrn923q1g.cdd.tadmc@magna.metronet.com>

Alan Mailer <clarityassoc@earthlink.net> wrote:

>Please excuse the complete naivete of this question but:  since I may be
>deploying my perl scrips on a Unix based web server... am I able to assume
>that most servers know how to deal with my use of the Calc and Manip
>modules?


Doesn't matter. 

If they don't have it, you can install it (if you have shell access).

Perl FAQ, part 8:

   "How do I keep my own module/library directory?"


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

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


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