Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^4: Easiest way to filter a file based on user input (updated)

by Peter Keystrokes (Beadle)
on Jul 07, 2017 at 16:24 UTC ( [id://1194518]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Easiest way to filter a file based on user input (updated)
in thread Easiest way to filter a file based on user input

I tried to implement the special number regex as such:

#!/usr/bin/env perl use strict; use warnings; use Regexp::Common; print "Enter limit: "; chomp( my $limit = <STDIN> ); $limit = abs($limit); open my $IN, '<', "xt_spacer_results.hairpin" or die $!; open my $SIFTED, '>', "new_xt_spacer_results.hairpin" or die $!; while (<$IN>){ next if /^None/; next if /^( $RE{num}{real}{-places=>2})/ && $1 > $limit; print $SIFTED $_; } close $IN; close $SIFTED;

But it aborts the program due to  use Regexp::Common; and it states:

Can't locate Regexp/Common.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at energy_sifter2.pl line 4. BEGIN failed--compilation aborted at energy_sifter2.pl line 4.

I'm not quite sure how to use modules. Do I download the module somehow and save it in the same file I'm working in?

Replies are listed 'Best First'.
Re^5: Easiest way to filter a file based on user input (updated)
by hippo (Bishop) on Jul 07, 2017 at 16:44 UTC
    I'm not quite sure how to use modules. Do I download the module somehow and save it in the same file I'm working in?

    Brew yourself a big pot of coffee and have a thorough read of A Guide to Installing Modules. You won't look back.

      How do you apply the module to your script?

      use lib '/location/of/module/';

      or something along the lines of:

      use Regexp::Common

        The latter. See use for examples and the FAQ What's the difference between require and use? for more detail.

        Addendum: Also, almost every module (including Regexp::Common) has a SYNOPSIS section in its documentation which includes a code snippet showing how to use it.

        Perl and (almost) all of its modules have excellent documentation. It will pay you dividends to learn where that documentation is, how to search it and how to understand what you find there.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1194518]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-20 03:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found