Hello dideod.yang,
Your script is not valid perl syntax. I recommend that you take a closer look at some documentation in order to become more familiar with perl syntax and debugging.
Here is a modified version of your script that will print the first element of @x, which is 'A'. It will also print all the elements of @x (joined by commas).
#!/usr/bin/env perl
use strict;
use warnings;
my @x = ( 'A', 'B', 'C');
my @y = ( 'C', 'D', 'F');
test(\@x,\@y);
sub test{
my ($x, $y) = @_;
print "First element of x is: ", $x->[0], "\n";
print "All elements of x are: ", join(', ', @{$x}), "\n";
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|