Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8325643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:30:29+00:00 2026-06-09T00:30:29+00:00

When running the below file with no output redirection, the output is as expected.

  • 0

When running the below file with no output redirection, the output is as expected.

Output

./get_urls.pl
www.site1.com
www.site2.com
www.siten.com

When redirecting STDOUT to a file, nothing is recorded in the file.

./get_urls.pl > out
cat out

–

#!/usr/bin/perl

use LWP::Simple;
use strict;
use warnings;

my $i = 1;

while (my $contents = get("http://www.validpage.com?page=$i"))
{
        #print STDERR $contents."\n".$url."\n";

        #print STDERR $i."\n";

        my @matches = ($contents =~ /_full'>(.*)?</g);

        for my $match (@matches)
        {
                $match =~ s/\s//g;
                print $match."\n";
        }

        $i++;
}

print STDERR "$i total matches.\n";

I suspect this behavior is a side effect of using LWP::Simple because output redirects as expected when the get() function call is omitted.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:30:31+00:00Added an answer on June 9, 2026 at 12:30 am

    Add

    $| = 1;
    

    to the beginning of your code. It’s autoflush issue when output is not sent to the terminal.

    When STDOUT is a terminal, perl autoflushes the output, but if STDOUT is, say, pipe like that

    perl print_urls.pl |cat
    

    it is no more a TTY but a bare file descriptor and autoflush is set to 0 to optimize file operations (you don’t want you logfile flushed after writing each line, right?)

    Even with autoflush disabled you will see the output… Sooner or later. Usually buffer is 4096 bytes so when your program output reaches 4097th char you will see first 4096 bytes at once.

    Also, if you don’t what to enable autoflush globally you can also try

    use IO::Handle;
    STDOUT->autoflush(1);
    

    More reading on that is man perlvar and perldoc IO::Handle

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have spooled a file before running the below command and got the output
on $(document).ready(function() in index.php, the below AJAX is executed, running the file getData.php: if
Monotouch 5.0.2. Running the simple code below I get this in the output panel:
I am running below code as root and using python2.6.1, platform is linux >>>
I am running the query below in Sybase application which works great but the
Hello friends i am running code given below which contains the setLogTimeEntery function and
I receive the error below when running the following function. The catch says the
I get the following error when running the code below: invalid byte sequence in
I am getting an argument of length zero after running the code below. I
while running: rake snorby:setup getting below error: rake aborted! You have already activated rake

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.