File Coverage

blib/lib/Venus/Os.pm
Criterion Covered Total %
statement 80 85 94.1
branch 54 68 79.4
condition 6 15 40.0
subroutine 22 23 95.6
pod 17 18 94.4
total 179 209 85.6


line stmt bran cond sub pod time code
1             package Venus::Os;
2              
3 95     95   2404 use 5.018;
  95         383  
4              
5 95     95   538 use strict;
  95         191  
  95         2227  
6 95     95   531 use warnings;
  95         213  
  95         3004  
7              
8 95     95   528 use Venus::Class 'base';
  95         208  
  95         736  
9              
10             base 'Venus::Kind::Utility';
11              
12             our %TYPES;
13              
14             # HOOKS
15              
16             sub _osname {
17 22952 100   22952   111239 $TYPES{$^O} || $^O
18             }
19              
20             # BUILDERS
21              
22             sub build_arg {
23 0     0 0 0 my ($self) = @_;
24              
25 0         0 return {};
26             }
27              
28             # METHODS
29              
30             sub call {
31 5     5 1 19 my ($self, $name, @args) = @_;
32              
33 5 50       15 return if !$name;
34              
35 5         22 require Venus::Path;
36              
37 5         15 my $which = $self->which($name);
38              
39 5 100       16 return if !$which;
40              
41 4         32 my $path = Venus::Path->new($which);
42              
43 4         22 my $expr = join ' ', @args;
44              
45 4   33     24 return $path->try('mkcall')->maybe->result($expr || ());
46             }
47              
48             sub find {
49 20     20 1 72 my ($self, $name, @paths) = @_;
50              
51 20 50       45 return if !$name;
52              
53 20         77 require File::Spec;
54              
55 20 100       173 return [$name] if File::Spec->splitdir($name) > 1;
56              
57 18         2249 my $result = [grep -f, map File::Spec->catfile($_, $name), @paths];
58              
59 18 50       138 return wantarray ? @{$result} : $result;
  0         0  
60             }
61              
62             sub is_bsd {
63              
64 13 100   13 1 32 return true if lc(_osname()) eq 'freebsd';
65 12 100       26 return true if lc(_osname()) eq 'openbsd';
66              
67 10         42 return false;
68             }
69              
70             sub is_cyg {
71              
72 13 100   13 1 28 return true if lc(_osname()) eq 'cygwin';
73 11 100       33 return true if lc(_osname()) eq 'msys';
74              
75 10         30 return false;
76             }
77              
78             sub is_dos {
79              
80 6 100   6 1 15 return true if is_win();
81              
82 3         15 return false;
83             }
84              
85             sub is_lin {
86              
87 13 100   13 1 27 return true if lc(_osname()) eq 'linux';
88              
89 10         33 return false;
90             }
91              
92             sub is_mac {
93              
94 12 100   12 1 24 return true if lc(_osname()) eq 'macos';
95 10 100       21 return true if lc(_osname()) eq 'darwin';
96              
97 9         21 return false;
98             }
99              
100             sub is_non {
101              
102 2 50   2 1 8 return false if is_bsd();
103 2 50       18 return false if is_cyg();
104 2 50       13 return false if is_dos();
105 2 100       13 return false if is_lin();
106 1 50       9 return false if is_mac();
107 1 50       10 return false if is_sun();
108 1 50       15 return false if is_vms();
109 1 50       4 return false if is_win();
110              
111 1         5 return true;
112             }
113              
114             sub is_sun {
115              
116 12 100   12 1 27 return true if lc(_osname()) eq 'solaris';
117 10 100       26 return true if lc(_osname()) eq 'sunos';
118              
119 9         23 return false;
120             }
121              
122             sub is_vms {
123              
124 11 100   11 1 30 return true if lc(_osname()) eq 'vms';
125              
126 9         24 return false;
127             }
128              
129             sub is_win {
130              
131 7618 100   7618 1 18827 return true if lc(_osname()) eq 'mswin32';
132 7609 100       20417 return true if lc(_osname()) eq 'dos';
133 7606 100       15796 return true if lc(_osname()) eq 'os2';
134              
135 7604         24888 return false;
136             }
137              
138             sub name {
139 2     2 1 415 my ($self) = @_;
140              
141 2         7 my $name = _osname();
142              
143 2         14 return $name;
144             }
145              
146             sub paths {
147 18     18 1 37 my ($self) = @_;
148              
149 18         74 require File::Spec;
150              
151 18         31 my %seen;
152              
153 18         503 my $result = [grep !$seen{$_}++, File::Spec->path];
154              
155 18 100       70 return wantarray ? @{$result} : $result;
  17         102  
156             }
157              
158             sub quote {
159 11     11 1 35 my ($self, $data) = @_;
160              
161 11 50       50 if (!defined $data) {
    100          
162 0         0 return '';
163             }
164             elsif ($self->is_win) {
165 2 50 33     30 return ($data =~ /^"/ && $data =~ /"$/)
      50        
166             ? $data
167             : ('"' . (($data =~ s/"/\\"/gr) || "") . '"');
168             }
169             else {
170 9 50 33     177 return ($data =~ /^'/ && $data =~ /'$/)
      50        
171             ? $data
172             : ("'" . (($data =~ s/'/'\\''/gr) || "") . "'");
173             }
174             }
175              
176             sub type {
177 8     8 1 18 my ($self) = @_;
178              
179 8         42 my @types = qw(
180             is_lin
181             is_mac
182             is_win
183             is_bsd
184             is_cyg
185             is_sun
186             is_vms
187             );
188              
189 8         30 my $result = [grep $self->$_, @types];
190              
191 8   50     51 return $result->[0] || 'is_non';
192             }
193              
194             sub where {
195 17     17 1 43 my ($self, $name) = @_;
196              
197 17         47 my $result = $self->find($name, $self->paths);
198              
199 17 50       79 return wantarray ? @{$result} : $result;
  0         0  
200             }
201              
202             sub which {
203 11     11 1 30 my ($self, $name) = @_;
204              
205 11         32 my $result = $self->where($name);
206              
207 11         52 return $result->[0];
208             }
209              
210             1;
211              
212              
213              
214             =head1 NAME
215              
216             Venus::Os - OS Class
217              
218             =cut
219              
220             =head1 ABSTRACT
221              
222             OS Class for Perl 5
223              
224             =cut
225              
226             =head1 SYNOPSIS
227              
228             package main;
229              
230             use Venus::Os;
231              
232             my $os = Venus::Os->new;
233              
234             # bless({...}, 'Venus::Os')
235              
236             # my $name = $os->name;
237              
238             # "linux"
239              
240             =cut
241              
242             =head1 DESCRIPTION
243              
244             This package provides methods for determining the current operating system, as
245             well as finding and executing files.
246              
247             =cut
248              
249             =head1 INHERITS
250              
251             This package inherits behaviors from:
252              
253             L
254              
255             =cut
256              
257             =head1 METHODS
258              
259             This package provides the following methods:
260              
261             =cut
262              
263             =head2 call
264              
265             call(string $name, string @args) (any)
266              
267             The call method attempts to find the path to the program specified via
268             L and dispatches to L and returns the result. Any
269             exception throw is supressed and will return undefined if encountered.
270              
271             I>
272              
273             =over 4
274              
275             =item call example 1
276              
277             # given: synopsis
278              
279             package main;
280              
281             my $app = $os->is_win ? 'perl.exe' : 'perl';
282              
283             my $call = $os->call($app, '-V:osname');
284              
285             # "osname='linux';"
286              
287             =back
288              
289             =over 4
290              
291             =item call example 2
292              
293             # given: synopsis
294              
295             package main;
296              
297             my $app = $os->is_win ? 'perl.exe' : 'perl';
298              
299             my @call = $os->call($app, '-V:osname');
300              
301             # ("osname='linux';", 0)
302              
303             =back
304              
305             =over 4
306              
307             =item call example 3
308              
309             # given: synopsis
310              
311             package main;
312              
313             my $call = $os->call('nowhere');
314              
315             # undef
316              
317             =back
318              
319             =over 4
320              
321             =item call example 4
322              
323             # given: synopsis
324              
325             package main;
326              
327             my @call = $os->call($^X, '-V:osname');
328              
329             # ("osname='linux';", 0)
330              
331             =back
332              
333             =over 4
334              
335             =item call example 5
336              
337             # given: synopsis
338              
339             package main;
340              
341             my @call = $os->call($^X, 't/data/sun');
342              
343             # ("", 1)
344              
345             =back
346              
347             =cut
348              
349             =head2 find
350              
351             find(string $name, string @paths) (arrayref)
352              
353             The find method searches the paths provided for a file matching the name
354             provided and returns all the files found as an arrayref. Returns a list in list
355             context.
356              
357             I>
358              
359             =over 4
360              
361             =item find example 1
362              
363             # given: synopsis
364              
365             package main;
366              
367             my $find = $os->find('cmd', 't/path/user/bin');
368              
369             # ["t/path/user/bin/cmd"]
370              
371             =back
372              
373             =over 4
374              
375             =item find example 2
376              
377             # given: synopsis
378              
379             package main;
380              
381             my $find = $os->find('cmd', 't/path/user/bin', 't/path/usr/bin');
382              
383             # ["t/path/user/bin/cmd", "t/path/usr/bin/cmd"]
384              
385             =back
386              
387             =over 4
388              
389             =item find example 3
390              
391             # given: synopsis
392              
393             package main;
394              
395             my $find = $os->find('zzz', 't/path/user/bin', 't/path/usr/bin');
396              
397             # []
398              
399             =back
400              
401             =cut
402              
403             =head2 is_bsd
404              
405             is_bsd() (boolean)
406              
407             The is_bsd method returns true if the OS is either C<"freebsd"> or
408             C<"openbsd">, and otherwise returns false.
409              
410             I>
411              
412             =over 4
413              
414             =item is_bsd example 1
415              
416             # given: synopsis
417              
418             package main;
419              
420             # on linux
421              
422             my $is_bsd = $os->is_bsd;
423              
424             # false
425              
426             =back
427              
428             =over 4
429              
430             =item is_bsd example 2
431              
432             # given: synopsis
433              
434             package main;
435              
436             # on freebsd
437              
438             my $is_bsd = $os->is_bsd;
439              
440             # true
441              
442             =back
443              
444             =over 4
445              
446             =item is_bsd example 3
447              
448             # given: synopsis
449              
450             package main;
451              
452             # on openbsd
453              
454             my $is_bsd = $os->is_bsd;
455              
456             # true
457              
458             =back
459              
460             =cut
461              
462             =head2 is_cyg
463              
464             is_cyg() (boolean)
465              
466             The is_cyg method returns true if the OS is either C<"cygwin"> or C<"msys">,
467             and otherwise returns false.
468              
469             I>
470              
471             =over 4
472              
473             =item is_cyg example 1
474              
475             # given: synopsis
476              
477             package main;
478              
479             # on linux
480              
481             my $is_cyg = $os->is_cyg;
482              
483             # false
484              
485             =back
486              
487             =over 4
488              
489             =item is_cyg example 2
490              
491             # given: synopsis
492              
493             package main;
494              
495             # on cygwin
496              
497             my $is_cyg = $os->is_cyg;
498              
499             # true
500              
501             =back
502              
503             =over 4
504              
505             =item is_cyg example 3
506              
507             # given: synopsis
508              
509             package main;
510              
511             # on msys
512              
513             my $is_cyg = $os->is_cyg;
514              
515             # true
516              
517             =back
518              
519             =cut
520              
521             =head2 is_dos
522              
523             is_dos() (boolean)
524              
525             The is_dos method returns true if the OS is either C<"mswin32"> or C<"dos"> or
526             C<"os2">, and otherwise returns false.
527              
528             I>
529              
530             =over 4
531              
532             =item is_dos example 1
533              
534             # given: synopsis
535              
536             package main;
537              
538             # on linux
539              
540             my $is_dos = $os->is_dos;
541              
542             # false
543              
544             =back
545              
546             =over 4
547              
548             =item is_dos example 2
549              
550             # given: synopsis
551              
552             package main;
553              
554             # on mswin32
555              
556             my $is_dos = $os->is_dos;
557              
558             # true
559              
560             =back
561              
562             =over 4
563              
564             =item is_dos example 3
565              
566             # given: synopsis
567              
568             package main;
569              
570             # on dos
571              
572             my $is_dos = $os->is_dos;
573              
574             # true
575              
576             =back
577              
578             =over 4
579              
580             =item is_dos example 4
581              
582             # given: synopsis
583              
584             package main;
585              
586             # on os2
587              
588             my $is_dos = $os->is_dos;
589              
590             # true
591              
592             =back
593              
594             =cut
595              
596             =head2 is_lin
597              
598             is_lin() (boolean)
599              
600             The is_lin method returns true if the OS is C<"linux">, and otherwise returns
601             false.
602              
603             I>
604              
605             =over 4
606              
607             =item is_lin example 1
608              
609             # given: synopsis
610              
611             package main;
612              
613             # on linux
614              
615             my $is_lin = $os->is_lin;
616              
617             # true
618              
619             =back
620              
621             =over 4
622              
623             =item is_lin example 2
624              
625             # given: synopsis
626              
627             package main;
628              
629             # on macos
630              
631             my $is_lin = $os->is_lin;
632              
633             # false
634              
635             =back
636              
637             =over 4
638              
639             =item is_lin example 3
640              
641             # given: synopsis
642              
643             package main;
644              
645             # on mswin32
646              
647             my $is_lin = $os->is_lin;
648              
649             # false
650              
651             =back
652              
653             =cut
654              
655             =head2 is_mac
656              
657             is_mac() (boolean)
658              
659             The is_mac method returns true if the OS is either C<"macos"> or C<"darwin">,
660             and otherwise returns false.
661              
662             I>
663              
664             =over 4
665              
666             =item is_mac example 1
667              
668             # given: synopsis
669              
670             package main;
671              
672             # on linux
673              
674             my $is_mac = $os->is_mac;
675              
676             # false
677              
678             =back
679              
680             =over 4
681              
682             =item is_mac example 2
683              
684             # given: synopsis
685              
686             package main;
687              
688             # on macos
689              
690             my $is_mac = $os->is_mac;
691              
692             # true
693              
694             =back
695              
696             =over 4
697              
698             =item is_mac example 3
699              
700             # given: synopsis
701              
702             package main;
703              
704             # on darwin
705              
706             my $is_mac = $os->is_mac;
707              
708             # true
709              
710             =back
711              
712             =cut
713              
714             =head2 is_non
715              
716             is_non() (boolean)
717              
718             The is_non method returns true if the OS is not recognized, and if recognized
719             returns false.
720              
721             I>
722              
723             =over 4
724              
725             =item is_non example 1
726              
727             # given: synopsis
728              
729             package main;
730              
731             # on linux
732              
733             my $is_non = $os->is_non;
734              
735             # false
736              
737             =back
738              
739             =over 4
740              
741             =item is_non example 2
742              
743             # given: synopsis
744              
745             package main;
746              
747             # on aix
748              
749             my $is_non = $os->is_non;
750              
751             # true
752              
753             =back
754              
755             =cut
756              
757             =head2 is_sun
758              
759             is_sun() (boolean)
760              
761             The is_sun method returns true if the OS is either C<"solaris"> or C<"sunos">,
762             and otherwise returns false.
763              
764             I>
765              
766             =over 4
767              
768             =item is_sun example 1
769              
770             # given: synopsis
771              
772             package main;
773              
774             # on linux
775              
776             my $is_sun = $os->is_sun;
777              
778             # false
779              
780             =back
781              
782             =over 4
783              
784             =item is_sun example 2
785              
786             # given: synopsis
787              
788             package main;
789              
790             # on solaris
791              
792             my $is_sun = $os->is_sun;
793              
794             # true
795              
796             =back
797              
798             =over 4
799              
800             =item is_sun example 3
801              
802             # given: synopsis
803              
804             package main;
805              
806             # on sunos
807              
808             my $is_sun = $os->is_sun;
809              
810             # true
811              
812             =back
813              
814             =cut
815              
816             =head2 is_vms
817              
818             is_vms() (boolean)
819              
820             The is_vms method returns true if the OS is C<"vms">, and otherwise returns
821             false.
822              
823             I>
824              
825             =over 4
826              
827             =item is_vms example 1
828              
829             # given: synopsis
830              
831             package main;
832              
833             # on linux
834              
835             my $is_vms = $os->is_vms;
836              
837             # false
838              
839             =back
840              
841             =over 4
842              
843             =item is_vms example 2
844              
845             # given: synopsis
846              
847             package main;
848              
849             # on vms
850              
851             my $is_vms = $os->is_vms;
852              
853             # true
854              
855             =back
856              
857             =cut
858              
859             =head2 is_win
860              
861             is_win() (boolean)
862              
863             The is_win method returns true if the OS is either C<"mswin32"> or C<"dos"> or
864             C<"os2">, and otherwise returns false.
865              
866             I>
867              
868             =over 4
869              
870             =item is_win example 1
871              
872             # given: synopsis
873              
874             package main;
875              
876             # on linux
877              
878             my $is_win = $os->is_win;
879              
880             # false
881              
882             =back
883              
884             =over 4
885              
886             =item is_win example 2
887              
888             # given: synopsis
889              
890             package main;
891              
892             # on mswin32
893              
894             my $is_win = $os->is_win;
895              
896             # true
897              
898             =back
899              
900             =over 4
901              
902             =item is_win example 3
903              
904             # given: synopsis
905              
906             package main;
907              
908             # on dos
909              
910             my $is_win = $os->is_win;
911              
912             # true
913              
914             =back
915              
916             =over 4
917              
918             =item is_win example 4
919              
920             # given: synopsis
921              
922             package main;
923              
924             # on os2
925              
926             my $is_win = $os->is_win;
927              
928             # true
929              
930             =back
931              
932             =cut
933              
934             =head2 name
935              
936             name() (string)
937              
938             The name method returns the OS name.
939              
940             I>
941              
942             =over 4
943              
944             =item name example 1
945              
946             # given: synopsis
947              
948             package main;
949              
950             # on linux
951              
952             my $name = $os->name;
953              
954             # "linux"
955              
956             # same as $^O
957              
958             =back
959              
960             =cut
961              
962             =head2 paths
963              
964             paths() (arrayref)
965              
966             The paths method returns the paths specified by the C<"PATH"> environment
967             variable as an arrayref of unique paths. Returns a list in list context.
968              
969             I>
970              
971             =over 4
972              
973             =item paths example 1
974              
975             # given: synopsis
976              
977             package main;
978              
979             my $paths = $os->paths;
980              
981             # [
982             # "/root/local/bin",
983             # "/root/bin",
984             # "/usr/local/sbin",
985             # "/usr/local/bin",
986             # "/usr/sbin:/usr/bin",
987             # ]
988              
989             =back
990              
991             =cut
992              
993             =head2 quote
994              
995             quote(string $data) (string)
996              
997             The quote method accepts a string and returns the OS-specific quoted version of
998             the string.
999              
1000             I>
1001              
1002             =over 4
1003              
1004             =item quote example 1
1005              
1006             # given: synopsis
1007              
1008             package main;
1009              
1010             # on linux
1011              
1012             my $quote = $os->quote("hello \"world\"");
1013              
1014             # "'hello \"world\"'"
1015              
1016             =back
1017              
1018             =over 4
1019              
1020             =item quote example 2
1021              
1022             # given: synopsis
1023              
1024             package main;
1025              
1026             # on linux
1027              
1028             my $quote = $os->quote('hello \'world\'');
1029              
1030             # "'hello '\\''world'\\'''"
1031              
1032             =back
1033              
1034             =over 4
1035              
1036             =item quote example 3
1037              
1038             # given: synopsis
1039              
1040             package main;
1041              
1042             # on mswin32
1043              
1044             my $quote = $os->quote("hello \"world\"");
1045              
1046             # "\"hello \\"world\\"\""
1047              
1048             =back
1049              
1050             =over 4
1051              
1052             =item quote example 4
1053              
1054             # given: synopsis
1055              
1056             package main;
1057              
1058             # on mswin32
1059              
1060             my $quote = $os->quote('hello "world"');
1061              
1062             # '"hello \"world\""'
1063              
1064             =back
1065              
1066             =cut
1067              
1068             =head2 type
1069              
1070             type() (string)
1071              
1072             The type method returns a string representing the "test" method, which
1073             identifies the OS, that would return true if called, based on the name of the
1074             OS.
1075              
1076             I>
1077              
1078             =over 4
1079              
1080             =item type example 1
1081              
1082             # given: synopsis
1083              
1084             package main;
1085              
1086             # on linux
1087              
1088             my $type = $os->type;
1089              
1090             # "is_lin"
1091              
1092             =back
1093              
1094             =over 4
1095              
1096             =item type example 2
1097              
1098             # given: synopsis
1099              
1100             package main;
1101              
1102             # on macos
1103              
1104             my $type = $os->type;
1105              
1106             # "is_mac"
1107              
1108             =back
1109              
1110             =over 4
1111              
1112             =item type example 3
1113              
1114             # given: synopsis
1115              
1116             package main;
1117              
1118             # on mswin32
1119              
1120             my $type = $os->type;
1121              
1122             # "is_win"
1123              
1124             =back
1125              
1126             =over 4
1127              
1128             =item type example 4
1129              
1130             # given: synopsis
1131              
1132             package main;
1133              
1134             # on openbsd
1135              
1136             my $type = $os->type;
1137              
1138             # "is_bsd"
1139              
1140             =back
1141              
1142             =over 4
1143              
1144             =item type example 5
1145              
1146             # given: synopsis
1147              
1148             package main;
1149              
1150             # on cygwin
1151              
1152             my $type = $os->type;
1153              
1154             # "is_cyg"
1155              
1156             =back
1157              
1158             =over 4
1159              
1160             =item type example 6
1161              
1162             # given: synopsis
1163              
1164             package main;
1165              
1166             # on dos
1167              
1168             my $type = $os->type;
1169              
1170             # "is_win"
1171              
1172             =back
1173              
1174             =over 4
1175              
1176             =item type example 7
1177              
1178             # given: synopsis
1179              
1180             package main;
1181              
1182             # on solaris
1183              
1184             my $type = $os->type;
1185              
1186             # "is_sun"
1187              
1188             =back
1189              
1190             =over 4
1191              
1192             =item type example 8
1193              
1194             # given: synopsis
1195              
1196             package main;
1197              
1198             # on vms
1199              
1200             my $type = $os->type;
1201              
1202             # "is_vms"
1203              
1204             =back
1205              
1206             =cut
1207              
1208             =head2 where
1209              
1210             where(string $file) (arrayref)
1211              
1212             The where method searches the paths defined by the C environment variable
1213             for a file matching the name provided and returns all the files found as an
1214             arrayref. Returns a list in list context. This method doesn't check (or care)
1215             if the files found are actually executable.
1216              
1217             I>
1218              
1219             =over 4
1220              
1221             =item where example 1
1222              
1223             # given: synopsis
1224              
1225             package main;
1226              
1227             my $where = $os->where('cmd');
1228              
1229             # [
1230             # "t/path/user/local/bin/cmd",
1231             # "t/path/user/bin/cmd",
1232             # "t/path/usr/bin/cmd",
1233             # "t/path/usr/local/bin/cmd",
1234             # "t/path/usr/local/sbin/cmd",
1235             # "t/path/usr/sbin/cmd"
1236             # ]
1237              
1238             =back
1239              
1240             =over 4
1241              
1242             =item where example 2
1243              
1244             # given: synopsis
1245              
1246             package main;
1247              
1248             my $where = $os->where('app1');
1249              
1250             # [
1251             # "t/path/user/local/bin/app1",
1252             # "t/path/usr/bin/app1",
1253             # "t/path/usr/sbin/app1"
1254             # ]
1255              
1256             =back
1257              
1258             =over 4
1259              
1260             =item where example 3
1261              
1262             # given: synopsis
1263              
1264             package main;
1265              
1266             my $where = $os->where('app2');
1267              
1268             # [
1269             # "t/path/user/local/bin/app2",
1270             # "t/path/usr/bin/app2",
1271             # ]
1272              
1273             =back
1274              
1275             =over 4
1276              
1277             =item where example 4
1278              
1279             # given: synopsis
1280              
1281             package main;
1282              
1283             my $where = $os->where('app3');
1284              
1285             # [
1286             # "t/path/user/bin/app3",
1287             # "t/path/usr/sbin/app3"
1288             # ]
1289              
1290             =back
1291              
1292             =over 4
1293              
1294             =item where example 5
1295              
1296             # given: synopsis
1297              
1298             package main;
1299              
1300             my $where = $os->where('app4');
1301              
1302             # [
1303             # "t/path/user/local/bin/app4",
1304             # "t/path/usr/local/bin/app4",
1305             # "t/path/usr/local/sbin/app4",
1306             # ]
1307              
1308             =back
1309              
1310             =over 4
1311              
1312             =item where example 6
1313              
1314             # given: synopsis
1315              
1316             package main;
1317              
1318             my $where = $os->where('app5');
1319              
1320             # []
1321              
1322             =back
1323              
1324             =cut
1325              
1326             =head2 which
1327              
1328             which(string $file) (string)
1329              
1330             The which method returns the first match from the result of calling the
1331             L method with the arguments provided.
1332              
1333             I>
1334              
1335             =over 4
1336              
1337             =item which example 1
1338              
1339             # given: synopsis
1340              
1341             package main;
1342              
1343             my $which = $os->which('cmd');
1344              
1345             # "t/path/user/local/bin/cmd",
1346              
1347             =back
1348              
1349             =over 4
1350              
1351             =item which example 2
1352              
1353             # given: synopsis
1354              
1355             package main;
1356              
1357             my $which = $os->which('app1');
1358              
1359             # "t/path/user/local/bin/app1"
1360              
1361             =back
1362              
1363             =over 4
1364              
1365             =item which example 3
1366              
1367             # given: synopsis
1368              
1369             package main;
1370              
1371             my $which = $os->which('app2');
1372              
1373             # "t/path/user/local/bin/app2"
1374              
1375             =back
1376              
1377             =over 4
1378              
1379             =item which example 4
1380              
1381             # given: synopsis
1382              
1383             package main;
1384              
1385             my $which = $os->which('app3');
1386              
1387             # "t/path/user/bin/app3"
1388              
1389             =back
1390              
1391             =over 4
1392              
1393             =item which example 5
1394              
1395             # given: synopsis
1396              
1397             package main;
1398              
1399             my $which = $os->which('app4');
1400              
1401             # "t/path/user/local/bin/app4"
1402              
1403             =back
1404              
1405             =over 4
1406              
1407             =item which example 6
1408              
1409             # given: synopsis
1410              
1411             package main;
1412              
1413             my $which = $os->which('app5');
1414              
1415             # undef
1416              
1417             =back
1418              
1419             =cut
1420              
1421             =head1 AUTHORS
1422              
1423             Awncorp, C
1424              
1425             =cut
1426              
1427             =head1 LICENSE
1428              
1429             Copyright (C) 2000, Awncorp, C.
1430              
1431             This program is free software, you can redistribute it and/or modify it under
1432             the terms of the Apache license version 2.0.
1433              
1434             =cut