Start with getting the information you need from the command line.
Space separated tokens from the command line are in the predeclared array @ARGV.
A multi-word pattern needs to have " or ' quotes depending upon OS.
#!/usr/bin/perl
use strict;
use warnings;
my ($pattern, @files) = @ARGV;
print "pattern=$pattern files are:@files\n";
__END__
example:
>mygrep.pl "some pattern" filea fileb filec
pattern=some pattern files are:filea fileb filec
I would suggest starting with a more simple subset of the problem.
Write a program that opens FileA.txt and then prints all lines that contain "asdf".
Create FileA.txt with test cases as you wish.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.