## 2019年1月19日土曜日

### Perl - Perl入門(perldoc(ドキュメント)、奇妙に見えるPerlプログラム(外部コマンド、バッククォート))

コード

Perl

```#!/usr/bin/env perl
@lines = `perldoc -u -f atan2`;
for (@lines) {
s/\w<([^>]+)>/\U\$1/g;
print;
}
```

```\$ perldoc -u -f atan2 > output1.txt
\$ perl sample3.pl > output2.txt
\$ diff output1.txt output2.txt > output3.txt
\$ cat output1.txt
=over 8

=item atan2 Y,X
X<atan2> X<arctangent> X<tan> X<tangent>

=for Pod::Functions arctangent of Y/X in the range -PI to PI

Returns the arctangent of Y/X in the range -PI to PI.

For the tangent operation, you may use the
L<C<Math::Trig::tan>|Math::Trig/B<tan>> function, or use the familiar
relation:

sub tan { sin(\$_[0]) / cos(\$_[0])  }

The return value for C<atan2(0,0)> is implementation-defined; consult

Portability issues: L<perlport/atan2>.

=back
\$ cat output2.txt
=over 8

=item atan2 Y,X
ATAN2 ARCTANGENT TAN TANGENT

=for Pod::Functions arctangent of Y/X in the range -PI to PI

Returns the arctangent of Y/X in the range -PI to PI.

For the tangent operation, you may use the
C<MATH::TRIG::TAN|Math::Trig/TAN> function, or use the familiar
relation:

sub tan { sin(\$_[0]) / cos(\$_[0])  }

The return value for ATAN2(0,0) is implementation-defined; consult

Portability issues: PERLPORT/ATAN2.

=back
\$ cat output3.txt
4c4
< X<atan2> X<arctangent> X<tan> X<tangent>
---
> ATAN2 ARCTANGENT TAN TANGENT
11c11
< L<C<Math::Trig::tan>|Math::Trig/B<tan>> function, or use the familiar
---
> C<MATH::TRIG::TAN|Math::Trig/TAN> function, or use the familiar
16,17c16,17
< The return value for C<atan2(0,0)> is implementation-defined; consult
---
> The return value for ATAN2(0,0) is implementation-defined; consult