"John W. Krahn" wrote:

> "R. Joseph Newton" wrote:
> >
> > Deb wrote:
> > >
> > > I have an array in which each element is a line commandline data.  It looks
> > > something like this -
> > >...
> > > post1: -r [EMAIL PROTECTED] -x cat-100 -h post1
> > > post2: -x tel -h post2
> > > post3: -h post3 -x hifi
> > >
> ...                      ^^^^
> What is the comma doing there?
>
> ..                                          ^
> Missing semicolon.
>

Hi John,

Thanks for catching that.  I guess i shold run my psuedocode through the command line 
instead of composing it in the mailer.  Cleaned it up a little, ut it in a test stub, 
and now it achieves the functionality described:

#!/usr/bin/perl -w

use strict;
use warnings;

my $string = "post1: -r [EMAIL PROTECTED] -x cat-100 -h post1";
my %relationships;

sub getRelationship($$);
getRelationship($string, \%relationships);


sub getRelationship ($$) {
  my ($commandline, $relationships) = @_;
  print "$commandline\n";
  my @commands = split /\s+-/, $commandline;
  my $key = shift(@commands);
  foreach (@commands) {
    if (s/^x\s+//) {$$relationships{$key} = $_;}
  }
}
foreach my $key (keys %relationships) {
   print "$key:=$relationships{$key}\n";
}

Joseph



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to