Acme-Backwards

 view release on metacpan or  search on metacpan

lib/Acme/Backwards.pm  view on Meta::CPAN

package Acme::Backwards; 
our $VERSION = '1.01';
use Keyword::Declare;
sub import {
	keytype OKAY is m{(?:fisle (?&PerlNWS)(?&PerlExpression).*?;|esle (?&PerlNWS).*?;)?+}xms;
	keyword rof (/(my\s*\$\w+)?/ $declare, Expr $test, /.+?;$/ $code) {_backwards('for', ($declare ? $declare : ()), $test, $code);};
	keyword fi (Expr $test, /.+?;/ $code, OKAY @next) {_backwards('if', $test, $code)._process_backwards(@next);};
	keyword sselnu (Expr $test, /.+?;/ $code, OKAY @next) {_backwards('unless', $test, $code)._process_backwards(@next);};
}
sub _process_backwards {join' ',map{$_=~m/(fisle|esle)(.*)$/;return"_$1"->($2)}@_;}
sub _esle {_backwards('else','',shift)}
sub _fisle {shift=~m/\s*((?&PerlExpression))\s*(.*?;) $PPR::GRAMMAR/gxm;_backwards('elsif', $1, $2);}
sub _backwards {scalar@_>3?sprintf"%s %s %s { %s }",@_:sprintf"%s %s { %s }",@_;}

1;

__END__

=head1 NAME

Acme::Backwards - One line fi, esle, fisle, sselnu, rof

=head1 VERSION

Version 1.01

=cut

=head1 SYNOPSIS

Quick summary of what the module does.

Perhaps a little code snippet.

	use Acme::Backwards;

	my $str = 'backwards'
	fi ( $str eq 'backwards' ) say $str; 
	
	sselnu ( $str eq 'forwards' ) say $str;

	fi ( $str eq 'forwards' ) say $str;
	fisle ( $str eq 'backwards' ) say $str;
	esle die $str;

	my $int = 0;
	rof (qw/1 2 3/) $int += $_;
	rof my $var (qw/4 5 6/) $int += $var;
	rof my $nest (qw/7 8/) fi ($nest == 7) print "one"; esle print "line";

=head1 EXPORTS

=head2 fi

if

=head2 fisle

elsif

=head2 esle

else

=head2 sselnu

unless

=head2 rof

for

=head1 AUTHOR

LNATION, C<< <thisusedtobeanemail at gmail.com> >>

=head1 BUGS

Please report any bugs or feature requests to C<bug-acme-backwards at rt.cpan.org>, or through
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Acme-Backwards>.  I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.

=head1 SUPPORT

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

    perldoc Acme::Backwards


You can also look for information at:

=over 2

=item * RT: CPAN's request tracker (report bugs here)

L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Acme-Backwards>

=item * Search CPAN

L<http://search.cpan.org/dist/Acme-Backwards/>

=back

=head1 ACKNOWLEDGEMENTS

=head1 LICENSE AND COPYRIGHT

Copyright 2019->2025 LNATION.



( run in 3.261 seconds using v1.01-cache-2.11-cpan-75ffa21a3d4 )