Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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.

In reply to Re: Solution for your prof by nikos
in thread <> diamond Operator by kocaweb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-25 17:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found