File perl-File-Grep.spec of Package perl-File-Grep

#
# spec file for package perl-File-Grep
#
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           perl-File-Grep
Version:        0.02
Release:        0
%define cpan_name File-Grep
Summary:        Find matches to a pattern in a series of files and related
License:        CHECK(GPL-1.0+ or Artistic-1.0)
Group:          Development/Libraries/Perl
Url:            http://search.cpan.org/dist/File-Grep/
Source0:        http://www.cpan.org/authors/id/M/MN/MNEYLON/%{cpan_name}-%{version}.tar.gz
BuildArch:      noarch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  perl
BuildRequires:  perl-macros
%{perl_requires}

%description
File::Grep mimics the functionality of the grep function in perl, but
applying it to files instead of a list. This is similar in nature to the
UNIX grep command, but more powerful as the pattern can be any legal perl
function.

The main functions provided by this module are:

* fgrep BLOCK LIST

Performs a grep operation on the files in LIST, using BLOCK as the critiria
for accepting a line or not. Any lines that match will be added to an array
that will be returned to the caller. Note that in void context, this
function will immediate return true on the first match, false otherwise,
and in scalar context, it will only return the number of matches.

When entering BLOCK, the $_ variable will be localized to the current line.
In addition, you will be given the position in LIST of the current file,
the line number in that file, and the line itself as arguments to this
function. While you can change $_ if necessary, only the original value of
the line will be added to the returned list. If you need to get the
modified value, use fmap (described below).

The LIST can contain either scalars or filehandle (or filehandle-like
objects). If the item is a scalar, it will be attempted to be opened and
read in as normal. Otherwise it will be treated as a filehandle. Any errors
resulting from IO may be reported to STDERR by setting the class variable,
$File::Grep::SILENT to false; otherwise, no error indication is given.

* fmap BLOCK LIST

Performs a map operation on the files in LIST, using BLOCK as the mapping
function. The results from BLOCK will be appended to the list that is
returned at the end of the call.

* fdo BLOCK LIST

Performs the equivalent of a foreach operation on the files in LIST,
performing BLOCK for each line in each file. This function has no return
value. If you need to specialize more than what fgrep or fmap offer, you
can use this function.

In addition, if you need additional fine control, you can use the internal
function _fgrep_process. This is called just like fgrep/fmap/fdo, as in
"_fgrep_process BLOCK LIST" except that you can control when the fucntion
'short circuits' by the return value from BLOCK. If, after processing a
line, the BLOCK returns a negative number, the entire process is aborted,
closing any open filehandles that were opened by the function. If the
return value is 0, the current file is aborted, closed if opened by the
function and the next file is then searched. A positive return value will
simply go on to the next line as appropriate.

%prep
%setup -q -n %{cpan_name}-%{version}
find . -type f ! -name \*.pl -print0 | xargs -0 chmod 644

%build
%{__perl} Makefile.PL INSTALLDIRS=vendor
%{__make} %{?_smp_mflags}

%check
%{__make} test

%install
%perl_make_install
%perl_process_packlist
%perl_gen_filelist

%files -f %{name}.files
%defattr(-,root,root,755)
%doc Changes README

%changelog
openSUSE Build Service is sponsored by