KenShackelford has asked for the wisdom of the Perl Monks concerning the following question:
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: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
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...$cnID = split("/", $serverID); print $cnID . "\n";
Originally posted as a Categorized Question.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Splitting a string... Duh?
by Preceptor (Deacon) on Sep 16, 2002 at 16:17 UTC | |
by Preceptor (Deacon) on Sep 16, 2002 at 16:24 UTC | |
|
Re: Splitting a string... Duh?
by virtualsue (Vicar) on Sep 20, 2002 at 20:32 UTC | |
|
Re: Splitting a string... Duh?
by PodMaster (Abbot) on Sep 16, 2002 at 16:32 UTC | |
|
Re: Splitting a string... Duh?
by Django (Pilgrim) on Sep 16, 2002 at 17:17 UTC | |
|
Re: Splitting a string... Duh?
by barrd (Canon) on Sep 16, 2002 at 16:16 UTC | |
|
Re: Splitting a string... Duh?
by virtualsue (Vicar) on Sep 20, 2002 at 20:01 UTC | |
|
Re: Splitting a string... Duh?
by SmokeyB (Scribe) on Sep 27, 2002 at 16:03 UTC | |
|
Re: Splitting a string... Duh?
by KenShackelford (Initiate) on Sep 18, 2002 at 17:40 UTC | |
|
Re: Splitting a string... Duh?
by logan (Curate) on Nov 12, 2002 at 22:25 UTC |