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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|