The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

ack - grep-like text finder

SYNOPSIS

    ack [options] PATTERN [FILE...]
    ack -f [options] [DIRECTORY...]

DESCRIPTION

Ack is designed as a replacement for grep.

Ack searches the named input FILEs (or standard input if no files are named, or the file name - is given) for lines containing a match to the given PATTERN. By default, ack prints the matching lines.

Ack can also list files that would be searched, without actually searching them, to let you take advantage of ack's file-type filtering capabilities.

OPTIONS

-a, --all

Operate on all files, regardless of type (but still skip directories like blib, CVS, etc.

-c, --count

Suppress normal output; instead print a count of matching lines for each input file.

--color, --nocolor

--color highlights the matching text. --nocolor supresses the color. This is on by default unless the output is redirected, or running under Windows.

-f

Only print the files that would be searched, without actually doing any searching. PATTERN must not be specified, or it will be taken as a path to search.

--group, --nogroup

--group groups matches by file name with. This is the default when used interactively.

--nogroup prints one result per line, like grep. This is the default when output is redirected.

-H, --with-filename

Print the filename for each match.

-h, --no-filename

Suppress the prefixing of filenames on output when multiple files are searched.

--help

Print a short help statement.

-i, --ignore-case

Ignore case in the search strings.

-l, --files-with-matches

Only print the filenames of matching files, instead of the matching text.

-m=NUM, --max-count=NUM

Stop reading a file after NUM matches.

--man

Print this manual page.

-n

No descending into subdirectories.

-o

Show only the part of each line matching PATTERN (turns off text highlighting)

--output=expr

Output the evaluation of expr for each line (turns off text highlighting)

-Q

Quote all metacharacters. PATTERN is treated as a literal.

--thpppt

Display the crucial Bill The Cat logo. Note that the exact spelling of --thpppppt is not important. It's checked against a regular expression.

-v, --invert-match

Invert match: select non-matching lines

--version

Display version and copyright information.

-w, --word-regexp

Force PATTERN to match only whole words. The PATTERN is wrapped with \b metacharacters.

ENVIRONMENT VARIABLES

ACK_OPTIONS

This variable specifies default options to be placed in front of any explicit options.

GOTCHAS

Note that FILES must still match valid selection rules. For example,

    ack something --perl foo.rb

will search nothing, because foo.rb is a Ruby file.

NAME

File::Next - File-finding iterator

VERSION

Version 0.32

SYNOPSIS

File::Next is a lightweight, taint-safe file-finding module. It's lightweight and has no non-core prerequisites.

    use File::Next;

    my $files = File::Next->files( '/tmp' );

    while ( my $file = $files->() ) {
        # do something...
    }

OPERATIONAL THEORY

Each of the public functions in File::Next returns an iterator that will walk through a directory tree. The simplest use case is:

    use File::Next;

    my $iter = File::Next->files( '/tmp' );

    while ( my $file = $iter->() ) {
        print $file, "\n";
    }

    # Prints...
    /tmp/foo.txt
    /tmp/bar.pl
    /tmp/baz/1
    /tmp/baz/2.txt
    /tmp/baz/wango/tango/purple.txt

Note that only files are returned by files()'s iterator.

The first parameter to any of the iterator factory functions may be a hashref of parameters.

Note that the iterator will only return files, not directories.

PARAMETERS

file_filter -> \&file_filter

The file_filter lets you check to see if it's really a file you want to get back. If the file_filter returns a true value, the file will be returned; if false, it will be skipped.

The file_filter function takes no arguments but rather does its work through a collection of variables.

  • $_ is the current filename within that directory

  • $File::Next::dir is the current directory name

  • $File::Next::name is the complete pathname to the file

These are analogous to the same variables in File::Find.

    my $iter = File::Find::files( { file_filter => sub { /\.txt$/ } }, '/tmp' );

By default, the file_filter is sub {1}, or "all files".

descend_filter => \&descend_filter

The descend_filter lets you check to see if the iterator should descend into a given directory. Maybe you want to skip CVS and .svn directories.

    my $descend_filter = sub { $_ ne "CVS" && $_ ne ".svn" }

The descend_filter function takes no arguments but rather does its work through a collection of variables.

  • $_ is the current filename of the directory

  • $File::Next::dir is the complete directory name

The descend filter is NOT applied to any directory names specified in the constructor. For example,

    my $iter = File::Find::files( { descend_filter => sub{0} }, '/tmp' );

always descends into /tmp, as you would expect.

By default, the descend_filter is sub {1}, or "always descend".

error_handler => \&error_handler

If error_handler is set, then any errors will be sent through it. By default, this value is CORE::die.

sort_files => [ 0 | 1 | \&sort_sub]

If you want files sorted, pass in some true value, as in sort_files => 1.

If you want a special sort order, pass in a sort function like sort_files => sub { $a->[1] cmp $b->[1] }. Note that the parms passed in to the sub are arrayrefs, where $a->[0] is the directory name and $a->[1] is the file name. Typically you're going to be sorting on $a->[1].

FUNCTIONS

files( { \%parameters }, @starting points )

Returns an iterator that walks directories starting with the items in @starting_points.

All file-finding in this module is adapted from Mark Jason Dominus' marvelous Higher Order Perl, page 126.

sort_standard( $a, $b )

A sort function for passing as a sort_files parameter:

    my $iter = File::Next::files( {
        sort_files => \&File::Next::sort_reverse
    }, 't/swamp' );

This function is the default, so the code above is identical to:

    my $iter = File::Next::files( {
        sort_files => \&File::Next::sort_reverse
    }, 't/swamp' );

sort_reverse( $a, $b )

Same as sort_standard, but in reverse.

Pulls out the files/dirs that might be worth looking into in $dir. If $dir is the empty string, then search the current directory. This is different than explicitly passing in a ".", because that will get prepended to the path names.

$parms is the hashref of parms passed into File::Next constructor.

AUTHOR

Andy Lester, <andy at petdance.com>

BUGS

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

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2006 Andy Lester, all rights reserved.

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

NAME

App::Ack - A container for functions for the ack program

VERSION

Version 1.38

SYNOPSIS

If you want to know about the ack program

No user-serviceable parts inside. ack is all that should use this.

FUNCTIONS

is_filetype( $filename, $filetype )

Asks whether $filename is of type $filetype.

skipdir_filter

Standard filter to pass as a File::Next descend_filter. It returns true if the directory is any of the ones we know we want to skip.

filetypes( $filename )

Returns a list of types that $filename could be. For example, a file foo.pod could be "perl" or "parrot".

The filetype will be undef if we can't determine it. This could be if the file doesn't exist, or it can't be read.

It will be '-ignore' if it's something that ack should always ignore, even under -a.

filetypes_supported()

Returns a list of all the types that we can detect.

show_help()

Dumps the help page to the user.

AUTHOR

Andy Lester, <andy at petdance.com>

BUGS

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

SUPPORT

The App::Ack module isn't very interesting to users. However, you may find useful information about this distribution at:

ACKNOWLEDGEMENTS

Thanks to everyone who has contributed to ack in any way, including Rick Scott, Ask Bjørn Hanse, Jerry Gay, Will Coleda, Mike O'Regan, Slaven Rezic, Mark Stosberg, David Alan Pisoni, Adriano Ferreira, James Keenan, Leland Johnson, Ricardo Signes and Pete Krawczyk.

COPYRIGHT & LICENSE

Copyright 2005-2006 Andy Lester, all rights reserved.

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

1 POD Error

The following errors were encountered while parsing the POD:

Around line 1097:

Non-ASCII character seen before =encoding in 'Bjørn'. Assuming UTF-8