Skip to content

Instantly share code, notes, and snippets.

@keedi
Created March 18, 2010 04:35
Show Gist options
  • Save keedi/336047 to your computer and use it in GitHub Desktop.
Save keedi/336047 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use 5.010; # perl 버전 5.10 사용
use common::sense; # utf8, strict, warnings 프라그마 on
use Scalar::Random qw( randomize ); # 임의 숫자 구하는 함수
use List::Util qw( max min ); # 최대값 및 최소값 구하는 함수
my $random; # 난수 생성기
my $max = 100; # 난수 최대값
randomize( $random, $max ); # 난수 생성기 초기화
my @numbers; # 숫자를 저장할 배열
push @numbers, $random for 1 .. 10; # 10 개의 난수 생성
my $max = max @numbers; # 숫자를 저장한 배열에서 최대값 추출
my $min = min @numbers; # 숫자를 저장한 배열에서 최소값 추출
say "numbers: @numbers";
say "max: $max";
say "min: $min";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment