Write some code on Perl6. Cool.

29.10.2016 586 views ;)

Yesturday was wrote some code on Perl6. It’s very cool and interesting. Script recursive search empty folders and remove it.

Сode:

my $file;
my $empty;

RemoveEmptySubFolders ($*CWD.path);

sub RemoveEmptySubFolders ( $path ) {
	$empty = True;
	for dir($path) -> $file {
		if ( $file.IO.d ) {
			unless (RemoveEmptySubFolders($file)) {
				$empty = False;
			}
		}
		else{
			$empty = False;
		}
	}
	if ($empty) {
		say $path if rmdir ($path);
	}
	return $empty;
}

What wondering me in Perl6:

  1. PHP has ‘glob’, Perl6 has ‘dir’
  2. IO – that big class with much more methods for Input/Outpu. Thats like Ruby language.
  3. Like old Perl5 we need to set { } for one operation, but in PHP we can make one operation without it
  4. Mandatory declaration of variables
  5. Cancatenation strings with symbol ~, this is most strange thing that I see. Why ?

Source very like on old Perl5 and PHP, but I was not used cool features of Perl6. Perl6 is very cool and interesting thing. There is no good documentation, no helpfull communities. StackOverflow is empty about it.. And it’s Great, you can be first GURU on it.


Last 5 records:

   


Smileys
Timer
Chat roulette
Virus Detector
Calculator
Vibrator
Check domain for available
Random number generator
Referral link gen
Detector external links
Math questions
Online piano
Yes or No
Today: 2017.11.24