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

  • SEARCH
  • Home
  • 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 265827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:48:12+00:00 2026-05-11T22:48:12+00:00

I am a noob Perl user trying to get my work done ASAP so

  • 0

I am a noob Perl user trying to get my work done ASAP so I can go home on time today 🙂

Basically I need to print the next line of blank lines in a text file.

The following is what I have so far. It can locate blank lines perfectly fine. Now I just have to print the next line.

    open (FOUT, '>>result.txt');

die "File is not available" unless (@ARGV ==1);

open (FIN, $ARGV[0]) or die "Cannot open $ARGV[0]: $!\n";

@rawData=<FIN>;
$count = 0;

foreach $LineVar (@rawData)
    {
        if($_ = ~/^\s*$/)
        {
            print "blank line \n";
                    #I need something HERE!!

        }
        print "$count \n";
        $count++;
    }
close (FOUT);
close (FIN);

Thanks a bunch 🙂

  • 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-05-11T22:48:12+00:00Added an answer on May 11, 2026 at 10:48 pm
    open (FOUT, '>>result.txt');
    
    die "File is not available" unless (@ARGV ==1);
    
    open (FIN, $ARGV[0]) or die "Cannot open $ARGV[0]: $!\n";
    
    $count = 0;
    
    while(<FIN>)
    {
        if($_ = ~/^\s*$/)
        {
                print "blank line \n";
                count++;
                <FIN>;
                print $_;
    
        }
        print "$count \n";
        $count++;
    }
    close (FOUT);
    close (FIN);
    
    • not reading the entire file into @rawData saves memory, especially in the case of large files…

    • <FIN> as a command reads the next line into $_

    • print ; by itself is a synonym for print $_; (although I went for the more explicit variant this time…

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

Sidebar

Related Questions

In my free time, I've been trying to improve my perl abilities by working
Clarification: I'm pretty much a Perl/CPAN noob, don't assume I know too much. I
I'm noob in Subversion, how can I find my old revisions of the project
This might be a noob question, but I need help. I screwed up my
I'm just a noob when it comes to regexp. I know Perl is amazing
noob here, I'm trying to transfer a file using rsync from windows to linux.
I have been trying to get rid of a weird bug for hours, with
Noob here. I have a rails app that has users and postings. I need
Noob ADO.NET question: Can I do the following? Retrieve a DataTable somehow. Dispose it.
Another noob question from me. I'm trying to create an application that counts, and

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.