W. Chris Shank on 29 Jul 2007 20:53:54 -0000 |
I am trying to do a simple Case statement in perl. I have a file with key:value pairs. I can parse out each key and the value via a loop, but I only need 3 keys, so I'm trying to make a Case statement where if the key equals any of 3 criteria the corresponding value is saved to a variable. Here is my script so far - but the value is never written to the variable. What am i doing wrong? Thanks perl wizards for your help. #!/usr/bin/perl while(<>) { chomp; my ($key,$value) = split(/:/); use Switch; switch ($key) { case "displayName" { my $displayName = $value } case "sn" { my $sn = $value } case "givenName" { my $givenName = $value } else { } } } print "displayName $displayName \n"; print "sn $sn \n"; print "giveName $givenName \n"; -- W. Chris Shank ACE Technology Group, LLC www.myremoteITdept.com (610) 640-4223 -------------------------------- Security Note: To protect against computer viruses, e-mail programs may prevent sending or receiving certain types of file attachments. Check your e-mail security settings to determine how attachments are handled. ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
|
|