Q:

tail -f file1 | perl -pe '$_' > file2 does not output anything to file2

This command does not output anything to file2:
#!/bin/bash
echo content > file1
tail -f file1 | perl -pe '$_' > file2

Whereas these commands work ok:
tail -f file1 > file2
tail -f file1 | perl -pe '$_'
tail file1 | perl -pe '$_' > file2
tail -f /tmp/file1 | while read line; do echo $line | perl -pe '$_' > /tmp/file2 ; done

Anyone knows what's happening?

A:

perl has detected that stdout is not a terminal. For efficiency, it waits until it has a full block of data to write. Since you don't provide more data, it won't write anything until tail exits and the program can finish.
You can enable autoflushing with $|++:
tail -f file1 | perl -pe '$|++; $_' > file2

