http://www.perlmonks.org?node_id=133876

mvaline has asked for the wisdom of the Perl Monks concerning the following question:

I wrote the following script to extract some information from a web page and print it to the screen. The web page is absolutly basic HTML so my paltry regexp works fine.

The problem is in the print statements at the end wherein I attempt to print out the information I extracted. As shown below, the script only prints out the contents of $avg_size. If I uncomment all but any of the variables, it prints out correctly.

I have tried forcing the screen to autoflush using the STDOUT->autoflush(1) method of the FileHandle module and by setting $| = 1. Neither option had any effect.

#!/usr/bin/perl -w use strict; use LWP::Simple; #### retrieve web page my $url = "http://www.visionforum.com/admin/avantgo.asp"; my $page_content = get($url); #### remove extraneous information and HTML markup (my $plain_text = $page_content) =~ s/<[^>]*>//gs; #### extract relevant info my @lines = split /\n/, $plain_text; my $title = $lines[10]; my $timestamp = $lines[11]; my $shoppers = $lines[13]; my $num_orders = $lines[17]; my $gross_sales = $lines[18]; my $avg_size= $lines[20]; #### output print $title; print $timestamp; print $shoppers; print $num_orders; print $gross_sales; print $avg_size; exit;