Hi All monks, I had posted an earlier question related to this one, but forgive me in advance because now I want to use @ARGV and not <>. So I want to run the script with the same functionality as below (userA mapped to userB's .profile and or userA mapped to userB's profile and userC mapped to userD's .profile and or userE and userF mapped to userG's .profile) like:

$ perl script -userA -userB

or $ perl script -userA -userB -userC -userD

or $ perl script -userE -userF -userG

as opposed to $ perl script then typing in the userA userB, CNTRL-D, userC userD

thanks!

#!/usr/bin/env perl use strict; use warnings; my (%adds, $user, $muser,); LOOP:while (<>) { chomp; ($user, $muser) = map lc, split; if ( s/[a-z]//g <= 5 ) { print uc("\nyou must enter at least 6 characters, try again!!!?? +?\n\n"); goto LOOP; } else { if ( -d "/users/$muser" ) { $adds{$user} = qx(ls /users/$muser/.profile); } elsif ( -d "/home/$muser" ) { $adds{$user} = qx(ls /home/$muser/.profile); } else { print "\n$muser does not have a /users subdir, exiting!\n\n"; exit 0; } print uc("\nnow building user associations for your user-adds!\n"); while ( my ($key, $val) = each(%adds) ) { print "\n$key will have a profile of $val\n"; chomp ($key,$val); if ( ! -d "/users/$key" ) { system("mkdir /users/$key"); system("chown $key:users /users/$key"); system("ln -sf $val /users/$key/.profile"); } } }

In reply to switching from <> to $ARGV by Anonymous Monk

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



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.