File extension is in extensions list: Difference between revisions
Content added Content deleted
Walterpachl (talk | contribs) m (→{{header|REXX}}: typos) |
(→{{header|Perl 6}}: handle extensions the Unix Way, agnostically) |
||
Line 83: | Line 83: | ||
a/b/c\d/foo: true</pre> |
a/b/c\d/foo: true</pre> |
||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |
||
<lang perl6> |
<lang perl6>sub ext-in-list(@ext,@files) { |
||
for @files { |
|||
⚫ | |||
⚫ | |||
⚫ | |||
} |
|||
} |
|||
ext-in-list |
|||
for < foo.C foo.zkl foo foo. > { |
|||
« |
|||
⚫ | |||
.c |
|||
⚫ | |||
.C# |
|||
⚫ | |||
.o |
|||
⚫ | |||
.yup |
|||
.½xy |
|||
'. embedded blanks ' |
|||
», |
|||
« |
|||
foo.c |
|||
foo.C |
|||
foo.C++ |
|||
foo.c# |
|||
foo.zkl |
|||
somefile |
|||
'holy smoke' |
|||
afile. |
|||
/a/path/to/glory.yup/or_not |
|||
funny... |
|||
unusual.½xy |
|||
'fly_in_the_ointment. embedded blanks ' |
|||
⚫ | |||
{{out}} |
{{out}} |
||
<pre>foo. |
<pre>True foo.c |
||
True foo.C |
|||
foo.zkl .zkl is not in the list |
|||
False foo.C++ |
|||
foo (has no extension) |
|||
True foo.c# |
|||
foo. . is not in the list</pre> |
|||
False foo.zkl |
|||
---- somefile |
|||
---- holy smoke |
|||
---- afile. |
|||
---- /a/path/to/glory.yup/or_not |
|||
---- funny... |
|||
True unusual.½xy |
|||
True fly_in_the_ointment. embedded blanks |
|||
</pre> |
|||
=={{header|Python}}== |
=={{header|Python}}== |