Module-Generic
view release on metacpan or search on metacpan
- Added method except() in Module::Generic::Array
- Corrected _parse_timestamp for a date patter that is for GMT and ensures the format set has GMT time zone.
- Improved the support method _warnings_is_enabled to check if class is even registered
- Corrected mishandling of IO layer when opening scalar with Module::Generic::Scalar::IO
- Improved _get_args_as_hash in Module::Generic to allow parameters to be mixed with other arguments
v0.23.1 2022-03-28T11:18:17+0900
- Added method _set_get_glob in Module::Generic
- Corrected a small bug in Module::Generic::Dynamic
- Corrected a small bug in method content() in Module::Generic::File
- Added method chown in Module::Generic::File
- Added method datetime in Module::Generic::DateTime
- Made a minor correction in chmod when reporting the mode upon error
- Changed autoload of methods in Module::Generic
- Updated the methods append and prepend in Module::Generic::Scalar to also accept sa calar reference or object
- Changed return value for _set_get_scalar_as_object to the object when the context is object
- Corrected a minor bug in pass_error in Module::Generic
- Minor improvement on when a directory was removed while perl was running affecting _uri_file_cwd() in Module::Generic::File
v0.23.0 2022-03-27T20:30:48+0900
- Minor improvement in _parse_timestamp
lib/Module/Generic.pm view on Meta::CPAN
# This forbids variables, code blocks, Perl ops, backticks, etc.
if( $params =~ /[^a-zA-Z0-9_,\=>\s\h[:blank:]'"\|\(\)\.\-]/ )
{
$self->__message( 120, "\$process_params->(): Illegal characters found inside eval." );
return;
}
# illegal functions that have no business being here, and could pass through the previous check
elsif( $params =~ /\b(?:
qx|system|open|exec|fork|require|use|eval|do|
package|sub|BEGIN|UNITCHECK|CHECK|INIT|END|
readpipe|sysopen|unlink|rename|chmod|chown|utime|truncate|mkdir|rmdir|opendir|readdir|closedir|glob
)\b/i )
{
$self->__message( 120, "\$process_params->(): Illegal functions used inside eval." );
return;
}
local $SIG{__WARN__} = sub{};
local $SIG{__DIE__} = sub{};
local $@;
my @res = eval( $params );
lib/Module/Generic/File.pm view on Meta::CPAN
warn( "Relative mode definition \"$def\" is malformed." ) if( warnings::enabled( 'Module::Generic' ) );
}
}
}
my $file = $self->filename;
CORE::chmod( $mode, $file ) || return( $self->error( sprintf( "An error occurred while changing mode for file \"$file\" to %o: $!", $mode ) ) );
$self->finfo->reset;
return( $self );
}
sub chown
{
my $self = shift( @_ );
my( $uid, $gid ) = @_;
my $f = $self->filename;
my $what = $self->is_dir ? 'directory' : 'file';
# try-catch
local $@;
my $rv;
eval
{
$rv = CORE::chown( $uid, $gid, "$f" );
};
if( $@ )
{
return( $self->error( "Unable to chown ${what} $f: $@" ) );
}
return( $rv );
}
sub cleanup { return( shift->_set_get_boolean( 'auto_remove', @_ ) ); }
sub close
{
my $self = shift( @_ );
my $io = $self->opened || return( $self );
lib/Module/Generic/File.pm view on Meta::CPAN
if the directory does not exist, it returns an empty L<Module::Generic::Array> object.
Upon error, it sets an L<error object|Module::Generic::Exception>, and returns C<undef> in scalar context, and an empty list in list context.
=head2 chmod
Provided with an octal value or a human file mode such as C<a+rw> and this will attempt to set the file or directory mode accordingly.
It returns the current object upon success or undef and sets an exception object upon error.
=head2 chown
Provided with an C<uid> and a C<gid> and this will call L<perlfunc/chown> on the underlying directory or file.
Both C<uid> and C<gid> must be provided, but you can provide a value of C<-1> to tell perl you do not want to change the value.
It returns true if the file or directory was changed, or o otherwise.
If an error occurred, it sets an L<error|Module::Generic/error> and return C<undef>
See L<perlport> for C<chown> portability limitations.
=head2 cleanup
This is an alias for L</auto_remove>. It enables or disables the auto cleanup of temporary file or directory upon perl cleanup phase.
$tmp->cleanup(1); # Enable it
my $bool = $tmp->cleanup;
=head2 close
( run in 0.582 second using v1.01-cache-2.11-cpan-71847e10f99 )