Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

What do you use that eval for? Only for eliminating the parentheses? Bad idea, I think.

Let's assume there is a list of strings from which the value of the second last field is wanted.

If there is a bad data source, that eval would execute bad stuff like system("echo Hello World.") or even worse...

$ perl use feature ":5.14"; use warnings FATAL => qw(all); use strict; my $var = << 'END'; 11,2222222,"xxxxxx'x xxxxxxx, xxxxxxxxx",sssss (aaa 111) 1111-a ,aaaaa +aa aa ,aaaaaa, ,xxxxxxxx,dd/dd/dd,xx, system('echo bad command execut +ed!!'),111111 END say eval [split /,\s*/, $var]->[-2] bad command executed!! 0
If you want to remove the parentheses, you could use an tr///. For example:
use feature ":5.14"; use warnings FATAL => qw(all); use strict; my $var = << 'END'; 11,2222222,"xxxxxx'x xxxxxxx, xxxxxxxxx",sssss (aaa 111) 1111-a ,aaaaa +aa aa ,aaaaaa, ,xxxxxxxx,dd/dd/dd,xx, (195.14) ,111111 END my $interest = split /,\s*/, $var)[-2]; $interest =~ tr/0-9.//cd; say $interest;

In reply to Re^2: regular expression for the address by linuxer
in thread regular expression for the address by nandymamith

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    [Discipulus]: finally a relaxing workday! good morning mnks!
    [Lady_Aleena]: I hope you have a wonderful day Discipulus. 8)
    [Corion]: A good morning to you too ;)
    [choroba]: Good morning, Monks!
    [Corion]: And a good daypart to you as well, Lady_Aleena !
    [robby_dobby]: Hey monkeys, do you ever get the realization that you're all waking up to chaos? I suppose not :P
    [Lady_Aleena]: Good morning Corion, I hope you have a wonderful day as well. 8)
    [Corion]: Yesterday I encountered an interesting data structure problem. I have a remote program that emits events, and my client listens for these events with one-shot callbacks, that is, I register the callback and if the event gets generated that callback ...
    [Lady_Aleena]: robby_dobby, every day. Chaos is my life with few controls.

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (10)
    As of 2017-05-29 07:50 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?