The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Hades::Macro::FH - Hades macro helpers for FH

VERSION

Version 0.01

SYNOPSIS

Quick summary of what the module does:

Hades->run({
	eval => q|
		macro {
			FH [ alias => { read_file => [qw/rf/], write_file => [qw/wf/] } ]
		}
		Kosmos { 
			geras $file :t(Str) :d('path/to/file.txt') { 
				€rf($file);
				$content = 'limos';
				€wf($file, $content);
			}
		}
	|;
});

... generates ...

package Kosmos;
use strict;
use warnings;
our $VERSION = 0.01;

sub new {
	my ( $cls, %args ) = ( shift(), scalar @_ == 1 ? %{ $_[0] } : @_ );
	my $self      = bless {}, $cls;
	my %accessors = ();
	for my $accessor ( keys %accessors ) {
		my $value
		    = $self->$accessor(
			defined $args{$accessor}
			? $args{$accessor}
			: $accessors{$accessor}->{default} );
		unless ( !$accessors{$accessor}->{required} || defined $value ) {
			die "$accessor accessor is required";
		}
	}
	return $self;
}

sub geras {
	my ( $self, $file ) = @_;
	$file = defined $file ? $file : 'path/to/file.txt';
	if ( !defined($file) || ref $file ) {
		$file = defined $file ? $file : 'undef';
		die qq{Str: invalid value $file for variable \$file in method geras};
	}

	open my $fh, "<", $file or die "cannot open file for reading: $!";
	my $content = do { local $/; <$fh> };
	close $fh;
	$content = 'limos';
	open my $wh, ">", $file or die "cannot open file for writing: $!";
	print $wh $content;
	close $wh;

}

1;

__END__

SUBROUTINES/METHODS

new

Instantiate a new Hades::Macro::FH object.

Hades::Macro::FH->new

open_write

call open_write method. Expects param $mg to be a Object, param $file to be a Str, param $variable to be a Str, param $error to be a Str.

$obj->open_write($mg, $file, $variable, $error)

open_read

call open_read method. Expects param $mg to be a Object, param $file to be a Str, param $variable to be a Str, param $error to be a Str.

$obj->open_read($mg, $file, $variable, $error)

close_file

call close_file method. Expects param $mg to be a Object, param $file to be a Str, param $variable to be a Str.

$obj->close_file($mg, $file, $variable)

read_file

call read_file method. Expects param $mg to be a Object, param $file to be a Str, param $variable to be a Str, param $error to be a Str.

$obj->read_file($mg, $file, $variable, $error)

write_file

call write_file method. Expects param $mg to be a Object, param $file to be a Str, param $content to be a Str, param $variable to be a Str, param $error to be a Str.

$obj->write_file($mg, $file, $content, $variable, $error)

ACCESSORS

macro

get or set macro.

$obj->macro;

$obj->macro($value);

AUTHOR

LNATION, <email at lnation.org>

BUGS

Please report any bugs or feature requests to bug-hades::macro::fh at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Hades-Macro-FH. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Hades::Macro::FH

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

This software is Copyright (c) 2020 by LNATION.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)

1 POD Error

The following errors were encountered while parsing the POD:

Around line 218:

Non-ASCII character seen before =encoding in '€rf($file);'. Assuming UTF-8