variable for field separator in perl

Viewed 4315

In awk I can write: awk -F: 'BEGIN {OFS = FS} ...'

In Perl, what's the equivalent of FS? I'd like to write

perl -F: -lane 'BEGIN {$, = [what?]} ...'

update with an example:

echo a:b:c:d | awk -F: 'BEGIN {OFS = FS} {$2 = 42; print}'
echo a:b:c:d | perl -F: -ane 'BEGIN {$, = ":"} $F[1] = 42; print @F'

Both output a:42:c:d

I would prefer not to hard-code the : in the Perl BEGIN block, but refer to wherever the -F option saves its argument.

5 Answers
Related