Whitehot
Whitehot

Reputation: 497

Perl: "Modification of a read-only value" for one line script that used to work

I am using this little line which is quite useful for parsing some data in HTML format, specifically for converting the HTML "special characters" into "real characters":

perl -MHTML::Entities -pe 'decode_entities(-s);' <tmp1 >tmp2

It used to work just fine, however now it's telling me

Modification of a read-only value attempted at -e line 1, <> line 1.

Can you help me find out why? Am I missing a library?

Upvotes: 1

Views: 64

Answers (1)

choroba
choroba

Reputation: 241968

Are you sure you had -s there? Try replacing it with $_:

decode_entities($_)

-s returns a file size, see -x

-s File has nonzero size (returns size in bytes).

While $_ contains the line read from the input.

Upvotes: 3

Related Questions