Hi!
I guess all of us have told him too much about learning Perl and studying at school. Enougn is said and done. He should realize he has to learn basics of Perl if he wants to pass the course. It's up to him to decide what to do with his own life. We did all we could to help him. I think the time has come to let him do whatever he wants to do with the solution of the assignment.
#!/usr/bin/perl
use strict;
use warnings;
print "First_name Last_name\n";
foreach my $file (@ARGV) {
open(FILE, "<$file");
if( $file eq "file1" ) {
$file="sysbacks/file1";
} elsif ( $file eq "file2" ) {
$file="alpha/file2"
} elsif ( $file eq "file3" ) {
$file="gamma/blue/file3";
} elsif ( ($file eq "file4") || ( $file eq "file5" ) ) {
$file="gamma/green/$file";
}
open(OUTPUT, ">$file");
while(<FILE>) {
s/xxx/ggg/gi;
s/alpha/ALPHA/g;
print OUTPUT;
}
close(FILE);
close(OUTPUT);
}
P.S. Tested on perl 5.6.1 build for i386-freebsd
P.S.S. It's been written this way to make his professor believe he wrote it.
P.S.S.S. I think his prof won't understand jonadab's solution. I don't expect him to be a perlmonk. I might be wrong. I'm sorry I didn't want to offend him.
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.