Skip to content

Instantly share code, notes, and snippets.

@olegwtf
Created April 19, 2012 18:15
Show Gist options
  • Save olegwtf/2422736 to your computer and use it in GitHub Desktop.
Save olegwtf/2422736 to your computer and use it in GitHub Desktop.
Perl like 1С
use utf8;
my $мама = 'рама';
sub мой($) {
print "я мою ", shift, "\n";
}
мой($мама);
@kilex
Copy link

kilex commented Apr 19, 2012

нехилый бредняк

@kilex
Copy link

kilex commented Apr 19, 2012

root@83:/test# git clone git://gist.github.com/2422765.git
Cloning into 2422765...
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
root@83:
/test# ls
2422765
root@83:/test# cd 2422765/
root@83:
/test/2422765# ls
1с.pl
root@83:/test/2422765# chmod +x 1с.pl
root@83:
/test/2422765# ls
1с.pl
root@83:/test/2422765# ./1с.pl
./1с.pl: line 1: use: команда не найдена
./1с.pl: line 3: my: команда не найдена
./1с.pl: line 4: syntax error near unexpected token (' ./1с.pl: line 4:sub мой($) {'
root@83:
/test/2422765#

@olegwtf
Copy link
Author

olegwtf commented Apr 19, 2012

1С головного мозга

@olegwtf
Copy link
Author

olegwtf commented Apr 19, 2012

@kilex

!/usr/bin/perl -CS в начале скрипта

или просто запускать как perl -CS имя скрипта

@kilex
Copy link

kilex commented Apr 19, 2012

!/usr/bin/perl

use strict;
use utf8;
use open qw(:std :utf8);

my $мама = 'рама';
sub мой($) {
my $субьект=shift;
print "я мою ".$субьект."\n";
}

print мой($мама);

@kilex
Copy link

kilex commented Apr 19, 2012

а что за CS ?

@olegwtf
Copy link
Author

olegwtf commented Apr 19, 2012

Из perldoc perlrun
-C [number/list]
The -C flag controls some of the Perl Unicode features.

        As of 5.8.1, the -C can be followed either by a number or a list of option letters.  The letters, their numeric values, and effects are as
        follows; listing the letters is equal to summing the numbers.

            I     1   STDIN is assumed to be in UTF-8
            O     2   STDOUT will be in UTF-8
            E     4   STDERR will be in UTF-8
            S     7   I + O + E

Говоря по-русски переводит STDIN, STDOUT и STDERR в режим поддержки utf8. Иначе будут варнинги. Ну или как ты сделал.

@sugar84
Copy link

sugar84 commented Apr 19, 2012

круто, про -CS не знал, спасибо

@kilex
Copy link

kilex commented Apr 19, 2012

действительно, это удобнее чем
use open qw(:std :utf8);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment