Hello all,
I have been looking in perldoc and perlfaq trying to find more info about typeglobs. I am just trying to see if the code below is an appropriate use and not an abuse of a typeglob ( I really want it to be okay) but don't want to use it if there are good reasons not to.

Obviously the example is simplistic, I would use it in roughly the same manner in the real code. It does work the way I expect and want it to work, i am just not familiar enough with perl to know what is really going on behind the scenes. Anyway here is the code:

#!/usr/bin/perl -w use strict; open FH, '/tmp/configfile' or die "Could not open file: $!\n"; my $foo=<FH>; close FH; my @foo=split(//, $foo); my $foo1=join("",@foo[0..2]); my $foo2=join("",@foo[3..5]); my $foo3=join("",@foo[6..16]); my $foo4=join("",@foo[17..19]); my $foo5=join("",@foo[20..24]); foo1(*$); foo2(*$); foo3(*$); foo4(*$); foo5(*$); sub foo1{ print "$foo1\n"; } sub foo2{ print "$foo2\n"; } sub foo3{ print "$foo3\n"; } sub foo4{ print "$foo4\n"; } sub foo5{ print "$foo5\n"; }



Here is the contents of /tmp/configfile:

123 abc abc@123.com lp2 12345

Here is the output of the script:
123
abc
abc@123.com
lp2
12345

Thanks in advance - Aseidas

In reply to Appropriate use of typeglob by aseidas

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.