in reply to Interpolating a string into list context.

This probably isn't a good idea. It does work though.
#!/usr/bin/perl use warnings; use strict; my $str = q("string with a comma,","and some spaces", "three"); my @array; eval <<"EVILEVAL"; \@array = ( $str ); EVILEVAL print "ELT: $_\n" for @array;
Now I'll go away and right 100 times, "I will not execute my data. I will not execute my data. I will not...".

More seriously, the CSV approaches people have mentioned are probably the way to go.

Replies are listed 'Best First'.
Re^2: Interpolating a string into list context.
by hangon (Deacon) on Nov 14, 2007 at 03:53 UTC

    Actually, I did do this as a temporary fix so I could get on with the rest of the project. Here's my penance:

    1. I will not execute my data. 2. I will not execute my data. ... ... ... 100. I will not execute my data.
      Awesome. I hope you one day repent, but we all know there is nothing so permanent as a temporary fix.

      More seriously, make sure your aren't getting your strings from a place where someone might be able to inject any code.

      As I'm sure you know, this is like SQL injection but only more fun since you have a whole perl interpreter to play with.