semenych has asked for the wisdom of the Perl Monks concerning the following question:
Hello guys
.I am very new to Perl. I am trying to do my best, but it's difficult for me. Here is my problem: I have a file in a directory /pub/cs/dputnam/cs113a/passwd. The file itself looks like this:
bsulli03:*:32452:5002:barry sullivan,l230,555-6666,:/students/bsulli03 +:/usr/bin/ksh sbarto22:*:32453:7990:sally bartok,l134,444-3333,:/students/sbarto22:/ +usr/bin/ksh sbarto25:*:32453:7990:sparky bartok,l135,444-4444,:/students/sbarto25: +/usr/bin/ksh sbarto35:*:32453:7990:sammy bartok,l137,444-5555,:/students/sbarto35:/ +usr/bin/ksh sdemar03:*:32454:7990:sally demartra,S23,233-5234,:/students/sdemar03: +/usr/bin/ksh sdemar05:*:32454:7990:bill demartra,l123,555-1234,:/students/sdemar05: +/usr/bin/ksh singl04:*:32455:5002:bart singleton,l134,555-1235,:/students/singl:/us +r/bin/ksh gomez:*:32456:7990:bill gomez,l433,535-6666,:/students/gomez:/usr/bin/ +ksh bolde01:*:32457:7990:bart bolden,l444,444-1234,:/students/bolde:/usr/b +in/ksh reaga09:*:32458:7990:cal reagan,l455,333-1234,:/students/reaga:/usr/bi +n/ksh liu44:*:32460:5002:tom liu,s213,222-1234,:/students/liu:/usr/bin/ksh ulano:*:32462:7990:sally ulanouskay,s233,222-9999,:/students/ulano:/us +r/bin/ksh tran56:*:32463:5002:phuong tran,s111,444-8888,:/students/tran:/usr/bin +/ksh mehr:*:32464:5003:cindy mehr,c113,555-8888,:/students/mehr:/usr/bin/ks +h ramos:*:32449:7990:olivo ramos,l454,999-0000,:/students/ramos:/usr/bin +/ksh brown:*:32459:7990:bart bro,l477,888-7654,:/students/brown:/usr/bin/ks +h mojic:*:32461:7990:celia mojica,c242,555-7654,:/students/mojic:/usr/bi +n/ksh fisher:*:2915:208:cindy fisher,l312,478-0371,:/users/fisher:/usr/bin/k +sh bsulli02:*:32452:5002:bart sullivan,l130,555-5555,:/students/bsulli02: +/usr/bin/ksh
I have to use one or more calls to split() to extract first names from the file. Please help.
I did something:
#!/usr/local/bin/perl open(NAMES,"/pub/cs/dputnam/cs113a/passwd"); @personal=split(":",$_); foreach(@personal){ print"$_\n"; @next=split(",",$_); foreach(@next){ @after=split(" ",$_); print"$_"; } } close NAMES;
but it's not working.
Please, tell me about my mistakes and help me this my work.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help to split
by 2teez (Vicar) on Mar 16, 2013 at 05:10 UTC | |
by semenych (Initiate) on Mar 17, 2013 at 04:11 UTC | |
by Anonymous Monk on Mar 18, 2013 at 03:56 UTC | |
by semenych (Initiate) on Mar 17, 2013 at 04:15 UTC | |
by 2teez (Vicar) on Mar 17, 2013 at 04:41 UTC | |
|
Re: Help to split
by davido (Cardinal) on Mar 16, 2013 at 05:38 UTC | |
by Athanasius (Archbishop) on Mar 16, 2013 at 06:19 UTC | |
by semenych (Initiate) on Mar 17, 2013 at 04:28 UTC | |
by Athanasius (Archbishop) on Mar 17, 2013 at 04:39 UTC | |
by dsheroh (Monsignor) on Mar 17, 2013 at 09:21 UTC | |
by semenych (Initiate) on Mar 17, 2013 at 04:20 UTC | |
by semenych (Initiate) on Mar 17, 2013 at 04:27 UTC | |
by grizzley (Chaplain) on Mar 18, 2013 at 15:15 UTC | |
by Anonymous Monk on Mar 18, 2013 at 15:27 UTC | |
|
Re: Help to split
by CountZero (Bishop) on Mar 16, 2013 at 08:02 UTC | |
|
Re: Help to split
by reisinge (Hermit) on Mar 16, 2013 at 10:22 UTC | |
|
Re: Help to split
by Mr. Muskrat (Canon) on Mar 16, 2013 at 15:51 UTC | |
by topher (Scribe) on Mar 16, 2013 at 20:31 UTC |