-
Notifications
You must be signed in to change notification settings - Fork 0
/
mode.pl
34 lines (28 loc) · 821 Bytes
/
mode.pl
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
32
33
34
# include path.pl
{
# return the file mode by the suffix of filename: pl, py or c
my sub getbysx {
return "pl" if $_[0] eq "pl";
return "py" if $_[0] eq "py";
return "c" if $_[0] eq "c++";
return "c" if $_[0] eq "c"; }
# return the mode by the filename, or return the default perl mode
our sub getmode {
my $sx = sx $_[0];
my $mode = getbysx $sx;
$mode = "pl" if not $mode;
return $mode }
# auto-identify the mode of a list of files by the first identifiable
# file suffix, or return the default perl mode
our sub firstmode {
my $mode;
for(@{$_[0]}) {
$mode = getbysx sx $_;
last if $mode }
$mode = "pl" if not $mode;
return $mode }
# return the comment identifier string by the mode: # or //
our sub getsy {
return "//" if $_[0] eq "c";
return "#" }
} # R.Jaksa 2024 GPLv3