Changing desktop background to the next available one
Use while to iterate over directory elements and skip reading them all at once into array,

opendir my $WALLSDIR, '/home/chummer/pictures/walls';
while (my $file = readdir($WALLSDIR)) {
    next if $file eq '.' or $file eq '..';

    # ..
}


Since you're not checking if open() or opendir() calls were successful at all, put 

use autodie;


at beginning of your script, and exceptions with description will be thrown when some of these calls fails.

Stylistic remark, my @fehbg = (); is same as just my @fehbg;

Use lexical file-handles together with three argument open (also lexical dir-handle for opendir),

open my $FEHFH, '&lt;', '/home/chummer/.fehbg';


Again stylistic remark,

for my $i (0 .. $#files)


is a more readable/simpler equivalent of,

for (my $i = 0; $i &lt;= $#files; ++$i)


Then foreach($files[$i+1]){ s/\s+/\\ /g; } is longer and less performant version of $files[$i+1] =~ s/\s+/\\ /g;