[18107] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 267 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 10 21:05:40 2001

Date: Sat, 10 Feb 2001 18:05:10 -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: <981857110-v10-i267@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 10 Feb 2001     Volume: 10 Number: 267

Today's topics:
    Re: Archive::Zip - any user comments? <tfbiv@SPAMMENOTerols.com>
    Re: chown not allowed (Abigail)
    Re: chown not allowed (Chris Fedde)
    Re: copy all files to remoteserver folder <a246456@fmr.com>
    Re: Devel DProf and " dprofpp " <callgirl@la.znet.com>
    Re: How to map (undef,undef) to (), but (undef,$y) to ( <rick.delaney@home.com>
        How to Script Interaction with POST Form? koyot@my-deja.com
    Re: How to Script Interaction with POST Form? <kstep@pepsdesign.com>
    Re: How to send HTML email from Perl using CGI <theaney@toadmail.toad.net>
        Make it stop... bakor@my-deja.com
    Re: Make it stop... <mcnuttj@nin.iats.missouri.edu>
    Re: Make it stop... (Steven Smolinski)
    Re: Modules/Constants. (Martien Verbruggen)
    Re: Modules/Constants. (Abigail)
        NDBM_File and ndbm.h <tanase_costin@my-deja.com>
        Newbie to perl... <fail00@hotmail.com>
    Re: Perl and database (Tarael200)
    Re: Perl and database (Chris Fedde)
    Re: Perl and Networking (Tarael200)
    Re: Perl and Networking (Chris Fedde)
    Re: Regular Expression Question (Craig Berry)
    Re: undef ? (Garry Williams)
    Re: use pack() to uuencode long strings? <nospam.newton@gmx.li>
    Re: who is responsible ? <steve@peachy.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 10 Feb 2001 15:46:45 -0500
From: Tom Bates <tfbiv@SPAMMENOTerols.com>
Subject: Re: Archive::Zip - any user comments?
Message-Id: <h1ab8tcqt36o1qd7mpebd6pslgvtsf0hud@4ax.com>

I just tried using this module today, and have had problems. If I zip
an Access database with WinZip, the unzip in Archive::Zip creates a
corrupt database. It's short by about 2%, with all compression methods
except "none".

Have you noticed any problems?

Tom

On Thu, 11 Jan 2001 15:27:04 -0000, "Geoff Winkless"
<geoff-at-farmline-dot-com@127.0.0.1> wrote:

>Has anyone any idea how good Archive::Zip is - it's only at 0.09 which
>doesn't instil huge amounts of confidence, but then it hasn't changed since
>May - which probably either means it's working ok or the author has given up
>on it (!!)
>
>Ta
>
>Geoff
>



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

Date: 10 Feb 2001 21:37:28 GMT
From: abigail@foad.org (Abigail)
Subject: Re: chown not allowed
Message-Id: <slrn98bd4o.656.abigail@tsathoggua.rlyeh.net>

Bart Lateur (bart.lateur@skynet.be) wrote on MMDCCXX September MCMXCIII
in <URL:news:s58a8t4v63ns0g4s9hs98ebmc0qq5kbm4q@4ax.com>:
?? Abigail wrote:
?? 
?? >Make sure you never have to create a new file. Have two files, say,
?? >'fnord' and 'frobnitz', and a symlink 'current'. Let current point
?? >to one of the files. You reading processes read from 'current'.
?? >Your writing program writes whatever file isn't pointed to by current.
?? >If the writer is done, flip the symlink.
?? 
?? The problem is that you cannot create a symlink that already exists. So
?? you have to unlink it first. In that regard, the problem is similar to
?? Chris Fedde's solution.

There is more than one way to flip a symlink. Assume for instance that
current now points to frobnitz.

     symlink "frobnitz", "new" or die $!;
     rename  "new", "current"  or die $!;

?? A second problem they have in common, is that it may happen that two
?? consecutive updates come very fast, faster than one program needs to
?? finish to read and process the entire file. You'd end up writing over a
?? file that's still being read.

Well, yeah, there's a price to be paid somewhere.

You could of course just have a dbm file with the appropriate permission
and a garbage collection program.

Or a small suid program that creates a file with the appropriate permissions.

?? Oh, BTW: copying the file doesn't help, as it appears not to copy the
?? file permissions and file owner. Not with File::Copy, and not with `cp`.


Of course not.


Abigail
-- 
$" = "/"; split $, => eval join "+" => 1 .. 7;
*{"@_"} = sub  {foreach (sort keys %_) {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};


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

Date: Sat, 10 Feb 2001 21:39:12 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: chown not allowed
Message-Id: <4yih6.23$zN2.170596864@news.frii.net>

In article <s58a8t4v63ns0g4s9hs98ebmc0qq5kbm4q@4ax.com>,
Bart Lateur  <bart.lateur@skynet.be> wrote:
>Abigail wrote:
>
>A second problem they have in common, is that it may happen that two
>consecutive updates come very fast, faster than one program needs to
>finish to read and process the entire file. You'd end up writing over a
>file that's still being read.
>

This is the classic sutuation where a lock may be used to serialize access.  

Assuming the method that I proposed, the online writer would first
gain an exclusive lock on 'hidden' then do it's write into that
file, finally it would do the 3 step mv.  The lock goes away when
the handle is closed.

Readers should also get a shared lock on 'visible' while they are
reading it to prevent writers from gaining the exclusive lock till they
are all done reading it.  

A special case come up when two writers hit at the same time.  if
both readers open then block on an exclusive lock. The second to
achieve the lock will be writing to 'visible' rather than 'hidden'.
That's bad!  One partial solution to have the writer do a non
blocking call to flock.  If it achieves the lock all is good.  If
it fails then it can wait a few ms before trying again.

>
>Oh, BTW: copying the file doesn't help, as it appears not to copy the
>file permissions and file owner. Not with File::Copy, and not with `cp`.
>

It is important to note that both 'visible' and 'hidden' in the fedde
method must have the correct ownership and permissions from the beginning.
These files permissions are never changed.

Lets say that your new data is in a file called 'stuff' with arbitrary
permissions and ownership.  As long as the update process has permission to
write 'hidden' then cp of 'stuff' into 'hidden' will work without changing
'hidden's permissions.

If you are running under apache it might be worth while looking at the
suEXEC configuration so that your CGI programs can run as someone other
than the www user.  But that is a topic for a different news group.

chris
-- 
    This space intentionally left blank


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

Date: Fri, 09 Feb 2001 16:54:19 -0500
From: a246456 <a246456@fmr.com>
Subject: Re: copy all files to remoteserver folder
Message-Id: <3A84670B.AD430801@fmr.com>


--------------9DAC8C91EC69E2699E424833
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I have figured out the problem. I used system function to copy all
files. It works..



a246456 wrote:

> Hi,
>
>     I wrote a simple script which has to copy all files from my
> workstation folder to a remoteserver folder. I am getting a error
> message like "The process tried to write to a nonexistent page."
>
> No problem with creating directories. It works if i mention a single
> filename to copy instead of all files.
> Could you please tell me where i went wrong.
>
> Thanks in advance.
> -------------------------------------------------------------------
> open(LST, "srv.txt") || die "File does`nt exist:$!\n";
> open(RCMDFAIL, ">rcfail.txt") || die "can`t create file $!\n";
>       chomp($currentserver=<LST>);
>       while($currentserver ne "") {
>
>      print "Connecting to $currentserver....\n";
>
>  open(PATH, "rcmd \\\\$currentserver set|");  #it displays NT
> environment variables
>  chomp(@lines=<PATH>);
>
>  if (@lines[0] =~/^Error/)     #if it cannot connect to server.
>  {
>      print RCMDFAIL "$currentserver\n";
>  }
>
>             elsif(@lines[2] =~/^AGENTWORKS_DIR/)  #if it matches the
> appln path
>     {
>             ($agent,$dir) = split("=", @lines[2]);
>      ($drv,$pat) = split(":", $dir);     #looking for the $drv drive(C
> or D or E)
>     }
>
>
>  open(PACH1, "rcmd \\\\$currentserver md
> $drv:\\tng\\patches\\Lo76560|"); #create directory on remote server
>  open(PACH2, "rcmd \\\\$currentserver md
> $drv:\\tng\\patches\\Lo80699|");
>  open(PACH3, "rcmd \\\\$currentserver md
> $drv:\\tng\\patches\\Lo81246|");
>  open(CMD, "copy \\Lo76560\\*.\*
> \\\\$currentserver\\$drv\:\\tng\\patches\\Lo76560|"); #copy all files
> from this folder to remote server folder
>  open(CMD, "copy \\Lo80699\\*.\*
> \\\\$currentserver\\$drv\:\\tng\\patches\\Lo80699|");
>  open(CMD, "copy \\Lo81246\\*.\*
> \\\\$currentserver\\$drv\:\\tng\\patches\\Lo81246|");
>  print "successfully copied all patch files to the folders\n";
>
>        $currentserver=<LST>;
>      }
>  close PACH1;
>  close PACH2;
>  close PACH3;
>  close LST;
>  close CMD;
>  close RCMDFAIL;

--------------9DAC8C91EC69E2699E424833
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
I have figured out the problem. I used system function to copy all files.
It works..
<br>&nbsp;
<br>&nbsp;
<p>a246456 wrote:
<blockquote TYPE=CITE>Hi,
<p>&nbsp;&nbsp;&nbsp; I wrote a simple script which has to copy all files
from my
<br>workstation folder to a remoteserver folder. I am getting a error
<br>message like "The process tried to write to a nonexistent page."
<p>No problem with creating directories. It works if i mention a single
filename to copy instead of all files.
<br>Could you please tell me where i went wrong.
<p>Thanks in advance.
<br>-------------------------------------------------------------------
<br>open(LST, "srv.txt") || die "File does`nt exist:$!\n";
<br>open(RCMDFAIL, ">rcfail.txt") || die "can`t create file $!\n";
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chomp($currentserver=&lt;LST>);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while($currentserver ne "") {
<p>&nbsp;&nbsp;&nbsp;&nbsp; print "Connecting to $currentserver....\n";
<p>&nbsp;open(PATH, "rcmd \\\\$currentserver set|");&nbsp; #it displays
NT environment variables
<br>&nbsp;chomp(@lines=&lt;PATH>);
<p>&nbsp;if (@lines[0] =~/^Error/)&nbsp;&nbsp;&nbsp;&nbsp; #if it cannot
connect to server.
<br>&nbsp;{
<br>&nbsp;&nbsp;&nbsp;&nbsp; print RCMDFAIL "$currentserver\n";
<br>&nbsp;}
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elsif(@lines[2]
=~/^AGENTWORKS_DIR/)&nbsp; #if it matches the appln path
<br>&nbsp;&nbsp;&nbsp; {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
($agent,$dir) = split("=", @lines[2]);
<br>&nbsp;&nbsp;&nbsp;&nbsp; ($drv,$pat) = split(":", $dir);&nbsp;&nbsp;&nbsp;&nbsp;
#looking for the $drv drive(C or D or E)
<br>&nbsp;&nbsp;&nbsp; }
<br>&nbsp;
<p>&nbsp;open(PACH1, "rcmd \\\\$currentserver md $drv:\\tng\\patches\\Lo76560|");
<b>#create
directory on remote server</b>
<br>&nbsp;open(PACH2, "rcmd \\\\$currentserver md $drv:\\tng\\patches\\Lo80699|");
<br>&nbsp;open(PACH3, "rcmd \\\\$currentserver md $drv:\\tng\\patches\\Lo81246|");
<br>&nbsp;open(CMD, "copy \\Lo76560\\*.\* \\\\$currentserver\\$drv\:\\tng\\patches\\Lo76560|");

<b>#copy all files</b>
<br><b>from this folder to remote server folder</b>
<br>&nbsp;open(CMD, "copy \\Lo80699\\*.\* \\\\$currentserver\\$drv\:\\tng\\patches\\Lo80699|");
<br>&nbsp;open(CMD, "copy \\Lo81246\\*.\* \\\\$currentserver\\$drv\:\\tng\\patches\\Lo81246|");
<br>&nbsp;print "successfully copied all patch files to the folders\n";
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $currentserver=&lt;LST>;
<br>&nbsp;&nbsp;&nbsp;&nbsp; }
<br>&nbsp;close PACH1;
<br>&nbsp;close PACH2;
<br>&nbsp;close PACH3;
<br>&nbsp;close LST;
<br>&nbsp;close CMD;
<br>&nbsp;close RCMDFAIL;</blockquote>
</html>

--------------9DAC8C91EC69E2699E424833--



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

Date: Sat, 10 Feb 2001 14:05:27 -0800
From: Kira <callgirl@la.znet.com>
Subject: Re: Devel DProf and " dprofpp "
Message-Id: <3A85BB27.1EDB22AC@la.znet.com>

"Godzilla!" wrote:

(various snippage)
 
> * silently curses *

Indeed.

 
> I've figured out Devel DProf ok. It runs and
> produces a useless document, tmon.out .. whoopie.
 
> Documentation indicates to use dprofpp to
> attain useful information from tmon.out file.

> What is dprofpp and how is it invoked and used?


Thanks to those who responded with positive
helpful information pertaining to this thread.
I have found some solutions after gathering
documentation and giving thought to those
positive remarks presented by others.

I have made the following discoveries after
exhaustive research and testing.

Devel DProf will run from inside a script, much
like LWP or Socket. It produces tmon.out as
documented. However, its feature, dprofpp,
cannot be run inside a script, neither as a
script command line or as a system syntax call.

To run dprofpp, this must be done from a command
line screen. This is not documented as it should
be. In my case and for those using DOS, you must
move into the directory containing tmon.out, a
directory under your Perl or Apache, then type 
in as a command,

dprofpp -u

Results will be printed to your DOS screen.
As an example from my system:

C:/apache/users/test/>dprofpp -u

(ENTER)

Do note tmon.out must be in your current
directory being used for this command.

A related issue presented in this thread,
is Tom Christiansen's pod2html. My tests
reveal his module simply doesn't work as
currently documented. What causes this
failure, I don't know. I have no interest
in his module and did not research reasons
for this failure of his module. Although 
not documented by Christiansen, it could be
this is another module which can only be
run from a command line screen. Perhaps
there is nothing wrong with his module
but rather, he has failed to present
correct documentation for his module.

On documentation, it is clear to me within
all Perl documentation and module documentation
I have examined, which is in great numbers, none
of the authors are qualified documentarians.

With my background in science and English, I've
enjoyed many experiences documenting my own
in-lab experiments and my own field research.
I have also frequently documented science research
for some of my former professors, with delight.

Avoiding a long lecture on proper documentation
techniques, I will exemplify a documentation
feature, a critical never-to-violate rule, which
is missing in all Perl related documentation.

When you read a professionally edited and published
book on science, on technology, a caveat is to first
present Convention Parameters. You will see this as,

"Bold Face Text Means This."
"Italicized Text Means That."
"Parenthetical Text Means This And That."
"FUBAR means F'd Up Beyond All Recognition."

You will frequently note in some Perl related
documentation, the use of a dollar sign,

$ (some syntax to use)

A presumption could be made this is a Unix command
line prompt. It could also be presumed this is
part of the syntax. In all cases I have examined,
there are no Convention Parameters. There are no
notes on what this dollar sign represents.

For all documentation I have examined, there are
no notes on 'script enclosed' versus 'command line'
usage for syntax; Convention Parameters are missing.

Those two quick and simple examples indicate to me
personally, as a scientist, as an English professor
and as a published authoress, those writing documentation
for Perl and for modules are not qualified to do so.
In all cases I studied, one of the most important rules
of documentation, Convention Parameters, is violated.
This is inexcusable.

Thanks again to those who responded with friendly
and intelligent advice. I now have a solution thanks
to your insightful input.

Godzilla!


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

Date: Sun, 11 Feb 2001 00:55:00 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: How to map (undef,undef) to (), but (undef,$y) to (undef,$y)?
Message-Id: <3A85E622.9004482@home.com>

gnari@my-deja.com wrote:
> 
> In article <962fsr$h9o@netnews.hinet.net>,
>   "John Lin" <johnlin@chttl.com.tw> wrote:
> >
> > if(my $found = my($x,$y) = foo) { print "found: $x,$y" }

> actually it does not matter how much you change foo, as your problem
> is in your
>   $found = my($x,$y) = foo
> assignement
> 
> here you are assigning whatever foo returns to a list ($x,$y) which
> has always exacly 2 elements, although those can be undef
> so the $found = my($x,$y)  will return always

No.  From perldata:

       List assignment in a scalar context returns the number of
       elements produced by the expression on the right side of
       the assignment:
  
> you can test this by
> perl -e'@a=($x,$y)=();print @a."\n";'

You can't test it with that because that is list assignment in _list_
context which is a totally different animal.

You can test it with this:

  perl -e'$a=($x,$y)=();print $a."\n";'

As for the question in the subject:

    sub foo {
        defined && return @list for @list;
        return;
    }


-- 
Rick Delaney
rick.delaney@home.com


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

Date: Sat, 10 Feb 2001 23:43:09 GMT
From: koyot@my-deja.com
Subject: How to Script Interaction with POST Form?
Message-Id: <964jmd$sf8$1@nnrp1.deja.com>

Hello!

I need to periodically poll a cgi script on a remote machine, but the
script is only set up to take inputs via the POST method. Could someone
point me in the direction of a module, or perhaps example code, that
would allow me to set up the inputs to the script and retrieve the
results?

Thanks!

K


Sent via Deja.com
http://www.deja.com/


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

Date: Sat, 10 Feb 2001 20:05:07 -0500
From: "Kurt Stephens" <kstep@pepsdesign.com>
Subject: Re: How to Script Interaction with POST Form?
Message-Id: <964og2$5b1$1@slb4.atl.mindspring.net>

<koyot@my-deja.com> wrote in message news:964jmd$sf8$1@nnrp1.deja.com...
>
> I need to periodically poll a cgi script on a remote machine, but the
> script is only set up to take inputs via the POST method. Could someone
> point me in the direction of a module, or perhaps example code, that
> would allow me to set up the inputs to the script and retrieve the
> results?
>

Read the documentation for LWP::UserAgent and HTTP::Request::Common.

use strict;
use LWP::UserAgent;
use HTTP::Request::Common;

my $ua = LWP::UserAgent->new;
my $resp = $ua->request(POST 'http://somewhere/foo', [foo => bar, bar =>
foo]);

#
# Process $resp->content;
#

HTH,

Kurt Stephens





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

Date: 10 Feb 2001 16:16:18 -0500
From: Tim Heaney <theaney@toadmail.toad.net>
Subject: Re: How to send HTML email from Perl using CGI
Message-Id: <87vgqiqlwd.fsf@susie.watterson>


"Mark la mar" <whitevanman@btinternetREMOVE.com> writes:
> 
> Can somebody please help me with this one. I`m wanting to senda small email
> as HTML (just like Outlook does) using sendmail. I feel that sendmail isn`t
> helping me out here and wonder what else to try.

Try the MIME::Lite module. The documentation that comes with it
contains an example of how to send an HTML message.

  http://search.cpan.org/doc/ERYQ/MIME-Lite-2.106/lib/MIME/Lite.pm#Send_an_HTML_document_with_images_included_

Hope this helps,

Tim



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

Date: Sun, 11 Feb 2001 00:56:31 GMT
From: bakor@my-deja.com
Subject: Make it stop...
Message-Id: <964nvt$vos$1@nnrp1.deja.com>

Here is a snippet in my continuing journey to learn perl...

#!/usr/bin/perl -w

use strict;
my $formtitle;
my $d;
my $descr;

print "Enter the form title: ";
$formtitle=<>;
chomp $formtitle;

print "Enter a brief description: (3 lines max)\n";

for($d=0;$d<=2;$d++)
{
open(DESC,">>$formtitle.txt") or die "Can't write to $formtitle.txt:
$!";
$descr=<>;
print DESC $descr;
}
chomp $descr;

the question is : If the user wants to enter less than 3 lines, what do
I need to put in to make it stop, for instance, "press enter on a blank
line to end....etc ? I've had this problem in shell,C and now perl.
I've scoured docs everywhere...?!!



Sent via Deja.com
http://www.deja.com/


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

Date: 11 Feb 2001 01:35:44 GMT
From: Justin McNutt <mcnuttj@nin.iats.missouri.edu>
Subject: Re: Make it stop...
Message-Id: <964q9g$ik$2@dipsy.missouri.edu>

bakor@my-deja.com wrote:
> Here is a snippet in my continuing journey to learn perl...

> #!/usr/bin/perl -w

> use strict;
> my $formtitle;
> my $d;
> my $descr;

> print "Enter the form title: ";
> $formtitle=<>;
> chomp $formtitle;

> print "Enter a brief description: (3 lines max)\n";

> for($d=0;$d<=2;$d++)
> {
> open(DESC,">>$formtitle.txt") or die "Can't write to $formtitle.txt:
> $!";
> $descr=<>;
> print DESC $descr;
> }
> chomp $descr;

> the question is : If the user wants to enter less than 3 lines, what do
> I need to put in to make it stop, for instance, "press enter on a blank
> line to end....etc ? I've had this problem in shell,C and now perl.
> I've scoured docs everywhere...?!!

You should be able to do something like:

NAME: for($d=0;$d<=2;$d++)
 .
 .
 .
$descr=<>;
if ( $descr =~ /your "last line" pattern/ ) {
	last NAME; # This gets you out of loop NAME, or:
}

See 'last' and 'next' in 'man perlfunc' and check out the Loop Control
section of 'man perlsyn'.

--J



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

Date: Sun, 11 Feb 2001 01:45:47 GMT
From: sjs@linux.ca (Steven Smolinski)
Subject: Re: Make it stop...
Message-Id: <slrn98c070.48b.sjs@ragnar.stevens.gulch>

bakor@my-deja.com <bakor@my-deja.com> wrote:
> the question is : If the user wants to enter less than 3 lines, what do
> I need to put in to make it stop, for instance, "press enter on a blank
> line to end....etc ? I've had this problem in shell,C and now perl.
> I've scoured docs everywhere...?!!

In Perl, I generally make another exit at the top of the loop (i.e.,
before you do anything exciting with the input) with something like:

  last if $input_line =~ /^[.q]$/;

That would exit the loop if $input_line was a period character or a
lowercase q on a line all by itself.  You would, of course, have to
publicise this feature to your users. 

Code for an example follows:

#!/usr/local/bin/perl 

require 5.6.0;  # for warnings pragma, and 3-arg open.
use strict;
use warnings;

print qq[Enter some text, up to 3 lines.\n],
      qq[A period or 'q' alone on a line by itself also ends input.\n];

my $maxlines = 3;
open DESC, '>', 'temp' or die "Can't open temp: $!";

while ( <STDIN> ) {
	last if /^[.q]$/;
	print DESC;
	last if --$maxlines <= 0;
}

close DESC or die "Can't close temp? $!";
__END__

-- 
Steven Smolinski => http://www.steven.cx/


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

Date: Sun, 11 Feb 2001 09:44:34 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Modules/Constants.
Message-Id: <slrn98bh2i.vht.mgjv@martien.heliotrope.home>

On Fri, 09 Feb 2001 00:48:54 +0000,
	Kelly Dorset <dorsettest@uk.insight.com> wrote:
> 
> ok.  starting with the constants file (pebbleconst.pm): 

I haven't run your code, but one thing to notice:

> sub BEGIN {  

ITYM

BEGIN {
}

without the sub.

> BEGIN {   
> 	unshift (@INC, "./include");
> }

just like this one.

If all you do in here is change @INC, you should probably use the lib
pragma instead.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | That's funny, that plane's dustin'
Commercial Dynamics Pty. Ltd.   | crops where there ain't no crops.
NSW, Australia                  | 


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

Date: 11 Feb 2001 00:40:19 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Modules/Constants.
Message-Id: <slrn98bnrj.656.abigail@tsathoggua.rlyeh.net>

Martien Verbruggen (mgjv@tradingpost.com.au) wrote on MMDCCXX September
MCMXCIII in <URL:news:slrn98bh2i.vht.mgjv@martien.heliotrope.home>:
?? On Fri, 09 Feb 2001 00:48:54 +0000,
?? 	Kelly Dorset <dorsettest@uk.insight.com> wrote:
?? > 
?? > ok.  starting with the constants file (pebbleconst.pm): 
?? 
?? I haven't run your code, but one thing to notice:
?? 
?? > sub BEGIN {  
?? 
?? ITYM
?? 
?? BEGIN {
?? }
?? 
?? without the sub.

    sub BEGIN { ... }

is entirely correct. The keyword 'sub' is optional.



Abigail
-- 
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
                                      print } sub __PACKAGE__ { &
                                      print (     __PACKAGE__)} &
                                                  __PACKAGE__
                                            (                )


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

Date: Sat, 10 Feb 2001 21:26:10 GMT
From: Costin <tanase_costin@my-deja.com>
Subject: NDBM_File and ndbm.h
Message-Id: <964blc$ltc$1@nnrp1.deja.com>

 Hi,

 I create a data base with perl 5.005_03 using NDBM_File. When I try to
read it with a C program using ndbm.h I obtain  garbage.

 Could please someone tell me if this is something I should expect?
 Did anybody used ndbm files with perl and C and it worked?

 I run Solaris 8 on a sparc10,

 Thanks,
    Costin



Sent via Deja.com
http://www.deja.com/


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

Date: Sun, 11 Feb 2001 12:50:26 +1300
From: "fail006" <fail00@hotmail.com>
Subject: Newbie to perl...
Message-Id: <964k8f$91g$3@lust.ihug.co.nz>

Hi,
I would like write a small program in perl that will tell me the IP address
of my local machine....I am using redhat 7...
How do i go about this...?

Thanks





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

Date: 10 Feb 2001 19:59:07 GMT
From: tarael200@aol.com (Tarael200)
Subject: Re: Perl and database
Message-Id: <20010210145907.27413.00000239@ng-df1.aol.com>

No, that'd eat up an enormous amount of memory and CPU load depending on the
amount of data you're working with..

A more efficient way to do it, methinks, 
is to loop through the data using, maybe, nested whiles..

while ($hashref = $sth1->fetchrow_hashref) {
while ($hashref2 = $sth2->fetchrow_hashref) {

  .... work with the data here..

}
}

Basically instead of dumping all the data at the startup, just loop through and
get two pieces of data per time and then work with it that way.

Sorry if my explanation is obfuscated ;-)

But hopefully that should be more efficient.
-Malander



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

Date: Sat, 10 Feb 2001 20:43:59 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Perl and database
Message-Id: <jKhh6.19$zN2.188620288@news.frii.net>

In article <20010211020254.19ff9b53.lxq79@hotmail.com>,
LXQ  <lxq79@hotmail.com> wrote:
>Hi,
>
>I am writing a script to send bulletin news to all the subscribers. The
>subscribers' email addresses are taken from MySQL. There are about 4000
>emails. About the bulletin, it is also different per email, so every
>subscriber gets different bulletin depends on what they chose. The size of
>every bulletin is around 50 Kbyte. My question is, is it right (efficient
>enough) to do it this way? :
>- Open the connection to the database, dump all email data to hash.
>- Open connection again, dump all bulletin data to hash.
>- Foreach the email hash, match it to the bulletin, and send it with
>sendmail.
>
>Thanks so much. 

The general algorithm for this kind of thing is as follows.

    open database connection;

    $sth = $dbh->prepare (fancy selects that joins the right bulletin 
			    to the right email address);

    $sth->execute or die $sth->errstr;

    while ($row = $sth->fetchrow_hashref) {
	# compose and send an email using the values in $row;
    } 

    close database connection;

Obviously threre are lots of details to work out here.  But the
key is to let the database do the work that it was designed to do.
Good design of your data schema can help greatly in this regard.

chris
-- 
    This space intentionally left blank


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

Date: 10 Feb 2001 19:55:40 GMT
From: tarael200@aol.com (Tarael200)
Subject: Re: Perl and Networking
Message-Id: <20010210145540.27413.00000238@ng-df1.aol.com>

First of all, yes you should've read the FAQ ;-)

Second of all, Perl does have built-in networking functions

perldoc IO::Socket
perldoc Socket

Thanks.
-Malander



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

Date: Sat, 10 Feb 2001 20:50:24 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Perl and Networking
Message-Id: <kQhh6.20$zN2.170607104@news.frii.net>

In article <963p95$7dt$1@nnrp1.deja.com>,  <qurob@hotmail.com> wrote:
>
>
>This is related to my previous posts about having a Perl program that
>acts as an email client. I'm new to Perl, but have done C, Java, Visual
>Basic, Pascal, assembly....My question is, does Perl have built-in
>networking functions (shoulda checked the FAQ, I know) or would it be
>more feasible/possible to open a telnet session from inside the perl
>script? I basically want to be able to check a pop3 server for new
>messages and download them, or send outgoing through a SMTP.
>

Perl has built in networking (sockets interface) You can also use
IO::Socket.  Or for a higher level interface for poking at a POP server
there is Net::POP3 and even a few IMAP modules available via CPAN.

Have a look around at www.cpan.org and see what you may find.

chris
-- 
    This space intentionally left blank


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

Date: Sat, 10 Feb 2001 20:29:23 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Regular Expression Question
Message-Id: <t8b953qmpq59d2@corp.supernews.com>

bonjaa@my-deja.com wrote:
[snip]
: So ten or more consecutive N's are like delimiters, basically I want a
: regular expression that says one or more N's followed by an optional
: newline symbol (if the consecutive N's are on two lines) followed by
: one or more N's, with the total number of N's greater than 10.

I'd suggest doing this in two steps:

  $filetext =~ tr/\n//d;
  @fragments = split /N{11,}/, $filetext;

That is, scrub away the newlines so that they don't mess up your search
for sequences of 11+ Ns.  This approach fails if newlines embedded in
fragments must be maintained, of course.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "When the going gets weird, the weird turn pro."
   |               - Hunter S. Thompson


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

Date: Sat, 10 Feb 2001 20:53:35 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: undef ?
Message-Id: <jThh6.2283$OO2.14302@eagle.america.net>

On Sat, 10 Feb 2001 17:17:11 GMT, Brcin <info@ultraviolet.li> wrote:
>undef $/ ;
>$_ = <STDIN> ;
>
>What exactly does that undef thing do?

The $/ variable is a special variable in Perl.  The special variables
are described in the perlvar manual page.  

In particular, $/ is the input record separator.  The perlvar manual
page tells you that it is set to newline, by default and that when it
is undefined, reads on files will "slurp" in the whole file instead of
one line at a time (default).  

-- 
Garry Williams


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

Date: Sat, 10 Feb 2001 20:51:58 +0100
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.li>
Subject: Re: use pack() to uuencode long strings?
Message-Id: <qo6b8t87r7tj0iht0d4fkdskqe26hhiq46@4ax.com>

On Sat, 10 Feb 2001 16:31:05 GMT, Drew Shafer <dshafer@mail.utexas.edu> wrote:

> Basically what I'm trying to do is send a binary file over a a
> text-based socket connection using the IO::Socket::INET module.  I am
> breaking the file up into bite-sized chunks and uuencoding/decoding it
> on the fly.

In that case you may want to use MIME::Base64 (or base 64 encoding in general).
As far as I know, the uuencode format has each line start with a byte saying how
many characters are encoded in this line. Hence, the uuencode format has a
maximum line length derived from the fact that only 64(?) different characters
are in its set. Base 64 encoding doesn't use this length byte, so its lines can
be any length. And as for space, they both expand the string by 4:3 -- though
base 64 should be slightly more efficient since you can drop the length bytes
and the newlines.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Sat, 10 Feb 2001 22:19:42 -0000
From: "Steve Kay" <steve@peachy.com>
Subject: Re: who is responsible ?
Message-Id: <964eli$sfu$1@plutonium.btinternet.com>

Download it from www.cpan.org

Steve

"nowayandnohow" <nowayandnohow@hotmail.com> wrote in message
news:xXdh6.7067$bu4.1294448@typhoon2.ba-dsg.net...
> Who is the "responsible" make r of cgi.pm ?
>
> where can i oficially read about it ?
>
> where can i download it ?
>
> thankfull for reply :-)
>
> // Newbie
>
>




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

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 V10 Issue 267
**************************************


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