Hey monks, there are a couple of minor things I need a bit of help on if u can...

I know how to find a word on a line...

if ($line =~ /\b$word\b/){}

But how do I find out if a word is not on a line, I thought maybe prefix the statement with a '!'? Theres clearly something obvious im missing here!

The second thing i would like to know is how do I remove the first char from a string in an array element?
I would have something like "10000001", but i want the first '1' to no longer exist so it will read "0000001". It must be the first char as sometimes there maybe letters there or special chars (e.g. -, +, $) that i dont want. I was thinking of using split which will work but i thought there must be some regular expression that is much more efficient (As u can guess, regular expressions are not my strong point!).

The third thing is i want to remove all chars up to the last ',' in an array element. For example, if I have:

"","","hello, my name is Bob, my cell number is, 1234567890",""

I want to remove ", 1234567890" in array element 2. It wont always be a number, this is just an example. Again i guess theres some clever bit of regex that solves this problem very quickly!

These are probably easy to solve for u perl guru's out there, but for us lowly apprentices its not so easy! I must get to grips with these god damn regex, can anyone recommend a decent book that can explain this sorta stuff for people as mentally challenged as myself?! (No books for dummies please, i dont need my mental capacity challenged by patronising yellow books with kiddie pics plastered over it! ;-))

Thanks peeps, Chad :-)


In reply to Not find a word / remove first char in string / remove last value in list by Anonymous Monk

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, details, 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, summary, 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.