Try passing the list as a reference, for example:
cog_class(\@c1_uniq_cog_ids, $name1);
Then,
shift off the list within the function, like so:
my $c1_uniq_cog_ids = shift;
my $name = shift;
So you finish up with something like:
#!/usr/bin/perl -w
use strict;
my $name1="chrom1 unique";
my @c1_uniq_cog_ids = qw(1 2 3 4 5);
print "NAME1 $name1\n";
cog_class(\@c1_uniq_cog_ids, $name1);
sub cog_class {
my $c1_uniq_cog_ids = shift;
my $name = shift;
print "NAME $name\n";
for my $id ( @{$cog_ids_ref} ){
# BLAH BLAH
}
}
Update:
Oh, one more thing... that C-style for loop that you have is probably better written either as:
foreach my $id (@{c1_uniq_cog_ids}) {
# Do stuff
}
or even....
for (@{c1_uniq_cog_ids}) {
# Do stuff
}
Update 2: Fixed, as pointed out by [id://cbrandtbuffalo]
hope this helps
--Darren
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.