No doubt I am going to kick myself in the head when I get the answer to this questions, but here goes anyway.. ;-) I have a set of strings that I am reading from a file. The data looks like this:
SERVER1/OU=00/OU=LOCATION/O=COMPANY SERVER2/OU=00/OU=LOCATION/O=COMPANY SERVERXYZ6/OU=00/OU=LOCATION/O=COMPANY SERVERFOOBAR/OU=01/OU=LOCATION/O=COMPANY
The name of the server in each string comes before the first "/" character, and I need to extract that into another string variable. The server name is variable in length. I don't care about what comes after that first "/" character in the line. I was trying to use the split command, but I have been having a lot of problem escaping the "/"'s used to specify the character to use for the split. In addition, I get errors that appear to make no sense when I use the following, where $serverID is the string that I have read in from the file:
$cnID = split("/", $serverID); print $cnID . "\n";
Can someone give me a pointer (no pun intended) on where I am going wrong here? This seems pretty straightforward, but obviously I am doing something incorrectly. Thanks for any ideas...

Originally posted as a Categorized Question.


In reply to Splitting a string... Duh? by KenShackelford

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.