hns - 日記自動生成システム - Version 2.19.9

先月 2021年10月 来月
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
Namazu for hns による簡易全文検索
詳しくは 詳細指定/ヘルプを参照して下さい
検索式:

2021年10月27日(水) 旧暦 [n年日記] [更新:"2004/08/09 23:43:33"]

#1 [Perl] pass array pointer to subroutine

code:

#!/usr/pkg/bin/perl
use strict;
use feature qw(declared_refs refaliasing say);

sub print_array {
    my ($args)   = @_;
    my (\@ptr)   = $args -> {-ptr}; 
    my ($string) = $args -> {-string}; 

    print $string,"\n";

    foreach my $i (0..$#ptr){
        print $ptr[$i],"\n";
    }
}
sub main {
    my (@array) =  (qw ( 1 2 3 4 5 ));
    print_array ({
    		-ptr    => \@array,
		-string => ' -- passing array test -- '
    });
}
main();
__END__

results:

SX3@makoto 21:04:49/211027(..git-work/pass-array)% perl pass-array
Declaring references is experimental at pass-array line 8.
Aliasing via reference is experimental at pass-array line 8.
 -- passing array test -- 
1
2
3
4
5
SX3@makoto 21:05:02/211027(..git-work/pass-array)% perl --version

This is perl 5, version 34, subversion 0 (v5.34.0) built for x86_64-netbsd-thread-multi

Copyright 1987-2021, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.



最近の日記
2024年03月10日
停電 (瞬電)
2024年03月03日
the second try on bare-metal
useradd
2024年02月29日
opendkim and senmail
2024年01月24日
chat/iam 0.0.8
2024年01月21日
uselocale vs setlocale (textproc/R-readxl)
以上、1 日分です。
タイトル一覧
カテゴリ分類
Powered by hns-2.19.9, HyperNikkiSystem Project

Count.cgi (since 2000/02/05)