As
grep says, you
are printing everything, but there are no newlines in any of those variables since
split removes them. The output variables overwrite each other because each ends in a carriage return character (this can often be seen in the output as the one line you do get sometimes has garbage at the end left over from previous lines). One solution which builds on
grep's and adds a somewhat simpler print statement follows:
my @lines = map{"$_\n"} split /\r\n/, $plain_text;
print @lines[10,11,13,17,18,20];
If you want to keep the meanings of the various line numbers intact in the code, but avoid creating independent variables for that purpose, you could do something like the following:
use strict;
use LWP::Simple;
my %info_lines = ( title => 10,
timestamp => 11,
shoppers => 13,
num_orders => 17,
gross_sales => 18,
avg_size => 20,
);
my $url = "http://www.visionforum.com/admin/avantgo.asp";
my $page_content = get($url);
(my $plain_text = $page_content) =~ s/<[^>]*>//gs;
my @lines = map{"$_\n"} split /\r\n/, $plain_text;
print $lines[$_] for sort values %info_lines;
--
I'd like to be able to assign to an luser
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.