Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: About personal function

by kevbot (Vicar)
on Jul 19, 2018 at 05:16 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-24 04:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found