-p causes perl to assume the following loop around your
script, which makes it iterate over filename arguments
somewhat like sed:

while (<>) {
... # your script goes here
} continue {
print;
}

Note that the lines are printed automatically. To
suppress printing use the -n switch. A -p overrides a
-n switch.