Hi,

This is what you were trying to write

#!/usr/bin/perl -- package xyz; require Exporter; *import = \&Exporter::import; use strict; use warnings; our @EXPORT_OK = qw(@overall @electronics @safety); our @products = ( [ "MG-20", 1, 2, 3 ], [ "JU-54", 2, 3, 1 ], [ "HY-21", 3, 1, 2 ], [ "OK-34", 4, 10, 5 ], [ "GT-75", 9, 6, 0 ], [ "KJ-23", 6, 8, 7 ], [ "PO-65", 7, 5, 10 ], [ "HN-34", 8, 6, 9 ], [ "ED-23", 9, 7, 4 ], [ "FR-98", 10, 4, 8 ], ); our( @overall, @electronics, @safety ); { for my $i ( 0 .. @products ) { push @overall, $products[$i][1] . ":" . $products[$i][0]; push @electronics, $products[$i][2] . ":" . $products[$i][0]; push @safety, $products[$i][3] . ":" . $products[$i][0]; } } 1; __END__

Actually this is what you were trying to write

#!/usr/bin/perl -- package xyz; require Exporter; *import = \&Exporter::import; use strict; use warnings; our @EXPORT_OK = qw(@overall @electronics @safety); our @products = ( [ "MG-20", 1, 2, 3 ], [ "JU-54", 2, 3, 1 ], [ "HY-21", 3, 1, 2 ], [ "OK-34", 4, 10, 5 ], [ "GT-75", 9, 6, 0 ], [ "KJ-23", 6, 8, 7 ], [ "PO-65", 7, 5, 10 ], [ "HN-34", 8, 6, 9 ], [ "ED-23", 9, 7, 4 ], [ "FR-98", 10, 4, 8 ], ); our @overall = map { $_->[1] . ':' . $_->[0] } @products; our @electronics = map { $_->[2] . ':' . $_->[0] } @products; our @safety = map { $_->[3] . ':' . $_->[0] } @products; 1; __END__

So that you could write something like this (no exporting required)

use Data::Dump qw/ dd/; use xyz qw/ @safety /;; dd( \@safety , \@xyz::safety ); __END__do { my $a = [ "3:MG-20", "1:JU-54", "2:HY-21", "5:OK-34", "0:GT-75", "7:KJ-23", "10:PO-65", "9:HN-34", "4:ED-23", "8:FR-98", ]; ($a, $a); }

Also, all lowercase names are reserved for pragmas . You can find much much more discussions on naming modules in Re: RFC: Automatic logger module

Sherab_Inc::xyz Sherab_LLC::products Xyz_LLC::products MySherabApp::xyz SherabApp::products ...

In reply to Re: Returning arrays from a package by Anonymous Monk
in thread Returning arrays from a package by sherab

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.