Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[COLOR=#804040][b]use warnings[/b][/color];
[COLOR=#804040][b]use strict[/b][/color];
[COLOR=#804040][b]use [/b][/color]Data::Dumper::Simple;
[COLOR=#804040][b]my[/b][/color] [COLOR=#008080]$var_01[/color] = [COLOR=#ff00ff]'[/color][COLOR=#ff00ff]foo[/color][COLOR=#ff00ff]'[/color];
[COLOR=#804040][b]print[/b][/color] [COLOR=#008080]Dumper[/color]([COLOR=#008080]$var_01[/color]);
[COLOR=#804040][b]my[/b][/color] ([COLOR=#008080]$name[/color]) = [COLOR=#804040][b]split[/b][/color]([COLOR=#804040][b]/[/b][/color][COLOR=#6a5acd]\s[/color][COLOR=#6a5acd]*[/color][COLOR=#ff00ff]=[/color][COLOR=#804040][b]/[/b][/color], Dumper([COLOR=#008080]$var_01[/color]));
[COLOR=#804040][b]print[/b][/color] [COLOR=#ff00ff]"[/color][COLOR=#ff00ff]* variable name = '[/color][COLOR=#008080]$name[/color][COLOR=#ff00ff]'[/color][COLOR=#6a5acd]\n[/color][COLOR=#ff00ff]"[/color];
[COLOR=#804040][b]my[/b][/color] [COLOR=#008080]@array_01[/color] = [COLOR=#ff00ff]qw ([/color][COLOR=#ff00ff]1 2 3 4[/color][COLOR=#ff00ff])[/color];
[COLOR=#804040][b]print[/b][/color] [COLOR=#008080]Dumper[/color]([COLOR=#008080]@array_01[/color]);
([COLOR=#008080]$name[/color]) = [COLOR=#804040][b]split[/b][/color]([COLOR=#804040][b]/[/b][/color][COLOR=#6a5acd]\s[/color][COLOR=#6a5acd]*[/color][COLOR=#ff00ff]=[/color][COLOR=#804040][b]/[/b][/color], Dumper([COLOR=#008080]@array_01[/color]));
[COLOR=#804040][b]print[/b][/color] [COLOR=#ff00ff]"[/color][COLOR=#ff00ff]* variable name = '[/color][COLOR=#008080]$name[/color][COLOR=#ff00ff]'[/color][COLOR=#6a5acd]\n[/color][COLOR=#ff00ff]"[/color];
$ perl varname.pl
$var_01 = 'foo';
* variable name = '$var_01'
@array_01 = (
'1',
'2',
'3',
'4'
);
* variable name = '@array_01'
my @pushedarray = @{shift};
my @array1 = (1,2,3,4);
check(@array1);
sub check
{
my @pushedarray = shift;
print @pushedarray;
}
sub my_function {
my ($arg1, $arg2, $arg3) = @_;
print "arg1 = $arg1, arg2 = $arg2, arg3 = $arg3";
}
my_function('This','Is','Fun');
arg1 = This, arg2 = Is, arg3 = Fun
my ($index1, $index2, $index3) = @_;
audiopro said:Why not just pass the name of the array to your sub routine when you call it?
[COLOR=#804040][b]use warnings[/b][/color];
[COLOR=#804040][b]use strict[/b][/color];
[COLOR=#804040][b]my[/b][/color] [COLOR=#008080]$var_01[/color] = [COLOR=#ff00ff]'[/color][COLOR=#ff00ff]foo[/color][COLOR=#ff00ff]'[/color];
print_var([COLOR=#ff00ff]'[/color][COLOR=#ff00ff]$var_01[/color][COLOR=#ff00ff]'[/color], [COLOR=#008080]$var_01[/color]);
[COLOR=#804040][b]my[/b][/color] [COLOR=#008080]@array_01[/color] = [COLOR=#ff00ff]qw ([/color][COLOR=#ff00ff]1 2 3 4[/color][COLOR=#ff00ff])[/color];
print_var([COLOR=#ff00ff]'[/color][COLOR=#ff00ff]@array_01[/color][COLOR=#ff00ff]'[/color], [COLOR=#008080]@array_01[/color]);
[COLOR=#0000ff]#-------------------------------------------[/color]
[COLOR=#804040][b]sub [/b][/color][COLOR=#008080]print_var [/color]{
[COLOR=#804040][b]my[/b][/color] ([COLOR=#008080]$var_name[/color], [COLOR=#008080]@var_value[/color]) = [COLOR=#008080]@_[/color];
[COLOR=#804040][b]print[/b][/color] [COLOR=#ff00ff]"[/color][COLOR=#ff00ff]* variable name = '[/color][COLOR=#008080]$var_name[/color][COLOR=#ff00ff]'[/color][COLOR=#6a5acd]\n[/color][COLOR=#ff00ff]"[/color];
[COLOR=#804040][b]print[/b][/color] [COLOR=#ff00ff]"[/color][COLOR=#ff00ff] value = [/color][COLOR=#008080]@var_value[/color][COLOR=#6a5acd]\n\n[/color][COLOR=#ff00ff]"[/color];
}
$ perl varname_simple.pl
* variable name = '$var_01'
value = foo
* variable name = '@array_01'
value = 1 2 3 4
my @array1 = qw (1 2 3 4);
print 'Sending array - @array1 to sub Check';
Check(\@array1);
sub Check {
my @pushedarray = @{$_[0]};
print \@{$_[0]};
}