Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2019-05-25 04:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (151 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!