File-Macro

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.031.
LICENSE
MANIFEST
META.yml
Makefile.PL
README
dist.ini
lib/File/Macro.pm
t/01-base.t

META.yml  view on Meta::CPAN

build_requires:
  Test::More: '0'
configure_requires:
  ExtUtils::MakeMaker: '0'
dynamic_config: 0
generated_by: 'Dist::Zilla version 5.031, CPAN::Meta::Converter version 2.143240'
license: perl
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: '1.4'
name: File-Macro
requires:
  Exporter: '0'
  strict: '0'
  warnings: '0'
version: '0.001'

Makefile.PL  view on Meta::CPAN

use ExtUtils::MakeMaker;



my %WriteMakefileArgs = (
  "ABSTRACT" => "Read a file within a block scope",
  "AUTHOR" => "Jeffrey Goff <drforr\@pobox.com>",
  "CONFIGURE_REQUIRES" => {
    "ExtUtils::MakeMaker" => 0
  },
  "DISTNAME" => "File-Macro",
  "EXE_FILES" => [],
  "LICENSE" => "perl",
  "NAME" => "File::Macro",
  "PREREQ_PM" => {
    "Exporter" => 0,
    "strict" => 0,
    "warnings" => 0
  },
  "TEST_REQUIRES" => {
    "Test::More" => 0
  },
  "VERSION" => "0.001",
  "test" => {

README  view on Meta::CPAN



This archive contains the distribution File-Macro,
version 0.001:

  Read a file within a block scope

This software is copyright (c) 2015 by Jeffrey Goff.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.


dist.ini  view on Meta::CPAN

name    = File-Macro
author  = Jeffrey Goff <drforr@pobox.com>
license = Perl_5
copyright_holder = Jeffrey Goff
copyright_year   = 2015

version = 0.001

[@Git]
[@Basic]

lib/File/Macro.pm  view on Meta::CPAN

use strict;
use warnings;
package File::Macro;

use Exporter qw(import);

=head1 NAME

File::Macro - Read a file within a block scope

=head1 VERSION

Version 0.01

=cut

our $VERSION = '0.01';
our @EXPORT = qw( with_file );

=head1 SYNOPSIS

This module exists exclusively to provide a shorthand for the C<open... or die>
idiom. Instead of repeating the same boilerplate, you simply call C<with_file>
and do whatever you need to do with your file inside the block, which is
already opened for you in C<$_>.

    use File::Macro;
    with_file 'foo.csv' => '<' => sub {
        say <$_>;
    };

If you want to use a different variable for the filehandle, just specify it
after the mode selector, like so:

    my $fh;
    with_file 'foo.csv' => '<' => \$fh => sub {
        say <$fh>;

lib/File/Macro.pm  view on Meta::CPAN

}

=head1 AUTHOR

Jeff Goff, C<< <jgoff at cpan.org> >>

=head1 BUGS

Please report any bugs or feature requests to C<bug-file-macro at rt.cpan.org>,
or through the web interface at
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Macro>. 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 File::Macro

You can also look for information at:

=over 4

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

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

=item * AnnoCPAN: Annotated CPAN documentation

L<http://annocpan.org/dist/File-Macro>

=item * CPAN Ratings

L<http://cpanratings.perl.org/d/File-Macro>

=item * Search CPAN

L<http://search.cpan.org/dist/File-Macro/>

=back

=head1 ACKNOWLEDGEMENTS

=head1 LICENSE AND COPYRIGHT

Copyright 2014 Jeff Goff.

This program is free software; you can redistribute it and/or modify it

t/01-base.t  view on Meta::CPAN

#!perl -T

use Test::More tests => 11;

use_ok( 'File::Macro' ) || print "Bail out!\n";

{ my $str;
  ok(!defined $_);
  with_file( 't/01-base.t', '<', sub {
    $str = <$_>;
  } );
  ok(!defined $_);
  ok($str);
  like($str, qr/perl/);
}



( run in 1.119 second using v1.01-cache-2.11-cpan-49f99fa48dc )