Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: About personal function

by kevbot (Priest)
on Jul 19, 2018 at 05:16 UTC ( #1218801=note: print w/replies, xml ) Need Help??

in reply to About personal function

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"; }

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1218801]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2022-09-29 15:35 GMT
Find Nodes?
    Voting Booth?
    I prefer my indexes to start at:

    Results (125 votes). Check out past polls.