There look to be a bunch of things there that will make the code hard to understand and maintain.

First off, don't use prototypes. That is your immediate problem as has already been suggested. They don't do what you think and cause subtle trouble that can lead to really hard to debug errors.

Don't use artificial boolean values. Just accept that $continue_tag is a boolean variable that is false if it is empty or 0 and true otherwise.

Make it clear where information comes from. You don't show @array_of_lines (bad name btw, why not just @lines?) being assigned any content. It's not clear how the work look_through_file does relates to the work create_output does. Where does $continue_tag's value get changed?

Without any idea what your intent for the code is I can only sketch a better structure, but consider:

#!/usr/bin/perl use strict; use warnings; my $fName = 'wibble.dat'; my $group; open my $fIn, '<', $fName or die "Can't open $fName: $!\n"; while (my @lines = scanFile($fIn)) { report(++$group, @lines); } sub scanFile { my ($fIn) = @_; my @lines; while (@lines < 10 && defined (my $line = <$fIn>)) { chomp $line; next if ! length $line; push @lines, $line; } return @lines; } sub report { my ($group, @lines) = @_; printf "%04d: %s\n", $group for @lines; }

which batches lines from a file into groups of 10 non-blank lines then prints each group with a group prefix.

True laziness is hard work

In reply to Re: Calling a subroutine within a conditional by GrandFather
in thread Calling a subroutine within a conditional by Freezer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.