[22055] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4277 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 18 00:05:37 2002

Date: Tue, 17 Dec 2002 21:05:07 -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           Tue, 17 Dec 2002     Volume: 10 Number: 4277

Today's topics:
    Re: comparing mangled times perlistically! <goldbb2@earthlink.net>
    Re: ExtUtils::MakeMaker: installing scripts to sbin? <comdog@panix.com>
    Re: FTPing without Net::FTP <jurgenex@hotmail.com>
        getstore not working - please help (Dennis Macdonald)
    Re: getstore not working - please help <bwalton@rochester.rr.com>
    Re: help:  perl script to make all DNA sequence Nmers? ctcgag@hotmail.com
    Re: Is it safe to return a reference to local or lexica <bart.lateur@pandora.be>
    Re: Linux vs. SunOS: $1 $2 match ctcgag@hotmail.com
    Re: Linux vs. SunOS: $1 $2 match <bwalton@rochester.rr.com>
    Re: Linux vs. SunOS: $1 $2 match <mgjv@tradingpost.com.au>
    Re: Mail::POP3Client faliure,...? <cmustard_!SPAM@nyc.rr.com>
    Re: members area in perl ??? <control153@NOSPAMyahoo.com>
    Re: Net::SMTP error <goldbb2@earthlink.net>
        Printing from within an XSub ctcgag@hotmail.com
    Re: stdin binary or text ? <bart.lateur@pandora.be>
    Re: stdin binary or text ? <flavell@mail.cern.ch>
        using perl to download wsj.com pages , with user id and (R Solberg)
    Re: using perl to download wsj.com pages , with user id <mgjv@tradingpost.com.au>
    Re: using perl to download wsj.com pages , with user id <mbudash@sonic.net>
    Re: using perl to download wsj.com pages , with user id <nobody@dev.null>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 17 Dec 2002 23:49:54 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: comparing mangled times perlistically!
Message-Id: <3DFFFE72.2E3AD885@earthlink.net>

Benjamin Goldberg wrote:
[snip]
>       # YYYYMMDDTHHMMSS.IIIIII
>       my ($YYYY, $MM, $DD, $hh, $mm, $ss, $us) =
>          unpack( 'A4 A2 A2 x A2 A2 A2 x A4', $_->[$i] );

I need to add a line here:

        $MM -= 1;

This is because the sample data shows a month of '12', indicating that
your month is 1..12.  But timelocal() expects the input month to be in
the same range as localtime() produces, namely 0..11.  Subtracting 1
fixes that.

I could also add:

        $YYYY -= 1900;

This isn't really necessary, as timelocal is clever enough to do that
itself, if needed, but putting it in reminds us that the year that
localtime produces is 'current year minus 1900', NOT 'last two digits of
current year'.

>       timelocal( $ss, $mm, $hh, $DD, $MM, $YYYY ) +
>          ($us / 1_000_000);

-- 
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r  coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);


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

Date: Tue, 17 Dec 2002 18:12:20 -0600
From: brian d foy <comdog@panix.com>
Subject: Re: ExtUtils::MakeMaker: installing scripts to sbin?
Message-Id: <171220021812209387%comdog@panix.com>

In article <9d4ea49.0212171337.556f7028@posting.google.com>, Paul Cody
Johnston <pcj-google@inxar.org> wrote:

> $ perl Makefile.PL INSTALLSCRIPT=/usr/sbin

> But of course that puts the onus on the user to put things in the
> right place.  Does there not exist the notion of a system binary
> directory in MakeMaker?


you can put that directly in your WriteMakefile:

WriteMakefile(
 
   ...

   'INSTALLSCRIPT' => '/usr/sbin',

   ...   
   );

you may want consider prompting the user for an installation
location, then putting it where the user wants.

-- 
brian d foy, comdog@panix.com


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

Date: Wed, 18 Dec 2002 03:41:45 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: FTPing without Net::FTP
Message-Id: <Z7SL9.43166$_S2.12946@nwrddc01.gnilink.net>

Cold Cathoid wrote:
> I am looking to write a perl script that does a rather simple task. I
> need to ftp a directory of files from a remote server. The remote
> server requires a login and password. I did some research and the
> Net::FTP would be really handy. Unfortunently it's not installed on
> the box I am using. I talked to our sysadmin and he said he could
> install it ... one day ... he figures in a couple months he could get
> around to it. It's not high on his list of priorities.

Then, why don't you just install it yourself?
perldoc -q modules: "How do I keep my own module/library directory?"
jue




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

Date: 17 Dec 2002 18:45:16 -0800
From: newsgroups@bandwood.com (Dennis Macdonald)
Subject: getstore not working - please help
Message-Id: <d98b592e.0212171845.3be4637a@posting.google.com>

Hi,

Below is the code that I'm using. The status returned is OK but
nothing is downloaded. Can anyone help me with why and how to fix it.


use LWP::Simple;
use HTTP::Status;

my $remote="http://www.bandwood.com/_testdir/winzip.zip";
my $local="winzip.zip";
my $rc = &getstore($remote,$local);
if ($rc != RC_OK) { print status_message($rc), "\n"; }
print ("#########\n");
print ("Download Status = " . status_message($rc). "\n");
print ("#########\n");



RETURNS:

######### Download Status = OK ######### 


If you take http://www.bandwood.com/_testdir/winzip.zip and paste it
into a browser it will work, so the path is correct.


Thanks,
Dennis.


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

Date: Wed, 18 Dec 2002 03:03:39 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: getstore not working - please help
Message-Id: <3DFFE58F.5070608@rochester.rr.com>

Dennis Macdonald wrote:

> Hi,
> 
> Below is the code that I'm using. The status returned is OK but
> nothing is downloaded. Can anyone help me with why and how to fix it.
> 
> 
> use LWP::Simple;
> use HTTP::Status;
> 
> my $remote="http://www.bandwood.com/_testdir/winzip.zip";
> my $local="winzip.zip";
> my $rc = &getstore($remote,$local);
> if ($rc != RC_OK) { print status_message($rc), "\n"; }
> print ("#########\n");
> print ("Download Status = " . status_message($rc). "\n");
> print ("#########\n");
> 
> 
> 
> RETURNS:
> 
> ######### Download Status = OK ######### 
> 
> 
> If you take http://www.bandwood.com/_testdir/winzip.zip and paste it
> into a browser it will work, so the path is correct.
 ...
> Dennis.
> 

Your code copy/pasted verbatim works just fine on my system.  It 
downloaded a file called winzip.zip, which, when unzipped, contained a 
gif file of the WinZip logo.  AS Perl build 633, Windoze 98SE.

Are you sure that's not what your system did too?
-- 
Bob Walton



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

Date: 18 Dec 2002 01:28:00 GMT
From: ctcgag@hotmail.com
Subject: Re: help:  perl script to make all DNA sequence Nmers?
Message-Id: <20021217202800.987$P5@newsreader.com>

isen@molbio.mgh.harvard.edu (isen) wrote:
> does anyone have a perl script to make all possible DNA sequence Nmers
> (and put in an array preferably) when given N as an input?


warn "Untested Code";
sub Nmer {
  die unless $_[0];
  return qw/A C T G/ if $_[0]==1;
  return map {$_.'A', $_.'C', $_.'T', $_.'G'} Nmer($_[0]-1);
};



> Please
> reply by email (sindriATmacDOTcom) if possible.

Sorry, no dice.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: Wed, 18 Dec 2002 00:46:10 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Is it safe to return a reference to local or lexical data?
Message-Id: <6igvvukoigg9tqkv1pp1dboq4etf09o6c2@4ax.com>

Christian Caron wrote:

>I thought print "@many\n"; would return numbers:
>
>1 2 3 4 5 6 7 8 9 10
>1 2 3 4 5...
>
>Maybe it's my misunderstanding of (Perl | English | FAQ)... 

Perhaps. If you indeed want "@many" to print something like the above
(except that there can't be newlines between the arrays), it *is*
possible, with the overload mechanism. In this case, bless what
makeone() returns, and overload q[""] for that package. Like:

	package Array;

	sub new {
	    my $pkg = shift;
	    return bless [ @_ ], $pkg;
	}

	use overload q[""] => \&stringify;

	sub stringify {
	    my $self = shift;
	    return "@$self";
	}

To be used like this:

	for my $i ( 1 .. 10 ) {
	    push @many, new Array(1 .. 10);
	}
	print "@many\n";

Or, if you insist on the low level approach (as I described above):

	sub makeone {
	    my @a = (1 .. 10);
	    return bless \@a, 'Array';
	}
	for my $i ( 1 .. 10 ) {
	    push @many, makeone();
	}
	print "@many\n";

The sub new is just a wrapper to return a blessed array reference.

I don't know if it's possible to overload q[""] by default for *all*
(unblessed) array references...

-- 
	Bart.


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

Date: 18 Dec 2002 01:43:53 GMT
From: ctcgag@hotmail.com
Subject: Re: Linux vs. SunOS: $1 $2 match
Message-Id: <20021217204353.798$Kd@newsreader.com>

"Eric" <emagnuss@yahoo.com> wrote:
> The following program returned different values on Linux than SunOs.
> (The SunOs had the expected result).  Is this a bug, or a "feature".
>
> $_ = "7 x";
>
> if (/^\d/) {
>    m/(\d+)\s*(\w+)/;
> } else {
>    m/(\w+)/;
> }
> my $a = $1;
> my $b = $2;
> print ":$a:$b:\n";
>
> __Results__
>
> -- sun4u sparc SUNW,Ultra-5_10 --
> :7:x:
>
> -- Linux 2.4.9 --
> :::

I get the same answer (the second one) on both Linux and SunOS.
Both have 5.6.1.  What version of Perl do you have on each machine?

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: Wed, 18 Dec 2002 02:55:42 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Linux vs. SunOS: $1 $2 match
Message-Id: <3DFFE3B3.6000900@rochester.rr.com>

ctcgag@hotmail.com wrote:

> "Eric" <emagnuss@yahoo.com> wrote:
> 
>>The following program returned different values on Linux than SunOs.
>>(The SunOs had the expected result).  Is this a bug, or a "feature".
>>
>>$_ = "7 x";
>>
>>if (/^\d/) {
>>   m/(\d+)\s*(\w+)/;
>>} else {
>>   m/(\w+)/;
>>}
>>my $a = $1;
>>my $b = $2;
>>print ":$a:$b:\n";
>>
>>__Results__
>>
>>-- sun4u sparc SUNW,Ultra-5_10 --
>>:7:x:
>>
>>-- Linux 2.4.9 --
>>:::
>>
> 
> I get the same answer (the second one) on both Linux and SunOS.
> Both have 5.6.1.  What version of Perl do you have on each machine?
> 
> Xho
> 
> 

The problems have to do with variable scope.  The $1 and $2 variables 
stick around only for the current block.  So once the if() block is 
existed, they go poof.  Try:

  $_ = "7 x";
  my $a;
  my $b;
  if (/^\d/) {
    m/(\d+)\s*(\w+)/ and
    ($a,$b)=($1,$2);
  } else {
    m/(\w+)/ and
    $a=$1;
  }
  print ":$a:$b:\n";

Note that declaring "my $a=$1; in the if block wouldn't work either, 
because the lexical variable $a would go out of scope.  See:

   perldoc perlvar

and look for $<digits> .

And BTW, always check a match for success before using the number 
variables from the match.  You might get a surprise if the match doesn't 
succeed if you don't check.

The OP's difference was probably due to the use of an ancient version of 
Perl on the SunOS system.  And the "expected result" is the one Linux 
gave, not the SunOS version, at least for all but ancient Perl versions.
-- 
Bob Walton



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

Date: Wed, 18 Dec 2002 04:20:36 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Linux vs. SunOS: $1 $2 match
Message-Id: <slrnavvu0a.865.mgjv@verbruggen.comdyn.com.au>

On Wed, 18 Dec 2002 02:55:42 GMT,
	Bob Walton <bwalton@rochester.rr.com> wrote:
> ctcgag@hotmail.com wrote:
> 
>> "Eric" <emagnuss@yahoo.com> wrote:
>> 
>>>The following program returned different values on Linux than SunOs.
>>>(The SunOs had the expected result).  Is this a bug, or a "feature".
>>>
>>>$_ = "7 x";
>>>
>>>if (/^\d/) {
>>>   m/(\d+)\s*(\w+)/;
>>>} else {
>>>   m/(\w+)/;
>>>}
>>>my $a = $1;
>>>my $b = $2;
>>>print ":$a:$b:\n";
>>>
>>>__Results__
>>>
>>>-- sun4u sparc SUNW,Ultra-5_10 --
>>>:7:x:
>>>
>>>-- Linux 2.4.9 --
>>>:::
>>>
>> 
>> I get the same answer (the second one) on both Linux and SunOS.
>> Both have 5.6.1.  What version of Perl do you have on each machine?
>> 
>> Xho
>> 
>> 
> 
> The problems have to do with variable scope.  The $1 and $2 variables 
> stick around only for the current block.  So once the if() block is 
> existed, they go poof.  Try:

#!/usr/local/bin/perl -w
use strict;

$_ = 17;
if (/(\d+)/)
{
    print "Here, \$1 is '$1'\n";
}
print "There, \$1 is '$1'\n";

produces the same result for various versions of Perl, on various
platforms (5.005_03 and 5.6.1 on Solaris, 5.6.1 and 5.8.0 on linux),
and that result is consistent with the fact that $1 is not localised
to the if() block. And it shouldn't be.

Note, BTW, that the scope of that if() block is from the opening brace
to the closing brace. The conditional is not part of that block. If
you have a while() block, things are different. If you have a for()
block, things are the same as with if. Confusing? You betcha.

To play with that a bit, use something like:

#!/usr/local/bin/perl -w
use strict;

$_ = 17;
/(\d)$/;
print "First, \$1 is $1\n";
if (/(\d+)/g)
{
    print "Here, \$1 is '$1'\n";
    /(\d)/;
    print "Now, \$1 is '$1'\n";
}
print "There, \$1 is '$1'\n";

And replace the "if" with "for" and "while".

[BTW, this exposes a documentation bug in perlsyn. It states:

    Unlike a "foreach" statement, a "while" statement never implicitly
    localises any vari­ ables.

which, as is shown by the above code (with a while replacing the if)
is patently not true, since $1 is 7 before the while statement, and 7
afterwards, but not inbetween. On the other hand, for loops do not
implicitly localise these variables. I'll report this, if it hasn't
been reported already.]

>   $_ = "7 x";
>   my $a;
>   my $b;
>   if (/^\d/) {
>     m/(\d+)\s*(\w+)/ and
>     ($a,$b)=($1,$2);
>   } else {
>     m/(\w+)/ and
>     $a=$1;
>   }
>   print ":$a:$b:\n";
> 
> Note that declaring "my $a=$1; in the if block wouldn't work either, 

No, it wouldn't, because the _lexical_ scope of that $a variable would
be limited to the block. Outside of it, you would be accessing the
_global_ $a (BTW, $a and $b are special. They are not good example
variables when you talk about scope).

> because the lexical variable $a would go out of scope.  See:
> 
>    perldoc perlvar
> 
> and look for $<digits> .

Yes, but you'd also need to read perlsyn (I am not even sure that it's
all explained in there, see section Compound statements), and be aware
quite well of what a block is in Perl, and how some constructions
limit scope or extend scope slightly.  You should probably also read
what perlre has to say about the scoping of $1 etc, since it is
slightly different.

It is confusing, and I believe work is being done in Perl 6 to get rid
of that confusion.

> And BTW, always check a match for success before using the number 
> variables from the match.  You might get a surprise if the match doesn't 
> succeed if you don't check.

Indeed. $1 will be set to whatever it was set for before you attempted
the match.

Martien
-- 
                        | 
Martien Verbruggen      | The four horsemen of the apocalypse are
Trading Post Australia  | called Abort, Retry, Ignore and Fail.
                        | 


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

Date: Tue, 17 Dec 2002 23:33:11 GMT
From: mUs <cmustard_!SPAM@nyc.rr.com>
Subject: Re: Mail::POP3Client faliure,...?
Message-Id: <slrnavvd9v.cu.cmustard_!SPAM@nyc.rr.com>

In article <uvtm81gk3pnu62@corp.supernews.com>, Rod wrote:
> "mUs" <cmustard_!SPAM@nyc.rr.com> wrote in message
> news:slrnavtb74.1c3.cmustard_!SPAM@nyc.rr.com...
>>
>> Ok, this is very frustrating, 2 days and many hours worth! I have used
> this
>> module/lib (libwww) before with ease (on other distro's). I just installed
>> this module on my Debian Woody 3.0 box and it's not working.
>> It seems like an encryption error (?).
>>
>> The following is the exact script i am trying to run, (except with my
>> personal info removed) and below is the Debugging info i'm getting.
>>
>> All my supplied data is correct, (i.e. username and password, i use the
> exact
>> same info for ~/.fetchmailrc and i retrieve mail fine. I am including a
>> Microsoft pop-server and a 'unknown' although probably some form of
>> *NIX server.
>>
>> I was also reciveing some MD5.pm error's although they seem be gone.
>> I would appreciate any info, guidance or help anyone could provide.
>> thank you.
>>
>> -mUs.
>>
>> <script>
>> #!/usr/bin/perl -w
>>
>> use Mail::POP3Client;
>> use strict;
>> use warnings;
>>
>> my($pop,$usr,$passwd,$host,$i);
>> $usr = 'me@me.com';
>> $passwd = 'clear_text';
>> $host = 'pop.me.com';
>>
> It worked for me just by changing the me@me.com to my username without the
> domain?
> Tested on Suse 8.1 Linux client connecting to RH (I think)Servers.
> 
> BTW: I didn't have any new mail :-) In Case You were Wondering.
> 

-thanks, this did work for two servers but not the third,... Odd i took these
calling methods right out to the documentation,.... i can't believe this was
it, of all the stuff i did try, i didn't try that. Thanks again.



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

Date: Wed, 18 Dec 2002 04:36:45 GMT
From: opt cool dude <control153@NOSPAMyahoo.com>
Subject: Re: members area in perl ???
Message-Id: <Xns92E7F09B8676Acontrol153NOSPAMyaho@167.206.3.2>

what i mean .. i have seen many tutorials on creating a members area in php  
(eg: http://www.devarticles.com/art/1/241) using php + mysql with sessions
but i have not seen one for perl .... is something like this possible to do 
in perl ??? 
thanks 
newbee here 



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

Date: Wed, 18 Dec 2002 00:00:28 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Net::SMTP error
Message-Id: <3E0000EC.DEF57101@earthlink.net>

Andrew Burton wrote:
> 
> > It could be that you don't have
> > permission to connect to
> > learning.wccs.edu, so $smtp is
> > undefined.  You should always check
> > this using something like:
> 
> Well, I'm writing this on elearning.wccs.edu as root...  I thought
> that would give me access, but I'll give that a whirl.  Thanks!

Remember that SMTP is a network protocol -- the smtp server doesn't know
that your perl script has root access.

Oh, and perhaps more important... do you *have* an smtp server?  If not,
then there's nothing on your machine for Net::SMTP to connect to.

Find out what SMTP server your other programs use, and use that.  Eg, on
Netscape 4.04, I can do Edit->Preferences->Mail & Groups->Mail Server,
and in the "Outgoing Mail (SMTP) Server" it says "mail.earthlink.net".

-- 
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r  coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);


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

Date: 18 Dec 2002 02:23:53 GMT
From: ctcgag@hotmail.com
Subject: Printing from within an XSub
Message-Id: <20021217212353.379$nd@newsreader.com>

I have some C code that uses 'printf' to "return" it's results, and
I'm trying wrap it in XS.  I was hoping to avoid having to muck with
the C I/O by hacking redirects together just using perl, but I'm not
having much luck.

use strict;
use ExtUtils::testlib;
use Tan;
# //Tan is this *.xs
# void
# hello()
# CODE:
# printf("Hello World\n");

##open STDOUT, ">>output.txt" or die $!;
foreach (1..100) {
  ###open STDOUT, ">>output.txt" or die $!;
  print "Starting $_\n";
  Tan::hello();
  ###close STDOUT or die $!;
};
##close STDOUT or die $!;

If I don't reopen STDOUT, I get what I expected,
100 "Starting" interspersed with 100 "Hello World" on
my terminal.

Using just the outer 'open STDOUT', I get what I expect in the file
output.txt.

Using just the inner 'open STDOUT', I get all 100 "Starting", but only
the first "Hello World", in the file output.txt (and nothing to the
terminal, so the other 99 Hello World are lost)

So it looks like I can change STDOUT once, and have the XSub
honer that redirection, but the second and later changes to STDOUT are
not handled well for the XSub.

Is there a way to accomplish this redirection in Perl
(that is less painfull than simply re-learning C i/o)?

Thanks,

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: Wed, 18 Dec 2002 00:31:35 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: stdin binary or text ?
Message-Id: <g8gvvuoclr9bjrekcec9du3a30v2hefhvc@4ax.com>

Alan J. Flavell wrote:

>On platforms which use \015\012 as their native newline
>representation, \015\012 (carriage-return followed by line-feed)
>_is_ the external embodiment of a newline (the logical \n function).

Yes... but that's not  how Perl works with it. One these platforms, in
text mode, "\n" IS "\012". It is when printing to a file handle in text
mode that "\012" is substituted by "\015\012". binmode() on that handle
prevents this conversion. Likewise, when reading from a file/handle,
"\015\012" is converted to "\012", whether you use <FH>, rad(),
sysread(), or what else. Again, binmode() prevents this conversion.

"\n" still is just one character in a string in Perl.

-- 
	Bart.


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

Date: Wed, 18 Dec 2002 02:01:33 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: stdin binary or text ?
Message-Id: <Pine.LNX.4.40.0212180153080.21288-100000@lxplus033.cern.ch>

On Dec 18, Bart Lateur inscribed on the eternal scroll:

> Alan J. Flavell wrote:
>
> >On platforms which use \015\012 as their native newline
> >representation, \015\012 (carriage-return followed by line-feed)
> >_is_ the external embodiment of a newline (the logical \n function).
>
> Yes... but that's not  how Perl works with it.

Right - well, it _is_ if you read it in binmode.  Which is why I
referred the questioner to perlport for more insights.

> One these platforms, in text mode, "\n" IS "\012".

right.  in text mode.  And provided you don't have to handle
cross-platform text data.

It's arguable (though I know the argument isn't a hard and fast one)
that if you need to handle *cross-platform* text data then you're
better off by using binmode and looking for \015 and/or \012 yourself.

> It is when printing to a file handle in text
> mode that "\012" is substituted by "\015\012".

If you're on one of the platforms which does that, indeed.

> "\n" still is just one character in a string in Perl.

Even in utf-8  ;-)

But don't forget that on at least one platform (the one that goes
upstream by going downstream, in the Nile/Euphrates analogy), that
one character is \015.




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

Date: 17 Dec 2002 19:37:32 -0800
From: flateyjarbok@yahoo.com (R Solberg)
Subject: using perl to download wsj.com pages , with user id and password
Message-Id: <386cc483.0212171937.3296264d@posting.google.com>

Hi,
I am trying to download pages from wsj.com, but I am unsuccessful.  I
am using the following (and I get the error message listed at the
bottom).  Appreciate any help, as I am a semi-newbie :-)  Please write
back to flateyjarbok@yahoo.com

use LWP::UserAgent;

$folder="C:\\My Documents\\WSJDaily01\\";

    my $req = new HTTP::Request "POST",
    "http://online.wsj.com/documents/mktindex.htm?diaries.htm";
	  $req->authorization_basic('userid', 'password');

    my $u = new LWP::UserAgent;
    my $content = $u->request($req)->content;


((((((((((((((((((((((((((((((

But I am getting the following download only.

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>302 Found</TITLE>
</HEAD><BODY>
<H1>Found</H1>
The document has moved <A
HREF="https://online.wsj.com/wsjra/servlet/WSJAuthReg?URI=%2Fdocuments%2Fmktindex.htm%3Fdiaries.htm">here</A>.<P>
<HR>
<ADDRESS>IBM_HTTP_Server/1.3.12.1 Apache/1.3.12 Server at
interactive.wsj.com Port 80</ADDRESS>
</BODY></HTML>


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

Date: Wed, 18 Dec 2002 04:30:23 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: using perl to download wsj.com pages , with user id and password
Message-Id: <slrnavvuil.865.mgjv@verbruggen.comdyn.com.au>

On 17 Dec 2002 19:37:32 -0800,
	R Solberg <flateyjarbok@yahoo.com> wrote:
> Hi,
> I am trying to download pages from wsj.com, but I am unsuccessful.  I
> am using the following (and I get the error message listed at the
> bottom).  Appreciate any help, as I am a semi-newbie :-)  Please write
> back to flateyjarbok@yahoo.com

Nope. You post here, you read here.

> use LWP::UserAgent;
>
> $folder="C:\\My Documents\\WSJDaily01\\";

$folder = "c:/My Documents/WSJDaily01/";

>     my $req = new HTTP::Request "POST",
>     "http://online.wsj.com/documents/mktindex.htm?diaries.htm";
> 	  $req->authorization_basic('userid', 'password');
> 
>     my $u = new LWP::UserAgent;
>     my $content = $u->request($req)->content;

><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
><HTML><HEAD>
><TITLE>302 Found</TITLE>

Is the response code indeed a 302 (Whatever HTML gets returned by the
server is of no use here)? LWP::UserAgent automatically follows
redirects for HEAD and GET requests only. The documentation of the
module states so under the explanation of the new() method, with the
attribute requests_redirectable.

Martien
-- 
                        | 
Martien Verbruggen      | 
Trading Post Australia  | In a world without fences, who needs Gates?
                        | 


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

Date: Wed, 18 Dec 2002 04:30:21 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: using perl to download wsj.com pages , with user id and password
Message-Id: <mbudash-7DD147.20302017122002@typhoon.sonic.net>

In article <386cc483.0212171937.3296264d@posting.google.com>,
 flateyjarbok@yahoo.com (R Solberg) wrote:

> Hi,
> I am trying to download pages from wsj.com, but I am unsuccessful.  I
> am using the following (and I get the error message listed at the
> bottom).  Appreciate any help, as I am a semi-newbie :-)  Please write
> back to flateyjarbok@yahoo.com
> 
> use LWP::UserAgent;
> 
> $folder="C:\\My Documents\\WSJDaily01\\";
> 
>     my $req = new HTTP::Request "POST",
>     "http://online.wsj.com/documents/mktindex.htm?diaries.htm";
> 	  $req->authorization_basic('userid', 'password');
> 
>     my $u = new LWP::UserAgent;
>     my $content = $u->request($req)->content;
> 
> 
> ((((((((((((((((((((((((((((((
> 
> But I am getting the following download only.
> 
> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
> <HTML><HEAD>
> <TITLE>302 Found</TITLE>
> </HEAD><BODY>
> <H1>Found</H1>
> The document has moved <A
> HREF="https://online.wsj.com/wsjra/servlet/WSJAuthReg?URI=%2Fdocuments%2Fmktin
> dex.htm%3Fdiaries.htm">here</A>.<P>
> <HR>
> <ADDRESS>IBM_HTTP_Server/1.3.12.1 Apache/1.3.12 Server at
> interactive.wsj.com Port 80</ADDRESS>
> </BODY></HTML>

er, then try getting:

https://online.wsj.com/wsjra/servlet/WSJAuthReg?URI=%2Fdocuments%2Fmktind
ex.htm%3Fdiaries.htm

hth-


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

Date: Wed, 18 Dec 2002 05:00:14 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: using perl to download wsj.com pages , with user id and password
Message-Id: <3E00004C.1040808@dev.null>



Michael Budash wrote:

> In article <386cc483.0212171937.3296264d@posting.google.com>,
>  flateyjarbok@yahoo.com (R Solberg) wrote:
> 
> 
>>Hi,
>>I am trying to download pages from wsj.com, but I am unsuccessful.  I
>>am using the following (and I get the error message listed at the
>>bottom).  Appreciate any help, as I am a semi-newbie :-)  Please write
>>back to flateyjarbok@yahoo.com
>>
>>use LWP::UserAgent;
>>
>>$folder="C:\\My Documents\\WSJDaily01\\";
>>
>>    my $req = new HTTP::Request "POST",
>>    "http://online.wsj.com/documents/mktindex.htm?diaries.htm";
>>	  $req->authorization_basic('userid', 'password');
>>
>>    my $u = new LWP::UserAgent;
>>    my $content = $u->request($req)->content;
>>
>>
>>((((((((((((((((((((((((((((((
>>
>>But I am getting the following download only.
>>
>><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
>><HTML><HEAD>
>><TITLE>302 Found</TITLE>
>></HEAD><BODY>
>><H1>Found</H1>
>>The document has moved <A
>>HREF="https://online.wsj.com/wsjra/servlet/WSJAuthReg?URI=%2Fdocuments%2Fmktin
>>dex.htm%3Fdiaries.htm">here</A>.<P>
>><HR>
>><ADDRESS>IBM_HTTP_Server/1.3.12.1 Apache/1.3.12 Server at
>>interactive.wsj.com Port 80</ADDRESS>
>></BODY></HTML>
>>
> 
> er, then try getting:
> 
> https://online.wsj.com/wsjra/servlet/WSJAuthReg?URI=%2Fdocuments%2Fmktind
> ex.htm%3Fdiaries.htm
> 
> hth-
> 

Also, notice that what wsj.com is using is not basic authorization, so 
saying

$req->authorization_basic('userid', 'password');

is not going to magically get you in (even if I assume that you have a 
valid userid and password).

What you have instead is a web form that your script needs to be able to 
fill out correctly.

perldoc -q submission

will tell you how you can do that.




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

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.  

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


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