Alex 'AdUser' Z
10 years ago
4 changed files with 52 additions and 55 deletions
@ -0,0 +1,35 @@
|
||||
package Text::Playlist; |
||||
|
||||
use strict; |
||||
use warnings; |
||||
|
||||
our $VERSION = 0.1; |
||||
|
||||
sub items { |
||||
my ($self) = @_; |
||||
|
||||
return wantarray ? @{$self->{items}} : $self->{items}; |
||||
} |
||||
|
||||
sub load { |
||||
my ($self, $file) = @_; |
||||
|
||||
open(my $FH, "<", $file) or return $!; |
||||
local $/ = undef; |
||||
my $content = <$FH>; |
||||
close($FH); |
||||
|
||||
return $self->parse($content); |
||||
} |
||||
|
||||
sub save { |
||||
my ($self, $file) = @_; |
||||
|
||||
open(my $FH, ">", $file) or die $!; |
||||
print $FH $self->dump(); |
||||
close($FH); |
||||
|
||||
return 1; |
||||
} |
||||
|
||||
1; |
Loading…
Reference in new issue