You claim a "working script", but I see no evidence of that. I see no use of sub{} in your code. Pass the subroutine a list of values. These can be interpreted by subroutine as simple list or a hash (key,value) pairs. Both ways are shown below. There are ways to pass references to hashes or references to arrays, but that appears to be beyond the scope of what is required here.
#!usr/bin/perl -w use strict; my %hash = ( 'NAME' => 'name222', 'COLOR' => 'yellow', 'SIZE' => 'big', ); Some_subroutine(%hash); sub Some_subroutine { my @list = @_; print "This shows that %hash is just a list of key,value pairs\n"; print " when passed like sub(%hash)\n"; print "list=@list\n\n"; my %hash = @_; print "This shows that assigning default list (@_) \n"; print " to %hash results in hash (key,value) assignments\n\n"; foreach my $key (keys %hash) { print "key $key \tvalue is $hash{$key}\n"; } } __END__ PRINTS: This shows that %hash is just a list of key,value pairs when passed like sub(%hash) list=SIZE big COLOR yellow NAME name222 This shows that assigning default list (SIZE big COLOR yellow NAME nam +e222) to %hash results in hash (key,value) assignments key COLOR value is yellow key SIZE value is big key NAME value is name222

In reply to Re: passing string to sub and string split by Marshall
in thread passing string to sub and string split by courierb

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.