mardi 23 janvier 2018

how perl handle pattern with different quotation

As https://perldoc.perl.org/perlrun.html indicates,

-F option specifies the pattern to split on for -a. The pattern may be surrounded by // , "" , or '' , otherwise it will be put in single quotes. You can't use literal whitespace or NUL characters in the pattern.

I tried below commands on a text, but the result is totally the same.

So what's the difference of these pattern quotation in below example?

$ perl -aF"\|" -lne 'print $F[0]' input
Time
2018-01-11 00:00:00
2018-01-11 00:15:00


$ perl -aF'|' -lne 'print $F[0]' input
T
2
2


$ perl -aF/|/ -lne 'print $F[0]' input
bash: /: Is a directory

Aucun commentaire:

Enregistrer un commentaire