There is a difference in how readline() handles references to typeglobs from 5.00503 and 5.6.1. The following works in 5.6.1:

#!/usr/bin/perl -w use strict; use Symbol; my $sym = gensym; open($sym, 'file1') || die "Can't $!"; while(readline($sym)){ print; }

But it doesn't work in 5.00503 (no warnings, readline simply returns undef so the loop isn't entered). Reading from <$sym> works in both version when $sym is a globref, but readline() itself didn't work with globrefs until 5.6 --- I didn't see mention of it in perldelta, but it is mentioned in the 'Changes' file for 5.6 sources:

_________________________________________________________________ [ 3349] By: gsar on 1999/05/09 20:23:07 Log: allow readline($globref), <$globref> already works Branch: perl ! pp_hot.c

A work around for 5.005 is to simply dereference the globref explicitly for the readline() function. The following work in 5.00503 and 5.6.1:

readline(${$sym}) readline(*{$sym}) or in your particular case: readline(*{$data[$i]->{FH}})

As a final note, in your last block where you pad out the string I think you want to substract the expand()'d length, not just the length():

# change this: print $_, ' 'x($data[$i]->{w}-1-length); # to this: print $_, ' 'x($data[$i]->{w}-1-length(expand($_)));

In reply to Re: Re: Some missing textutils by danger
in thread Some missing textutils by belg4mit

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.