Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: netswap.pl (style/coding comments)

by OeufMayo (Curate)
on Jun 04, 2001 at 02:16 UTC ( #85378=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl -wi.bak
    use strict;
    
  2. or download this
    my %params;
    my $filename = shift || die "Usage: netswap.pl CONFILENAME\n";
    
  3. or download this
    open(FH,"$filename")
        or die "Could not open network configuration file: [$filename] for
    + reading: $!\n";
    
  4. or download this
    while(<FH>){
        # Skip the blank lines or the commented lines
    ...
        # avoid typing mistakes
        $params{$name} = lc($value);
    }
    
  5. or download this
    print <<"EOL";
    new hostname    = [$params{hostname}]
    ...
    new gateway     = [$params{gateway}]
    
    EOL
    
  6. or download this
    my $replacements = {
        '/etc/hosts' => {
    ...
        my $replacements = shift;
        foreach my $filename (keys %{$replacements}){
            print STDERR "Processing file [$filename]\n";
    
  7. or download this
            unless (-e $filename){
                print STDERR "  [$filename] cannot be found!\n";
                next;
            }
    
  8. or download this
            @ARGV=($filename); # put the filename where perl can find it.
            while(<>){ 
    ...
            print STDERR "  done\n";
        }
    }
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2014-09-21 10:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (168 votes), past polls