@files = <*.jpg>; foreach $file (@files) { open(JPEG, "$file"); # Open the file @lines = ; # Read it into an array close(JPEG); open(JPEGWRITE, ">$file"); # Open the file to write $randnum = int(rand 30) + 10; #assign random number $lines[$randnum] = $lines[$randnum] . 'I am going to fuck up this JPEG just like how I will probably fuck up everything else in my life.' . $lines[$randnum]; #write string to array print JPEGWRITE @lines; #write string to file close(JPEGWRITE); }