[25155] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7404 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 14 18:05:51 2004

Date: Sun, 14 Nov 2004 15:05:05 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 14 Nov 2004     Volume: 10 Number: 7404

Today's topics:
    Re: backreferneces in search pattern <see@sig.invalid>
    Re: backreferneces in search pattern <tadmc@augustmail.com>
    Re: backreferneces in search pattern <nobull@mail.com>
    Re: Cumulative distribution functions? (PJ)
    Re: Cumulative distribution functions? <1usa@llenroc.ude.invalid>
    Re: Extract domain name <xxredbaronxxx@hotmail.com>
        FAQ 5.26: How can I read in an entire file all at once? <comdog@panix.com>
        FAQ 7.27: How do I clear a package? <comdog@panix.com>
    Re: Image::EXIF troubles <1usa@llenroc.ude.invalid>
    Re: options to shrink-wrap a perl script <tadmc@augustmail.com>
    Re: options to shrink-wrap a perl script <flavell@ph.gla.ac.uk>
        Password-protected login problem <jimsimpson@cox.net>
        Problems with using Autoloader <augustus74@cox.net>
    Re: Problems with using Autoloader <nobull@mail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 14 Nov 2004 13:10:23 -0500
From: Bob Walton <see@sig.invalid>
Subject: Re: backreferneces in search pattern
Message-Id: <41979d34$1_2@127.0.0.1>

Marek Stepanek wrote:

> On 13/11/2004 16:30, in article cn592c$pms$1@sun3.bham.ac.uk, "Brian
> McCauley" <nobull@mail.com> wrote:
 ...
> If somebody could point me to the right direction of the "adavanced
> trickery", I will find the rest myself. Is this the right tricky direction ?
> 
Well, you're getting there, I guess (I'm not too clear on precisely what 
it is you want to do).  See comments below.
> 
> #!/usr/bin/perl -w
-w is not needed with the "use warnings;" statement in place.
> 
> use strict;
> use warnings;
> 
> my (@results02, %seen);
> 
> while (<>) {
>     no warnings qw(uninitialized);
>     my @results = 
> m!onmouseover="[^']+'([^']+)'(?:(?:(?:;\s+[^']+)'([^']+)')+)?(?:(?:[^']+)'([
> ^']+)')?"!g;
> 
>     foreach my $i (0..$#results) {
>         @results02 = "'$results[$i]',\n";
Here you are assigning a scalar value (a string) to an array 
(@results02).  Perl attempts to DWYM -- but it will result in @results02 
being an array with a single element, the scalar just assigned.  You 
could do what I think you want to do either of several ways:

           push @results02,"'$results[$i]',\n";

or

           $results02[$i]="'$results[$i]',\n";

In either case, you should recognize that @results02 will be cumulative 
(in two different fashions) for each line read from the input data.  In 
the first case, all the matched results would pile up in @results02; in 
the second case, if a line with fewer matched fields is encountered, the 
leftover values from the previous line will still be present in the 
latter elements of @results02.  Neither is likely to be what you want. 
I'm guessing you want to initialize @results02 each time through the 
while loop, prior to the loop setting @results02.

Also, a more "Perlish" style of loop which would suffice here (because 
you don't actually need the array index variable) would be:

     for my $result(@results){
        push @results02,"'$result',\n";
     }
>         }
Please use a consistent indenting style.  That would make it much easier 
to read your programs.
>         for (@results02) {
If the only thing you are using @results02 for is this loop, you may 
save your energy (and the computer's) by simply incorporating this 
statement in the previous loop.  It is not necessary to have a separate 
loop if this is all you're doing.  Indeed, it is not necessary to 
generate the @results02 array at all (but I don't know what you might be 
doing with it later in your real code).
>             $seen{$_}++;
Here also note that %seen will be cumulative from line to line of the 
input data, since its values have not been reset since the previous 
execution of the while loop body.  That might or might not be what you 
want??
>             }
>         print sort keys %seen;
Here you are printing out all the keys that have accumulated in %seen so 
far, and you're doing it each time through the while loop.  So you print 
out all the keys from the first data line; then all the keys from the 
first and second data lines; then from the first second and third; etc. 
  Again, I doubt that is what you want to do.  I would guess this print 
statement is intended to come after the end of your while loop, after 
all the data has been read.
>     }
> 
There is no "advanced trickery" here, just logical reasoning applied to 
computer programming.  You need to think in terms of breaking your 
problem down into steps, writing and testing each step as you go, and 
then organizing those steps in a fashion that will accomplish your goal. 
  As someone else has said, throwing crap together randomly is not the 
way to write a computer program.  It looks like you're understanding the 
individual steps (or maybe successfully copying them from somewhere?), 
but are mostly missing the larger picture.
-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl


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

Date: Sun, 14 Nov 2004 09:48:36 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: backreferneces in search pattern
Message-Id: <slrncpevik.p7i.tadmc@magna.augustmail.com>

Marek Stepanek <mstep@t-online.de> wrote:


> use warnings;


Good!


>     no warnings qw(uninitialized);


Bad!

Do you turn the radio volume up to "fix" the funny noise that 
your car is making?

You should try and understand why you are getting a warning rather
than ignore it. The warning is trying to tell you something...
listen to it.


>     my @results = 
> m!onmouseover="[^']+'([^']+)'(?:(?:(?:;\s+[^']+)'([^']+)')+)?(?:(?:[^']+)'([
> ^']+)')?"!g;


That regex it too horrid for me to look at, you need a m!!gx instead...


>     foreach my $i (0..$#results) {
>         @results02 = "'$results[$i]',\n";
>         }


When you find yourself doing explicit indexing in Perl, you should
pause and rethink, because you don't often need to do that.

You can loop over all of the elements without any explict indexing,
leaving that part to Perl (and a machine is much less likely to
make an indexing mistake than a human is).

   foreach my $result ( @results ) {


Ask yourself these questions:

   What will @results contain if the match *fails* ?       (A: the empty list)

   What will $#results return in that case?                (A: -1)

   How many iterations will your foreach() above go thru?  (A: 0)


ie. The body of the loop is never entered, and the for() below
    is never executed.


Did you try executing this code, or did you just type it in?


>         for (@results02) {

@results02 can never have more than a single element in it, because
you stomp over it each time thru the outer loop.

This loop (would) iterate no more that 1 time, so there is no
need for a loop at all...



If you post a short and complete program *that we can run* that
illustrates your problem, then we could surely help you fix it.

Have you seen the Posting Guidelines that are posted here frequently?


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


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

Date: Sun, 14 Nov 2004 19:53:19 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: backreferneces in search pattern
Message-Id: <cn8cri$2mh$1@sun3.bham.ac.uk>



Tad McClellan wrote:

> Marek Stepanek <mstep@t-online.de> wrote:
> 
>>use warnings;
> 
> Good!
> 
>>    no warnings qw(uninitialized);
> 
> Bad!

Yes in this case.  I don't think that you should give the impression 
that switching off warnings is always bad.  Particularly in the case of 
'uninitialized' one can often produce code that is both more efficient 
and more readable by disabling this particular warning:

my $record = do {
   no warnings qw(uninitialized);
   join ':', @fields;
};

my $record = join ':', map { defined() ? $_ : '' } @fields;

> You should try and understand why you are getting a warning rather
> than ignore it.

That is true.  But you may give some people the impression that you 
think understanding the cause and choosing to ignore are warning are 
mutually exclusive.  Indeed understanding the cause should be considered 
a prerequisite of making the descision to ignore a warning.

> The warning is trying to tell you something... listen to it.

I agree completely.



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

Date: 14 Nov 2004 09:20:20 -0800
From: perlmod@yahoo.com (PJ)
Subject: Re: Cumulative distribution functions?
Message-Id: <6775b086.0411140920.2e085cc4@posting.google.com>

CPAN, of course, is the first place I checked. Most of the time, it is
your friend...

The module you mention, Statistics::Distributions does not have a
corresponding function. Math::CDF is also lacking.

q/NORMDIST (x, mean, standard_dev, cumulative) returns the area under
the normal distribution up to point x where you have to define the
mean and SD of the population./

Now, there have been arguments posted on why not to use NORMDIST, but
I simply need to reproduce the examples in the book.

q/Microsoft chose to use a 6 polynomial approximation to the NORMSDIST
function (rather than the infinite series), and it is the worst of the
"DIST" functions. I have a nice graph that shows the error. So avoid
depending on these 3 "DIST" functions when sigma is more than 4./

Fortunately, I found Peter Acklam's Statistics::Distrib::Normal module
(requires his Math::SpecFun::Erf).  Why they are not posted on CPAN, I
don't know, but you can find them at
http://home.online.no/~pjacklam/perl/modules/index.html.

The following clode produces the same output as the NORMDIST example
given in MS Excel Help.

#!/usr/local/bin/perl -w

use strict;
use Statistics::Distrib::Normal;

my $dist = Statistics::Distrib::Normal->new(mu => 40, sigma=> 1.5);
print $dist->ltp(42) . "\n";
















"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message news:<Xns95A1925FD08Fasu1cornelledu@132.236.56.8>...
> perlmod@yahoo.com (PJ) wrote in 
> news:6775b086.0411132149.53554100@posting.google.com:
> 
> > I am going trough a book that uses that NORMDIST function in Excel.  I
> > would like to repoduce the results in perl.  Does anyone have a
> > function or module that is the same as Excel's NORMDIST?  Actually, I
> > only need the cumulative distribution function (in Excel's NORMDIST
> > function, the 4th parameter is set to TRUE).
> 
> CPAN is your friend:
> 
> http://search.cpan.org/~mikek/Statistics-Distributions-
> 1.02/Distributions.pm


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

Date: 14 Nov 2004 19:10:06 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Cumulative distribution functions?
Message-Id: <Xns95A1902041F1Basu1cornelledu@132.236.56.8>

perlmod@yahoo.com (PJ) wrote in
news:6775b086.0411140920.2e085cc4@posting.google.com: 

> CPAN, of course, is the first place I checked. Most of the time, it is
> your friend...
> 
> The module you mention, Statistics::Distributions does not have a
> corresponding function. 

Don't mess with distributions if you do not know statistics.

use strict;
use warnings;

use Statistics::Distributions;

my ($mean, $stdev) = (40, 1.5);
my $z = (42 - $mean)/$stdev;
my $p = 1 - Statistics::Distributions::uprob($z);
print "$p\n";

D:\Home> perl st.pl
0.908789

To recall:

perlmod@yahoo.com (PJ) wrote in 
news:6775b086.0411132149.53554100@posting.google.com:

> As an example, normdist(42, 40, 1.5, TRUE) equals 0.908789.


I am glad you found something that does what you want. But think before you 
speak. Or, at least read the documentation for the module you are using 
which shows how to get what you want from the module.

I am also going to suggest that you read the posting guidelines for this 
group. Top-posting and full-quoting are not really appreciated here.

Sinan.



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

Date: Sun, 14 Nov 2004 03:12:24 -0800
From: "Shabam" <xxredbaronxxx@hotmail.com>
Subject: Re: Extract domain name
Message-Id: <IJCdna3d5pLaHgrcRVn-sA@adelphia.com>

> The problem is not well defined.
>
> For "http://www.tacp.toshiba.com/" do you want "tacp.toshiba.com" or just
> "toshiba.com"?  For "http://story.news.yahoo.com", is "news" included or
not?
> You can't just use the last two components in all cases, such as
> "http://www.toyota.co.jp" or "http://www.bbc.co.uk".

What I would need is just the domain name part.  In this case it would be
"toshiba.com" only.  No subdomains.  My domains will be simple
(com/net/org), so complicated situations like "toyota.co.jp" wouldn't apply.




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

Date: Sun, 14 Nov 2004 17:03:01 +0000 (UTC)
From: PerlFAQ Server <comdog@panix.com>
Subject: FAQ 5.26: How can I read in an entire file all at once?
Message-Id: <cn8345$3s8$1@reader1.panix.com>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.

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

5.26: How can I read in an entire file all at once?

    You can use the File::Slurp module to do it in one step.

            use File::Slurp;

            $all_of_it = read_file($filename); # entire file in scalar
        @all_lines = read_file($filename); # one line perl element

    The customary Perl approach for processing all the lines in a file is to
    do so one line at a time:

        open (INPUT, $file)         || die "can't open $file: $!";
        while (<INPUT>) {
            chomp;
            # do something with $_
        }
        close(INPUT)                || die "can't close $file: $!";

    This is tremendously more efficient than reading the entire file into
    memory as an array of lines and then processing it one element at a
    time, which is often--if not almost always--the wrong approach. Whenever
    you see someone do this:

        @lines = <INPUT>;

    you should think long and hard about why you need everything loaded at
    once. It's just not a scalable solution. You might also find it more fun
    to use the standard Tie::File module, or the DB_File module's $DB_RECNO
    bindings, which allow you to tie an array to a file so that accessing an
    element the array actually accesses the corresponding line in the file.

    You can read the entire filehandle contents into a scalar.

        {
            local(*INPUT, $/);
            open (INPUT, $file)     || die "can't open $file: $!";
            $var = <INPUT>;
        }

    That temporarily undefs your record separator, and will automatically
    close the file at block exit. If the file is already open, just use
    this:

        $var = do { local $/; <INPUT> };

    For ordinary files you can also use the read function.

            read( INPUT, $var, -s INPUT );

    The third argument tests the byte size of the data on the INPUT
    filehandle and reads that many bytes into the buffer $var.



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

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-2002 Tom Christiansen and Nathan
    Torkington, and other contributors as noted. All rights 
    reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.


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

Date: Sun, 14 Nov 2004 23:03:03 +0000 (UTC)
From: PerlFAQ Server <comdog@panix.com>
Subject: FAQ 7.27: How do I clear a package?
Message-Id: <cn8o77$a8c$1@reader1.panix.com>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.

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

7.27: How do I clear a package?

    Use this code, provided by Mark-Jason Dominus:

        sub scrub_package {
            no strict 'refs';
            my $pack = shift;
            die "Shouldn't delete main package"
                if $pack eq "" || $pack eq "main";
            my $stash = *{$pack . '::'}{HASH};
            my $name;
            foreach $name (keys %$stash) {
                my $fullname = $pack . '::' . $name;
                # Get rid of everything with that name.
                undef $$fullname;
                undef @$fullname;
                undef %$fullname;
                undef &$fullname;
                undef *$fullname;
            }
        }

    Or, if you're using a recent release of Perl, you can just use the
    Symbol::delete_package() function instead.



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

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-2002 Tom Christiansen and Nathan
    Torkington, and other contributors as noted. All rights 
    reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.


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

Date: 14 Nov 2004 16:45:25 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Image::EXIF troubles
Message-Id: <Xns95A177995B435asu1cornelledu@132.236.56.8>

David Dyer-Bennet <dd-b@dd-b.net> wrote in
news:m2lld4j4lf.fsf@gw.dd-b.net: 

> "A. Sinan Unur" <1usa@llenroc.ude.invalid> writes:
> 
>> David Dyer-Bennet <dd-b@dd-b.net> wrote in
>> news:m2u0rtjhlg.fsf@gw.dd-b.net: 
>>

 ...

> Here you go.  Note that this runs under mod_perl; my current best info
> suggests that the module Image::EXIF isn't compatible with mod_perl --

You might want to read 

http://perl.apache.org/docs/1.0/guide/porting.html#Exposing_Apache__Registr
y_secrets (http://tinyurl.com/4f4a5)

Also, running under mod_perl may mean different things depending on 
context. You should specify whether it is running as a so-called Registry 
script.

> somewhere down in the underlying C utility code.  I haven't chased it
> that deep.

I don't have time to either. I also don't have Image::EXIF on my system and 
don't have time to compile it. However, does the following code help? 
(untested).

#! /usr/bin/perl

# Untested

use strict;
use warnings;

use Data::Dumper;
use Image::EXIF;

use CGI;
$CGI::POST_MAX = 5000;
$CGI::DISABLE_UPLOADS = 1;

use CGI::Carp 'fatalsToBrowser';
use File::Spec 'catfile';

use constant IMAGE_DIR => 
        '/web/dd-b/SnapshotAlbum/data/2004/09180-Birthday';

run();

sub run {
    my $q = new CGI;

    my $fn = CGI->param('fn');
    $fn = '' unless defined $fn;

    # Always untaint variables ... see perldoc perlsec
    if($fn =~ /^(\w+\.jpg)$/i) {
        $fn = $1;
    } else {
        $fn = '';
    }

    $fn = catfile IMAGE_DIR, $fn;
    
    die "Cannot read $fn: $!" unless -r $fn;

    my @res;
    push @res, "File: ", $fn;
    
    my $exif = Image::EXIF->new;
    $exif->file_name($fn);
    push @res,  $exif->error ? $exif->errstr : Dumper($exif->get_all_info);
    
    print $q->header,
        $q->start_html('test'),
        $q->pre(join ("\n", @res)),
        $q->end_html;
    }
}
__END__



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

Date: Sun, 14 Nov 2004 12:18:57 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: options to shrink-wrap a perl script
Message-Id: <slrncpf8ch.p7i.tadmc@magna.augustmail.com>

David Combs <dkcombs@panix.com> wrote:
> In article <Pine.LNX.4.61.0410212252140.3299@ppepc56.ph.gla.ac.uk>,
> Alan J. Flavell <flavell@ph.gla.ac.uk> wrote:
>>On Thu, 21 Oct 2004, A. Sinan Unur wrote:
>>
>>> botfood@yahoo.com (dan baker) apparently wrote something in 
>>news:13685ef8.0410200629.47e94ab7
>>> @posting.google.com:
>>> 
>>> Thank you for providing me with an opportunity to plonk someone.
>>
>>It already worked for me.  Maybe you should try it more often  ;-)
> 
> Geez, guys -- isn't that being just a bit rough?
                      ^^^^
                      ^^^^

Which "that" is that "that"?

Assuming it is what you quoted, then the "that" is the act
of killfiling someone.

Whether the killfiling was deserved or a "bit rough" depends on
what the killee did to "earn" such treatment. (I've quoted it below.)

(I'd have to say it was deserved, as I had already killfiled
 him 3 days before the above-quoted posts were made.  :-)
)


> (that is, assuming that "plonk" means to kill-list someone;


It does.


> , just because he asked what PAR was, 


He didn't "just" ask that, he added a poke with "ok, great..",
when all he had to do was spend 10 seconds Googling (instead
he took the 10 seconds to express his displeasure at *getting an answer*
to the question that he asked).

Looks to me like he was looking for a fight rather than looking 
for his answer (or he has abysmal time-management skills), else
he would have had the complete answer in the same amount of time
that it took to complain about not getting the complete answer.

This has a negative long-term effect as it may encourage
NO answer rather than an answer for future posters.

I figure that the volunteer who answered his question had 3 choices:

   1) Give a complete-ish answer in 20, 30, 60 seconds.

   2) Provide a search term sure to lead to the problem's solution
      in 5 seconds.

   3) Skip to the next article and provide no help at all in zero seconds.


The OP's insistence that the volunteer give 60 seconds rather than
5 seconds seems likely to encourage choosing the zero-second alternative
for similar future questions.

And less people find answers.

The OP hurt the community. Becoming ostracized by the community
for such a "contribution" ought to be expected.


> he got a somewhat high-handed
> response 


He reaped what he had sown. I don't find that surprising.

[ particularly if the other sub-threads in this thread are
  considered. There it was basically one person who just
  got here telling several people who have been here many
  times that we aren't doing it "right". He didn't have
  enough experience to know better, but he didn't let that
  stop him from giving us instructions anyway.
]


> -- and it escalated, small piece by small piece, from
> there.


I think he would have been fine with the post that earned him
the above plonk he if had left out:

   You have renewed my faith that there are people in this group capable
   of demonstrating not only knowledge, but are interested in giving
   complete and thoughtful answers.

Which I expect was a bit of venting from parts of this thread
not in the ancestry of _this_ sub-thread.


> Well, let me back off a bit: you guys sure donate a *huge* amount
> of time and brainpower to clpm, day after day after day -- so I guess
> we mostly-lurkers here got to cut you some slack for a once-in-a-while
> quick, angry response -- esp after an hours-long session of 
> answering all these posts!


With all that experience comes an ability to detect bad attitude
early on. At the 1st glimmer of such, I make a killfile entry
and move on to help a more deserving poster.

(even if I end up killfiling a "good" poster for one mess-up, there
 will *still* be more posts for me to read than I want to read, so
 it costs me nothing to ignore several dozen folks, even on a whim.
)


> PS: just wondering -- when you *do* "plonk" someone,
>    is that like a death penalty (ie, permanent, 
>    never removed),


Yes, for me at least (and I expect that I am typical).


>    to, every so often, to let them out 


Nope.

In the 5 or 6 years that I've used a scorefile, I have only removed 
four people from auto-ignoration.

And 2 of them were back in there within a month, teaching me that
it probably isn't worth it taking folks out in the first place.


> -- but
>    on parole?


But I very occasionally "go slumming" down in the posts scored
below -5000 just to get reinforcement that the killfiling was
deserved, I am almost never disappointed though, so they generally
stay in.


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


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

Date: Sun, 14 Nov 2004 19:46:35 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: options to shrink-wrap a perl script
Message-Id: <Pine.LNX.4.61.0411141923460.32736@ppepc56.ph.gla.ac.uk>

On Sun, 14 Nov 2004, David Combs wrote:

> In article <Pine.LNX.4.61.0410212252140.3299@ppepc56.ph.gla.ac.uk>,
> Alan J. Flavell <flavell@ph.gla.ac.uk> wrote:
> >On Thu, 21 Oct 2004, A. Sinan Unur wrote:
[...]
> >> Thank you for providing me with an opportunity to plonk someone.
> >
> >It already worked for me.  Maybe you should try it more often  ;-)
> 
> Geez, guys -- isn't that being just a bit rough?

In the circumstances, it didn't seem unreasonable, actually.  The 
newbie did seem to be spoiling for a fight, instead of participating 
in a constructive discussion.  OK, so Abigail and Uri aren't the most 
paternal of respondents, but that -should- have been clear to anyone 
who had followed the group for at least a little while before starting 
to post to it.

> (that is, assuming that "plonk" means to kill-list someone;

Check the "jargon file" for details?  It's a widely-used term on 
usenet.

> , just because he asked what PAR was, he got a somewhat high-handed
> response -- and it escalated, small piece by small piece, from
> there.

Well, quite.  When you're the newcomer to a community, do you normally 
throw your weight about; or make a bit of effort to fit in with the 
way that the regulars like to do things?

> PS: just wondering -- when you *do* "plonk" someone,
>    is that like a death penalty (ie, permanent, 
>    never removed), 

I can't speak for anyone else, but I have a bunch of killfile sections 
which are used in rotation; from time to time I rotate the sections 
and delete the oldest one. There's a special section for those who are 
meant to stay permanently, but that's only rarely used.

Other folks prefer a rating system.


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

Date: Sun, 14 Nov 2004 13:58:34 -0500
From: "jim simpson" <jimsimpson@cox.net>
Subject: Password-protected login problem
Message-Id: <SVNld.76$tw3.64@lakeread03>

I am trying to automate the process of loggin in to a number of
password-protected financial sites and downloading my statements from them.
I've succeeded with about one-half of them. In each case, I've started with
the HTML for the login page, stripped it down to just the login FORM, and
logged in using that abbreviated login page in IE. Once I get that shortened
form working, I write a perl script using the same INPUT fields and ACTION
URL as that form. In about half the cases, that works fine -- in the other
half I'm unable to get logged in. I get an "i The page cannot be displayed"
page returned.

For example, the following script fails to login to the Scudder website
athttp://www.myscudder.com/t/index.jhtml. You can see below the abbreviated
(form-only) login page, which gets me logged in just fine.

It appears that something else is required to be submitted for those sites
where this procedure fails to login.

For obvious reasons I have obscured the User Name and the Password. I
realize someone trying to help will be handicapped by not being able to
access the site.

Can someone please help me determine what else is required for the several
sites that have failed to login using this procedure?

Thanks,

Jim

########################################################
#! perl -w

use strict;

use LWP;
use HTTP::Cookies;

my $https_loginform =
"https://investments.scudder.com/t/index.jhtml?_DARGS=%2Ft%2Fhome%2Fcustomiz
e_areas%2Fhome_login.jhtml";

my $https_user = 'xxxxxx';
my $https_pass = 'xxxxxx';

my $browser = LWP::UserAgent->new();
$browser->protocols_allowed( ['https'] );
$browser->cookie_jar(HTTP::Cookies->new(file => "abccookies.txt", autosave
=> 1));

# Following is the "abbreviated" login in page, which works fine to get
# me logged in with a browser.
#
#<html>
#  <head>
#    <title>Scudder Login</title>
#  </head>
#  <body>
#    <form method="post"
action="https://investments.scudder.com/t/index.jhtml?_DARGS=%2Ft%2Fhome%2Fc
ustomize_areas%2Fhome_login.jhtml">
#      <input type="hidden" name="/direct/login/LoginForm.login"
value="xxxxxx">
#      <input type="hidden" name="_D:/direct/login/LoginForm.login" value="
">
#      <input type="hidden" name="/direct/login/LoginForm.password"
value="xxxxxx">
#      <input type="hidden" name="_D:/direct/login/LoginForm.password"
value=" ">
#      <input type="submit" name="submit" value="&nbsp;&nbsp;Log
in&nbsp;&nbsp;">
#      <input type="hidden" name="_D:submit" value=" ">
#      <input type="hidden" name="/direct/login/LoginForm.successUrl"
value="/t/login/ruby_slippers.jhtml">
#      <input type="hidden" name="_D:/direct/login/LoginForm.successUrl"
value=" ">
#      <input type="hidden" name="/direct/login/LoginForm.profileResetUrl"
value="/t/index.jhtml?content=/t/login/reset_password.jhtml">
#      <input type="hidden"
name="_D:/direct/login/LoginForm.profileResetUrl" value=" ">
#      <input type="hidden" name="/direct/login/LoginForm.alternateUrl"
value="/t/index.jhtml?content=/t/registration/index.jhtml">
#      <input type="hidden" name="_D:/direct/login/LoginForm.alternateUrl"
value=" ">
#      <input type="hidden" name="/direct/login/LoginForm.errorUrl"
value="/t/index.jhtml?content=/t/login/returnlogin.jhtml">
#      <input type="hidden" name="_D:/direct/login/LoginForm.errorUrl"
value=" ">
#    </form>
#  </body>
#</html>
#
# End of abbreviated login page.

my $response = $browser->post($https_loginform,
[
  '/direct/login/LoginForm.login'              => $https_user,
  '_D:/direct/login/LoginForm.login'           => ' ',
  '/direct/login/LoginForm.password'           => $https_pass,
  '_D:/direct/login/LoginForm.password'        => ' ',
  'submit'                                     => '&nbsp;&nbsp;Log
in&nbsp;&nbsp;',
  '_D:submit'     => ' ',
  '/direct/login/LoginForm.successUrl'         =>
'/t/login/ruby_slippers.jhtml',
  '_D:/direct/login/LoginForm.successUrl'      => ' ',
  '/direct/login/LoginForm.profileResetUrl'    =>
'/t/index.jhtml?content=/t/login/reset_password.jhtml',
  '_D:/direct/login/LoginForm.profileResetUrl' => ' ',
  '/direct/login/LoginForm.alternateUrl'       =>
'/t/index.jhtml?content=/t/registration/index.jhtml',
  '_D:/direct/login/LoginForm.alternateUrl'    => ' ',
  '/direct/login/LoginForm.errorUrl'           =>
'/t/index.jhtml?content=/t/login/returnlogin.jhtml',
  '_D:/direct/login/LoginForm.errorUrl'        => ' '
] );

if ($response->is_error())
{
  printf "Error on POST: %s\n", $response->status_line;
}
else
{
  open my $fh, '> abclogin.html' or die $!;
  print $fh $response -> content;
  close $fh;
}




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

Date: Mon, 15 Nov 2004 00:17:58 -0500
From: Augustus <augustus74@cox.net>
Subject: Problems with using Autoloader
Message-Id: <faMld.2065$nj.1890@lakeread01>

  I am using perl 5.005 on solaris 8.0. I have also tried this with 
5.8.x on linux.

Here is my problem.
I am trying to use AutoLoader functionality in one of my modules.

I have put
use AutoLoader 'AUTOLOAD' ;

and my functions (e.g. testProc) after __END__ in my module file.

I generated the module by h2xs -Xn myModule
then edited the myModule/myModule.pm with the the data above.

After that perl Makefile.pl PREFIX=$HOME/myPerlModules

After that "make install", which installs the module in $HOME/myPerlModules.
It also creates the auto/myModules dir with the necessary files under
$HOME/myPerlModules.

Now in my script I do

use lib '/home/user/myPerlModules' ;
use AutoLoader 'AUTOLOAD' ;
testProc("123");

I get the message
Can't localte auto/main/testProc.al in @INC ....

My question is , why is it looking for auto/main instead of auto/testProc ?
I also tried myModule::testProc , but I get can't locate
myModule/testProc.pm

I also tried
use myModule 'testProc' ; But I get testProc is not exported. I haven't
added testProc to @EXPORT or @EXPORT_OK, but I thought with AutoLoader it
is not needed.

So what am I missing here ? any help greatly appriciated .


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

Date: Sun, 14 Nov 2004 19:38:10 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Problems with using Autoloader
Message-Id: <cn8bv5$27u$1@sun3.bham.ac.uk>



Augustus wrote:
>  I am using perl 5.005 on solaris 8.0. I have also tried this with 5.8.x 
> on linux.
> 
> Here is my problem.
> I am trying to use AutoLoader functionality in one of my modules.
> 
> I have put
> use AutoLoader 'AUTOLOAD' ;
> 
> and my functions (e.g. testProc) after __END__ in my module file.
> 
> I generated the module by h2xs -Xn myModule
> then edited the myModule/myModule.pm with the the data above.
> 
> After that perl Makefile.pl PREFIX=$HOME/myPerlModules
> 
> After that "make install", which installs the module in 
> $HOME/myPerlModules.
> It also creates the auto/myModules dir with the necessary files under
> $HOME/myPerlModules.
> 
> Now in my script I do
> 
> use lib '/home/user/myPerlModules' ;
> use AutoLoader 'AUTOLOAD' ;
> testProc("123");
> 
> I get the message
> Can't localte auto/main/testProc.al in @INC ....
> 
> My question is , why is it looking for auto/main instead of auto/testProc ?

Becuase it was main that installed AutoLoader.  There is nothing in your 
  script that even mentioned myModule.

You need to use myModule not AutoLoader in your script.  For example see 
any module that uses AutoLoader.

> I also tried myModule::testProc , but I get can't locate
> myModule/testProc.pm

I do not believe you.

> I also tried
> use myModule 'testProc' ; But I get testProc is not exported. I haven't
> added testProc to @EXPORT or @EXPORT_OK, but I thought with AutoLoader it
> is not needed.

You thought wrong.

> So what am I missing here ?

It's not so much that you are missing something but that you are seeing 
something that is not there.  The AutoLoader and Exporter menchanisms 
are more-or-less orthogonal.



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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