in reply to Re: LWP not returning leading spaces in web page
in thread LWP not returning leading spaces in web page

This is helping to narrow down the problem. I made two small changes to your code and now I can replicate the problem.

#!/usr/bin/perl -d use LWP; use strict; use warnings; my $ua = new LWP::UserAgent; my $r = $ua->get("http://groups.yahoo.com"); if ($r->is_success) { if ($r->content =~ m/^\s+\S$/m) { print "I saw some trailing spaces...\n"; } else { print "Oppsie! I did not see any trailing spaces...\n"; } } else { die "Failed miserably\n"; }

I updated the regex to (I believe) properly look for individual lines with leading spaces and some text. Then I tried a different web page. The problem now appears.

If you actually print out the content $ua->content, you'll see that LWP doesn't print any of the leading spaces that Mozilla View Source does show!

I'd really like to understand what's happening here!

Andy

@_="the journeyman larry disciple keeps learning\n"=~/(.)/gs, print(map$_[$_-77],unpack(q=c*=,q@QSdM[]uRMNV^[ni_\[N]eki^y@))

Replies are listed 'Best First'.
Re3: LWP not returning leading spaces in web page
by Hofmator (Curate) on Feb 01, 2003 at 10:17 UTC
    I updated the regex to (I believe) properly look for individual lines with leading spaces and some text.if ($r->content =~ m/^\s+\S$/m)

    Your regex doesn't do what you claim it does. This regex looks for

    1. beginning of line
    2. at least one whitespace
    3. one non whitespace character
    4. end of line
    That's quite a strange line, containing only one non whitespace character ... fokat's original regex correctly looks for a line beginning with a couple of whitespaces followed by a non whitespace char.

    -- Hofmator