File tree 1 file changed +15
-4
lines changed
1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change 3
3
use strict;
4
4
use warnings;
5
5
6
- use local ::lib ' perl5' ;
6
+ use if -d " perl5 " , ' local::lib' => ' perl5' ;
7
7
8
8
use Getopt::Long;
9
9
use Pod::Usage;
10
+ use File::Temp qw( :POSIX ) ;
10
11
11
12
use Tie::iCal;
12
13
use DateTime::Format::ICal;
19
20
20
21
my $file ;
21
22
my $help = 0;
23
+ my $stdout = 0;
24
+ my $vcal = 0;
22
25
my %shows ;
23
26
24
27
GetOptions (
25
28
' file=s' => \$file ,
26
- ' help' => \$help ,
27
- ) and $file
29
+ ' stdout' => \$stdout ,
30
+ ' vcal' => \$vcal ,
31
+ ' help' => \$help ,
32
+ ) and ($file || $stdout )
28
33
or die pod2usage( # Print documentation and quit if bad opts
29
34
-exitval => $help , # With return value 0 if $help was not set
30
35
-verbose => 2 # Print all the sections
31
36
);
32
37
38
+ $file = tmpnam() if $stdout ;
33
39
system " touch $file " ;
34
-
35
40
tie %shows , ' Tie::iCal' , $file ;
36
41
37
42
my %dayHash = (
92
97
93
98
untie %shows ;
94
99
100
+ unless ($vcal ) {
101
+ my $staging = tmpnam();
102
+ system " echo BEGIN:VCALENDAR > $staging && grep -v VCALENDAR $file >> $staging && echo END:VCALENDAR >> $staging && cat $staging > $file && rm $staging " ;
103
+ }
104
+ system " cat $file && rm $file " if $stdout ;
105
+
95
106
__END__
96
107
97
108
=head1 NAME
You can’t perform that action at this time.
0 commit comments