in reply to Re: Beginner in perl : Use of uninitialized value
in thread Beginner in perl : Use of uninitialized value

Just another tip: there is no need to read all of STDIN into an array; you can iterate over each line as it comes in.
foreach my $line (<STDIN>) { ... }

The problem with that is that the foreach loop will read all lines into a list in memory first.

You need a while loop to iterate over one line at a time:

while ( my $line = <STDIN> ) { ... }

Replies are listed 'Best First'.
Re^3: Beginner in perl : Use of uninitialized value
by jimpudar (Pilgrim) on Dec 28, 2018 at 20:20 UTC

    Quite right, that's what I get for posting without testing my code :).

    I edited my comment to correct this.

    πάντων χρημάτων μέτρον έστιν άνθρωπος.

      Thank you @jwkrahn and @jimpudar , it's been such a great learning so far , I will definitely keep these things in mind when coding next time.