When you say
Code:
print m!(https?://[^/]+)!
print can take a list of arguments, so "m!(https?://[^/]+)" is called in an array context.
So "m!(https?://[^/]+)" returns an array whose elements are all the parenthetical groups with matches. Since your regexp has only one parenthetical group, it returns an array with only one element.
print then concatenates all the elements in the array.
In the second command,
Code:
print m!(https?://[^/]+)!."\n"
"m!(https?://[^/]+)!" is concatenated with the string "\n". Only scalars can be concatenated with strings. So "m!(https?://[^/]+)!" is now being called in a scalar context. In a scalar context the match operator returns true (1) if a match has been found, and returns false (0) otherwise.
You could fix the second command by using a comma (to make a list) instead of a period (concatentation operator):
Code:
cat LOGFILE | perl -ne 'print m!(https?://[^/]+)!,"\n"'
Bookmarks