#!/usr/bin/perl

use 5.022;
use warnings;

use Pod::Usage qw(pod2usage);

$| = 1;

my @say = qw/Hare Krishna Rama/;
my @seq = (split(//,'010'),((1)x3),((0)x2));
push @seq, map {$_*2} @seq;

my $n = $ARGV[-1] // 108;

usage() unless $n =~ /^\d+/ && $n > 0;

for (1..$n) {
	my $c = 0;
	for (@seq) {
		print $say[$_] . ($c ++ % 2 ? "!\n" : ' ');
		sleep 1;		
	}
	say '';
}

sub usage {
	my $file = @_ ? "$_[0]" : (caller)[1];
	open my $handle, '>', \my $output;
	pod2usage -exitval => 'noexit', -input => $file, -output => $handle;
	$output =~ s/^.*\n|\n$//;
	$output =~ s/\n$//g;
	say $output;
	exit;
}

1;

=encoding utf8

=head1 NAME

mantra - 108 numbers of mantra

=head1 SYNOPSIS

Usage: mantra [n]

       mantra
       mantra 16
       mantra 108
       	
Options:

       Numbers of mantra (default: 108)

mantra developed by Ivan Trunaev, Russia, 2026

Contacts <ivan@trunaev.ru>

=cut
