Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
For anyone who's interested, here's a script which will disable the Caps Lock key under Linux, or turn it back on.  The default is to apply it only to the current user; to make the change global, the -g switch is used.
#!/usr/bin/perl -w # # Disable/Enable the caps lock key # 051206 liverpole # ############## ### Strict ### ############## use strict; use warnings; #################### ### User-defined ### #################### my $xmodmap = '/usr/bin/X11/xmodmap'; my $sysmodmap = '/etc/X11/Xmodmap'; my $usrmodmap = $ENV{'HOME'} . "/.Xmodmap"; ################# ### Libraries ### ################# use FileHandle; use File::Basename; use Getopt::Long; ############### ### Globals ### ############### my $iam = basename $0; my $b_global = 0; my $syntax = " syntax: $iam [switches] <'off' | 'on'> Disables or reenables the CAPS LOCK key by changing the appropriat +e 'Xmodmap' file. Use 'off' to disable, and 'on' to reenable. Switches: -g ... apply the change globally (must be run as 'root' +) "; #################### ### Command-line ### #################### GetOptions("g" => \$b_global) or die $syntax; (my $state = shift) or die $syntax; if ($state ne 'off' && $state ne 'on') { die "$iam: invalid state '$state' (should be 'off' or 'on')\n"; } ################### ### Subroutines ### ################### sub perform($) { my ($cmd) = @_; print "% $cmd\n"; system($cmd) } #################### ### Main program ### #################### # If making global changes, make sure user is 'root' if ($b_global) { (0 == $<) or die "$iam: you must run this as 'root'\n"; } # Read the appropriate file my $infile = ($b_global || (!-e $usrmodmap))? $sysmodmap: $usrmodmap; my $fh = new FileHandle; open($fh, "<", $infile) or die "$iam: cannot read '$infile' ($!)\n"; chomp(my @lines = <$fh>); close $fh; printf "Read '$infile' -- %d line%s\n", 0 + @lines, (1 == @lines)? "": + "s"; # Modify the file @lines = grep { !/^\s*(remove|add)\s+Lock\s+=\s+Caps_Lock\s*(!|$)/i } +@lines; ($state eq 'off') and push @lines, "remove Lock = Caps_Lock"; ($state eq 'on') and push @lines, "add Lock = Caps_Lock"; # Write the file my $outfile = $b_global? $sysmodmap: $usrmodmap; open($fh, ">", $outfile) or die "$iam: cannot write '$outfile' ($!)\n +"; map { print $fh "$_\n" } @lines; printf "Wrote '$outfile' -- %d line%s\n", 0 + @lines, (1 == @lines)? " +": "s"; close $fh; # Make the changes take effect if (-x $xmodmap) { (-f $sysmodmap) and perform "$xmodmap $sysmodmap"; (-f $usrmodmap) and perform "$xmodmap $usrmodmap"; }

@ARGV=split//,"/:L"; map{print substr crypt($_,ord pop),2,3}qw"PerlyouC READPIPE provides"

In reply to Re: The most useless key on my keyboard is: by liverpole
in thread The most useless key on my keyboard is: by davido

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (10)
    As of 2014-09-30 19:47 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

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











      Results (383 votes), past polls