[16119] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3531 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 1 14:05:24 2000

Date: Sat, 1 Jul 2000 11:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <962474712-v9-i3531@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 1 Jul 2000     Volume: 9 Number: 3531

Today's topics:
    Re: *** Urgent: Perl Access to MySql without DBI.pm pos <danny@lennon.postino.com>
        ANNOUNCE: CGI-Formalware V 1.09 <ron@savage.net.au>
        ANNOUNCE: Devel::StackTrace 0.7 (first public release) <grimes@waste.org>
        ANNOUNCE: Exception::Class 0.6 (first public release) <grimes@waste.org>
    Re: Changing .htpasswd on the fly.. <flavell@mail.cern.ch>
    Re: Changing .htpasswd on the fly.. <gellyfish@gellyfish.com>
        Creating modules question <jfisher@epotec.com>
    Re: DANGEROUS CODE ABOVE (was Re: Perl Help Please!) (Randal L. Schwartz)
        Debugging Memory Usage <jason.holland@dial.pipex.com>
    Re: Finding FatalsToEmail ? (Randal L. Schwartz)
    Re: Help with hashes (Eric Bohlman)
    Re: Interchage the role of key and value in a hash (Tad McClellan)
    Re: LWP Script <gellyfish@gellyfish.com>
    Re: mysql and perl in win32 <bwalton@rochester.rr.com>
    Re: Newbie question about subroutines... <iltzu@sci.invalid>
        Newbie question: extract colums from a file into an arr (Clemens Hermann)
    Re: Number of matches question <tony@pyxis.blackstar.co.uk>
    Re: off topic question about NT command shell [was: Dum <gellyfish@gellyfish.com>
    Re: Printing background images? <gellyfish@gellyfish.com>
    Re: Printing Problems <bwalton@rochester.rr.com>
    Re: Specifying smtp server in Mail::Mailer <gellyfish@gellyfish.com>
    Re: Spliting things (Tad McClellan)
    Re: Spliting things <psychoNOpsSPAM@pcpatches.com.invalid>
    Re: Spliting things <psychoNOpsSPAM@pcpatches.com.invalid>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 1 Jul 2000 15:59:33 GMT
From: <danny@lennon.postino.com>
Subject: Re: *** Urgent: Perl Access to MySql without DBI.pm possible ??? ***
Message-Id: <8jl4h5$lbf$1@lennon.postino.com>

User-Agent: tin/1.4.2-20000205 ("Possession") (UNIX) (Linux/2.2.14-5.0 (i586))

WWW_DESIGN_HOSTING <whofer@access.ch> wrote:
> can anybody tell me how i can access from a Perl-Script to a Mysql Database
> ( MySql is on a Linux Server ).
> I have to make the exam and the system administrator told me, that the
> DBI.pm Perl Module
> is not installed on the Server. He also told me, that they will never
> install DBI.pm on the server !

I had this problem on my first Oracle site. The Oracle DBI required the
ProC library from Oracle, and they wanted a couple of thousand for it. 
Maybe the Justice Department will target Ellison next, dirtbag.
Anyhow, I ended up having to write system/shell calls to psql and 
parsing out the output. I am sure you could do the same with calls to
mysql, someting like(do a man mysql for exact syntax):

#!/usr/bin/perl -w
$Returned = 'mysql -ddatabase -c"SELECT * from TABLE;" ' ;
# now work with $Returned


-- 
Danny Aldham     Providing Certified Internetworking Solutions to Business
www.postino.com  E-Mail, Web Servers, Web Databases, SQL PHP & Perl


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

Date: Wed, 28 Jun 2000 19:40:58 +1000
From: "Ron Savage" <ron@savage.net.au>
Subject: ANNOUNCE: CGI-Formalware V 1.09
Message-Id: <_So75.373$R7.18600@news-east.usenetserver.com>

The Perl module CGI::Formalware V 1.09 is now on CPAN.

What is CGI::Formalware?
o It allows you to use an XML file, instead of CGI scripting, to generate
CGI forms.
o When data is entered into the fields on the form, this data is passed as
parameters into underlying scripts.
o You write the scripts in the XML file.
o So, each form usually consists of a set of fields, and a list of script
names as radio buttons. You enter as much data as is required for the script
you wish to run, and then click on the script's name. CGI::Formalware runs
the script, using the input data.
o The scripts are run from the OS's command line, and can do anything.
o Scripts are tagged as local or remote. Remote scripts must have enough
parameters to allow you to log on to the remote machine. Then, the remote
script is shipped using Net::Telnet to the machine of your choice, where it
is run.
What fun!

Changes in this version:
Revision history for Perl extension CGI::Formalware.

o Tested under Apache 1.3.12 for Windows, with ActivePerl and with mod_perl.

o The Table of Contents is now 'live', meaning you can click on a page's
 name to jump to that page.

o Paragraphs can now have a text attribute. So, both of the following are
 accepted:
  <paragraph />
  <paragraph text = 'Some string' />

o The number of columns in a radio group can be controlled. So, both of the
 following are accepted:
  <radioGroup
   name  = 'serverName'
   prompt  = 'Server name: '
   value  = 'Example|Simple|Test'
  />
  <radioGroup
   name  = 'serverName'
   prompt  = 'Server name: '
   value  = 'Example|Simple|Test'
   columns  = '1' # Optional. Default: '1'. A string, not a digit
  />

o A file browse button is now available. Use it like this:
  <fileField
   name  = 'fileName'
   prompt  = 'Filename: '
   size  = '60'
   override = '0'
  />
 This change requires the use of start_multipart_form(), rather than
 start_form().

o The initial page, which asks for the name of the XML file, now contains
 more explanatory text.

o The output of local and remote scripts now have the '<' and '>' characters
 encoded as &lt; and &gt;. This applies particularly to the output of DOS
 directory listings.

o The documentation has been expanded to spell out exactly which CGI
 functions are supported. These are:
  <fileField ...>
  <horizontalRule ...>
  <paragraph ...>
  <radioGroup ...>
  <textField ...>

o General code clean-up: Hash items which were 'X' => Y, are now X => Y.

--
Cheers
Ron & Pen Savage
ron@savage.net.au    pen@savage.net.au
http://savage.net.au/index.html




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

Date: Tue, 27 Jun 2000 16:46:38 -0500
From: Peter Grimes <grimes@waste.org>
Subject: ANNOUNCE: Devel::StackTrace 0.7 (first public release)
Message-Id: <cTo75.375$R7.19060@news-east.usenetserver.com>

Devel::StackTrace is a module that provides an OO interface to the
information available from the caller() function, allowing you to step
through the stack frames in sequence or retrieve a single frame as
desired.

It was primarily written to be used by my Exception::Class (see next
announcement) module but may be useful as part of a debugging/devel
environment in general. 

If you have questions please send them via email.

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

The URL

    ftp://ftp.urth.org/pub/Devel-StackTrace-0.7.tar.gz

has entered CPAN as

  file: $CPAN/authors/id/D/DR/DROLSKY/Devel-StackTrace-0.7.tar.gz
  size: 4736 bytes
   md5: f6f43401ffd1c0895b1c8b40e325d134

No action is required on your part
Request entered by: DROLSKY (Dave Rolsky)
Request entered on: Tue, 27 Jun 2000 19:20:14 GMT
Request completed:  Tue, 27 Jun 2000 19:21:13 GMT

        Virtually Yours,
        Id: paused,v 1.68 1999/10/22 14:39:12 k Exp k 




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

Date: Tue, 27 Jun 2000 16:51:19 -0500
From: Peter Grimes <grimes@waste.org>
Subject: ANNOUNCE: Exception::Class 0.6 (first public release)
Message-Id: <5To75.374$R7.18989@news-east.usenetserver.com>

This perl module allows you to declare a hierarchical set of exception
classes at compile time.  Exceptions may be derived from any base class
though this module provides Exception::Class::Base as the default.  In
addition, you may mix in classes loaded from files or otherwise declared
without Exception::Class. 

Sample usage:

 use Exception::Class( 'Exception::Foo',
                       'Exception::Foo::Bar' => { isa => 'Exception::Foo' },
                       'Exception::Foozle' );

 # All of these are now Exception::Class::Base subclasses

It will also detect circular inheritances and missing parents in your
declarations at compile time.

Please email me if you have any questions as I don't regularly read the
newsgroups.

-dave


The URL

    ftp://ftp.urth.org/pub/Exception-Class-0.6.tar.gz

has entered CPAN as

  file: $CPAN/authors/id/D/DR/DROLSKY/Exception-Class-0.6.tar.gz
  size: 6521 bytes
   md5: 990056f7a4cb4669d49cad5ef635bd76

No action is required on your part
Request entered by: DROLSKY (Dave Rolsky)
Request entered on: Tue, 27 Jun 2000 19:20:40 GMT
Request completed:  Tue, 27 Jun 2000 19:21:31 GMT

        Virtually Yours,
        Id: paused,v 1.68 1999/10/22 14:39:12 k Exp k 





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

Date: Sat, 1 Jul 2000 14:54:49 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Changing .htpasswd on the fly..
Message-Id: <Pine.GHP.4.21.0007011428090.17749-100000@hpplus03.cern.ch>

On Sat, 1 Jul 2000, Hans wrote:

> >> $pass = crypt($pass, $pass);
> >
> >Where did you get this idea from?  It publishes the first two
> >characters of every password, to anyone who can read the file.
> 
> The file '.htpasswd' is placed in a directory not accessable from the
> web, is this enough to provide basic security/authentication with the
> function 'crypt()'?

On _that_ basis, you might as well store the password in plain text.
The crypting is supposed to be giving you at least a modest amount of
additional security, in case the data accidentally falls into the
wrong hands.  (Yeah, we all know about Crack...).

My point is, you get no benefit from doing it that way.  If you can't
be bothered to construct a random salt, I think you'd be better to use
a fixed one, say 'xy' or something, than to put the first two
characters of every password in clear text into its crypted version,
which is what the above code is in effect doing.

> The thing I am trying to realize is this:

Sure, but until you've decided with the help of the CGI or servers
group just what it is you plan to implement, there isn't a lot that
the Perl language group can help you with the detailed coding.

So the rest of this is off-topic for Perl and you should treat it with
the relevant level of scepticism.  F'ups suggested!

But do, _do_, read carefully about file locking, or somewhere down the
line your carefully planned data will go west.

> Next the script should update the '.htaccess' file in the protected
> directory (todo) and the '.htpasswd' file (todo), so the new user can
> login the protected directory instantly (after receiving his/her
> Password by E-mail).

If you're saying that each user gets a different protected area, then
yes, it looks as if you need to do that.  Otherwise, "require
valid-user" would cover all users, present or future, authenticated in
the relevant domain, and you would not need to update htaccess every
time.

Btw. the Perl FAQs show you how to use your own copies of modules (as
long as they do not require to be installed as root).

good luck



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

Date: 1 Jul 2000 16:14:05 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Changing .htpasswd on the fly..
Message-Id: <8jl1rt$eem$1@orpheus.gellyfish.com>

On Fri, 30 Jun 2000 15:24:20 +0200 Alan J. Flavell wrote:
> 
> Me, I'd take a look at Randal's WebTechniques.  Bound to be some
> more-reliable examples to follow there, although I see that in col.5
> where something similar is done, he's still using numerical constants
> for lock modes.
> 
> Oh dear, I'm reluctant to teach Randal to suck eggs, but he seems to
> do this consistently, and in col 34 he even compounds it by coding
> 
>      flock($master, 2);          # LOCK_EX
> 

It might be that some of the examples predate the inclusion of the Fcntl
module in the distribution - I cant be arsed to look right now as England
appear to be in with a fighting chance of beating the West Indies at Lourdes
er Lords ;-}

/J\
-- 
** This space reserved for venue sponsor for yapc::Europe **
              <http://www.yapc.org/Europe/> 


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

Date: Sat, 01 Jul 2000 17:39:03 GMT
From: James Fisher <jfisher@epotec.com>
Subject: Creating modules question
Message-Id: <395E2C71.F00E3A15@epotec.com>

I am having trouble getting a module I created to work correctly.  I am
creating a funtion that will user the XML::Parser module.  The problem
is coming in when I have to define my own implementations for the
XML::Parser functions such as StartTag, Text, etc.....  I have the code
working fine by itself, but I need to put the following into a
function...

use XML::Parser;

my $p=new XML::Parser(Style=>'Stream');
$p->parsefile('test2.xml');

my @Answers;
my ($CurrentQuestionNumber, $CurrentAnswerNumber, $QuestionFlag) = 0;

sub StartTag {
    my ($expat,$element)=@_;
    $CurrentQuestionNumber = $_{'NUMBER'};

    if (($element eq "QUESTION") and ($CurrentQuestionNumber ==
$SearchNumber)) {
        $QuestionFlag = 1;
    } elsif ($element eq "ANSWER" && $QuestionFlag == 1 ) {
        $CurrentAnswerNumber = $_{'NUMBER'};
    }
}

sub Text {
    if ($QuestionFlag == 1) {
        $Answers[$CurrentAnswerNumber] = $_;
    }
}

sub EndTag {
    my ($expat,$element)=@_;
    if ($element eq "QUESTION" && $QuestionFlag == 1) {
        $QuestionFlag = 0;
    }
}

How do you define a function that implements the above in a module.  I
have been trying different implementations for a few days and have been
unsuccessful.  Any suggestions...

JF




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

Date: 01 Jul 2000 09:46:54 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: DANGEROUS CODE ABOVE (was Re: Perl Help Please!)
Message-Id: <m1hfa9er29.fsf@halfdome.holdit.com>

>>>>> "Bart" == Bart Lateur <bart.lateur@skynet.be> writes:

>> http://www.your.server.org/yourscript?PAGE=rm+-rf+/+|

Bart> I'm not sure what

Bart> 	open PAGE, "rm -rf /";

Bart> is supposed  to do. I don't think it will invoke rm. But you can still
Bart> modify it do to so, I guess.

You missed the vertical bar on the end. Essential to the mix.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Sat, 01 Jul 2000 16:47:56 +0000
From: Jason Holland <jason.holland@dial.pipex.com>
Subject: Debugging Memory Usage
Message-Id: <395E20BC.AF64C4A1@dial.pipex.com>

Hello all,

I've run into a problem quite recently with tracking memory usage in
Perl.

Essentially, I've built a system where a hierarchy of linked Perl
objects are created. It's actually a DOM implementation, and the number
of objects allocated in a tree can be extremely large.

Because of the way that the tree structure is built, each of the node
objects stores a reference to it's parent and child nodes. Because of
this I believe that some circular references may have been introduced.
I've carefully written a destructor for each object that breaks any
references but it's quite hard seeing if this is being done properly or
not.

Part of the system is used in a batch environment, and can quite easily
use several hundred megabytes of RAM!

I've already checked out CPAN, the DProf module, which is very nice, and
looked through the documentation for the Debugger; but there doesn't
seem to be much in the way of tools for tracking memory usage.

What I would like would be a module, similar to DProf, that would tell
me what each package was allocating; and more importantly what was not
being released upon object destruction and at exit.

Incidentally, I'm just about to try the GNU ddd debugger, which may or
may not do what I want. It's probably overkill though ;-)

Any ideas?

Thanks in advance!

Jason

-- 
"A Jedi craves not these things."

                            Yoda


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

Date: 01 Jul 2000 10:04:00 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Finding FatalsToEmail ?
Message-Id: <m1aeg1eq9r.fsf@halfdome.holdit.com>

>>>>> "Tina" == Tina Mueller <tina@streetmail.com> writes:

Tina> i've never heard of that fatalsToEmail.

Of course not.  I made it up for my Linux Magazine "Wisdom of Perl"
column, and it's not printed yet.

Tina> you should take a look at 
Tina> perldoc CGI::Carp
Tina> you can use the carpout() function to write
Tina> errors to a filehandle which can be a
Tina> pipe to an email program, too.

Well, the downside of that is that you get email whether something
happened or not, and you get email on each invocation.  Ick. :)

FatalsToEmail fixes those, and will probably be part of the CPAN as
soon as I get a real name for it, document it apart from the article,
and get clearance from the magazine to publish the work they own as a
"work for hire".  (They gave that already for "perlboot", so I can't
imagine them rejecting this either.)

Aside - the problem of being a successful and prolific columnist (some
102 columns so far and 2.5 more each month) is that I'm generating a
ton of stuff that I don't own, but really should be released to the
CPAN.  At least I worked out the deal where I get to put it on my site
at places like:

        http://www.stonehenge.com/merlyn/WebTechniques/
        http://www.stonehenge.com/merlyn/UnixReview/
        http://www.stonehenge.com/merlyn/LinuxMag/

So at least people can download and take what they want.  It just
can't be in the CPAN without working out a specific deal for each
column. :(

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 1 Jul 2000 15:55:59 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Help with hashes
Message-Id: <8jl4af$jvc$3@slb7.atl.mindspring.net>

Colby Hansen (cghansen@micron.com) wrote:
: I assure you the code does exist and it did when I posted my original
: message.  My point is that so what if I made two typos...  my question was
: answered, my code works now, and I even learned some things (hey, maybe
: other people reading this newsgroup did too).  Isn't that the point...  I
: doubt the point is to see who is proficient at copying and pasting their
: code.

The point is that if you ask for help debugging retyped code, the code
that's getting debugged is very likely to be different from the code that
actually *needs* to be debugged.  It may contain spurious errors, like
yours did, or worse, you may unconsciously type what you want your code to
be rather than what it actually is (this is due to the psychological
phenomenon known as "set," which causes us to see what we think *should*
be there rather than what *is* there.  One time I wasted a whole week
tracking down a bug in some assembly code where I pushed some data onto a
stack, did some stuff, and then popped the data off the stack.  Well, I
*intended* to pop the data off the stack, but I forgot to actually write
the instructions to do it.  But I *knew* that every push needed a
corresponding pop, so my mind "helpfully" filled in the missing pops when
I was looking at the code).  In the latter case, nobody will be able to
find the bug because it won't be present in the code they're looking at. 

Part of the process of becoming a good programmer is becoming aware of
issues like this.  Nobody in their right mind will fault you for not being
aware of them when you start out, but nobody in their right mind will
continue to help you if you treat having things like this pointed out to
you as an attack or insult. 



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

Date: Sat, 1 Jul 2000 09:31:38 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Interchage the role of key and value in a hash
Message-Id: <slrn8lrslq.7tb.tadmc@magna.metronet.com>

On Sat, 1 Jul 2000 18:33:51 +0800, multiplexor <abuse@localhost> wrote:
>I have a hash:
>
>%entity = ('&' , '&amp;' , '>' , '&gt;');
>
>What is the best way to make a hash like the followings?
>
>%code =  ('&amp;' , '&' , '&gt;' , '>');
>
>That is, interchange the role of the keys and values of %entity.


To "reverse" a hash:

   my %code = reverse %entity;        #  :-)


You lose stuff if values are duplicated in %entity, but I'm
guessing your particular application is one-to-one.


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


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

Date: 1 Jul 2000 15:56:27 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: LWP Script
Message-Id: <8jl0qr$b2j$1@orpheus.gellyfish.com>

[ removed the non-existent comp.lang.perl ]

In comp.lang.perl.misc Jason Brown <jrbrown@cts.com> wrote:
> 
> 
> I am writing a little LWP script to find some
> information on a web page. The first thing I must
> to is log onto their site - which appears to be
> ok. 
> 
> However the response I get from my perl script is
> not the same as I get when I do it manually. 
> 
> Do I need to some how combine GET & POST -- or
> other suggestions are welcome.
> 
> Here is a code segment:
> 
> my $cjar = LWP::UserAgent->new;
> $cjar->cookie_jar(HTTP::Cookies->new(file => "ingramcookies.txt",autosave
> => 1, ignore_discard => 1));
> 
> # Submit User Info
> 
> my $auth = LWP::UserAgent->new;
> my $req = POST "$ingram", [ USERNAME => "$uname", PASSWORD => "$passwd" ]
> my $resp =  $auth->request($req)->as_string;
> 
> Here is what is returned by the remote site:
> 
> HTTP/1.1 302 (Found) Moved Temporarily
> Date: Thu, 29 Jun 2000 23:06:23 GMT
> Location: [removed]
> Server: [removed]
> 

You should read in the LWP::UserAgent manpage about the redirect_ok method

/J\
-- 
** This space reserved for venue sponsor for yapc::Europe **
              <http://www.yapc.org/Europe/> 


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

Date: Sat, 01 Jul 2000 16:02:17 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: mysql and perl in win32
Message-Id: <395E164B.409264ED@rochester.rr.com>

"Jon K." wrote:
 ...
> Alternatively, is there any version of win32 perl that comes along with
> DBI and MySQL
> support?
 ...
> Jon.
Looks like ActiveState Perl version 5.005 comes with DBI in the standard
package, and the mySQL DBD driver is available via PPM.  The Perl 5.6
version looks like it is missing the mySQL DBD driver, but maybe the one
from 5.005 would work?  Either of these two versions of Perl is
currently available from http://www.activestate.com .  Note that 5.6
states it won't work with NT 4 pre-service-pack-5.
-- 
Bob Walton


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

Date: 1 Jul 2000 16:48:32 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Newbie question about subroutines...
Message-Id: <962469893.23771@itz.pp.sci.fi>

In article <39509D97.E982270@ccf.auth.gr>, Vlasis Hatzistavrou wrote:
>I want to launch them together because I want to make a metasearch engine
>andthe searches in the different engines must happen at the same time because
>otherwise it would take a lot of time to wait for one engine to finish, then
>launch the other etc.

Well, in that case LWP::Parallel::RobotUA might be just what you want.

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method."  -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: Sat, 01 Jul 2000 17:01:44 GMT
From: haribeau@gmx.net (Clemens Hermann)
Subject: Newbie question: extract colums from a file into an array
Message-Id: <395e22dd.9600231@news.btx.dtag.de>

Hi,

I was digging around the web quite a while but did not find a solution
for my problem: 
A Textfile with 8 colums and several 1000 rows.
To evaluate the file I only need 2 of the 8 rows (Nr. 3 and Nr. 6).
How can I 

1. create an array containing the two columns and any line

2 create two arrays each containing one column.

The file contains no real "colums", only strings seperated by tabs.

Thanks in advance for any hint.

Clemens


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

Date: Sat, 01 Jul 2000 16:22:08 GMT
From: Tony Bowden <tony@pyxis.blackstar.co.uk>
Subject: Re: Number of matches question
Message-Id: <QUo75.2151$4C4.44375@news2-win.server.ntlworld.com>

Clinton A. Pierce <clintp@geeksalad.org> wrote:
> Try something more idiomatic like this:
> @list=qw/adam bob adams carol dave adamson carol bob/;
> @match=grep {/^adam$/} @list;
> print scalar @match;   # This prints 1
> You get 1 if there's exactly 1 adam.  If there's two, you get 2.
> If there's no adams...you get 0.  Which is false in Perl.

Surely, if all you want to know is how many matches there are it's much 
quicker to just iterate over the array and count them?

my $count = 0; 
foreach (@list) { $count++ if ($_ eq "adam") };

Tony
-- 
-----------------------------------------------------------------------------
 Tony Bowden | tony@blackstar.co.uk               http://www.blackstar.co.uk/
  Black Star |    The UK's Biggest Video & DVD store * Free Postage Worldwide
-----------------------------------------------------------------------------



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

Date: 1 Jul 2000 17:17:01 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: off topic question about NT command shell [was: Dumb Perl (win32) Q]
Message-Id: <8jl5ht$qh6$1@orpheus.gellyfish.com>

On Sat, 01 Jul 2000 03:40:33 GMT jason wrote:
> 
> BUT .. you should be debugging CGI scripts in a CGI environment .. 
> 

That really does depend on what part of the programming you are debugging 
really.  If you are debugging parts that are specific to the CGI then
perhaps, but in other cases it might more appropriate to test at the
command line as it easier to control the environment and avail yourself of
diagnostic information.

In most non-trivial applications written for the CGI I would say that the
majority of the code is the application logic itself and very little of it
is specific to the CGI.  I tend to favour making the core code work as a
command line application whatever interface it might end up using ...

/J\
-- 
** This space reserved for venue sponsor for yapc::Europe **
              <http://www.yapc.org/Europe/> 


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

Date: 1 Jul 2000 16:21:40 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Printing background images?
Message-Id: <8jl2a4$fsv$1@orpheus.gellyfish.com>

On Fri, 30 Jun 2000 10:22:38 GMT Nathan D Hiller wrote:
> How can I get background images to print for users who print my web page?
> 
> I have a web page that contains several background images. When internet
> users print this page I want the background images to print as well. If I
> have a print button on this web page for users to click on when they need to
> print, how can I send a print command to the user's printer so that the
> background images are printed?
> 

You cant do this in general - you will need to ask in a group about browsers
to find out if it is at all possible with any particular browser.

/J\
-- 
** This space reserved for venue sponsor for yapc::Europe **
              <http://www.yapc.org/Europe/> 


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

Date: Sat, 01 Jul 2000 15:53:30 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Printing Problems
Message-Id: <395E1445.5C6AF6F6@rochester.rr.com>

GC wrote:
> 
> I've a file that contains some text
> 
> now the strangest things are happening, when I would like to print every
> line from that file, it stops after printing a number of lines, when I test
> what could be the problem and I delete the last 10 lines from the file, then
> the script stops printing the lines 10 lines earlier etc....
> 
> Has anybody had this problem before ?
 ...
Haven't seen that one before, unless it is a buffering problem.  If you
actually want some help, whittle you code down so a very small short but
complete segment that demonstrates the problem you are having and that
anyone can run easily to duplicate your results, and ask again.  Details
like what platform, OS, Perl version etc are also helpful.
-- 
Bob Walton


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

Date: 1 Jul 2000 15:49:14 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Specifying smtp server in Mail::Mailer
Message-Id: <8jl0da$9la$1@orpheus.gellyfish.com>

On Fri, 30 Jun 2000 14:02:17 GMT Shana Rosenberg wrote:
> In article <8jhm28$c4m$1@orpheus.gellyfish.com>,
>   Jonathan Stowe <gellyfish@gellyfish.com> wrote:
>> You are indeed using the module correctly ?
> 
> As far as I know I am. Perhaps I should have put "Newbie" in my post
> title :)
> 
>> have you thought that the server in question might not allowing
> relaying
>> for the host you are sending from ?
> 
> The server will allow relaying from my host. I am in the same domain
> and this is the only restriction set up on our SMTP server, that
> senders be in the same domain.
> 
>> What you might want to do is to
>> temporarily alter Mail::Mailer::smtp so that it turns the debugging on
>> for Net::SMTP - or you could use Net::SMTP directly to talk to the
>> server in question.
> 
> Once again, forgive my newbieness at Perl. I don't know how to do this
> so I would appreciate suggestions for taking this course of action.
> 

OK.  You find the Mail::Mailer::smtp module - on my system this is :

  /usr/lib/perl5/site_perl/5.6.0/Mail/Mailer/smtp.pm

but it may be somewhere different on yours. Then you change the lines in
the 'exec' subroutine that say :

    my $host = $opt{'Server'} || undef;
    # for Net::SMTP we do not really exec
    my $smtp = Net::SMTP->new($host, Debug => 0)
        or return undef;

to: 

    my $host = $opt{'Server'} || undef;
    my $debug = $opt{'Debug'} || 0;
    # for Net::SMTP we do not really exec
    my $smtp = Net::SMTP->new($host, Debug => $debug)
        or return undef;


The patch for that would be :

--- smtp.pm	Sat Jul  1 14:57:14 2000
+++ smtp.pm.new	Sat Jul  1 14:56:51 2000
@@ -12,8 +12,9 @@
     my($self, $exe, $args, $to) = @_;
     my %opt = @$args;
     my $host = $opt{'Server'} || undef;
+    my $debug = $opt{'Debug'} || 0;
     # for Net::SMTP we do not really exec
-    my $smtp = Net::SMTP->new($host, Debug => 0)
+    my $smtp = Net::SMTP->new($host, Debug => $debug)
 	or return undef;
 
     ${*$self}{'sock'} = $smtp;


Then you can do :

$mailer = Mail::Mailer->new('smtp',Server=> 'your.smtp.server',
                                   Debug => 1
                                   );

And it will emit gobs of debugging information about the SMTP transaction
which should be able to help you diagnose the problem . You might want to
ask in some group that talks about SMTP if you dont understand what you
are looking at ...


/J\
-- 
** This space reserved for venue sponsor for yapc::Europe **
              <http://www.yapc.org/Europe/> 


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

Date: Sat, 1 Jul 2000 09:43:06 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Spliting things
Message-Id: <slrn8lrtba.7tb.tadmc@magna.metronet.com>

On Fri, 30 Jun 2000 17:12:14 -0700, psycho <psychoNOpsSPAM@pcpatches.com.invalid> wrote:
>ok, I have a ladder script that im running and i want to split
>the ranked members by so many so that i can place ads in the
>gaps. How would i do this?
>
>1 to 25
><ad>
>26-50
><ad>


if ( $rank >= 1 and $rank <= 25) {
   ad(1);
}
elsif ( $rank >= 26 and $rank <= 50) {
   ad(2);
}
else {
   warn "invalid rank: '$rank'";
}


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


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

Date: Sat, 01 Jul 2000 10:14:42 -0700
From: psycho <psychoNOpsSPAM@pcpatches.com.invalid>
Subject: Re: Spliting things
Message-Id: <07be1782.6639ec09@usw-ex0104-033.remarq.com>

Thank you Tad..


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

Got questions?  Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com



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

Date: Sat, 01 Jul 2000 10:27:54 -0700
From: psycho <psychoNOpsSPAM@pcpatches.com.invalid>
Subject: Re: Spliting things
Message-Id: <2a7ca9f1.69aba527@usw-ex0104-033.remarq.com>

hey, tad.. i've got a probelm still, take a look

http://www.pcpatches.com/cgi-bin/cgimania/test/testing.cgi


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

Got questions?  Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com



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

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


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