"R. Joseph Newton" wrote:
>
> Deb wrote:
> >
> > I have an array in which each element is a line commandline data. It looks
> > something like this -
> >
> > @Array contains lines:
> >
> > post1: -r [EMAIL PROTECTED] -x cat-100 -h post1
> > post2: -x tel -h post2
> > post3: -h post3 -x hifi
> >
> > What I really need to do is build a relationship between the first field
> > (which is the same as the argument to -h) and the argument to -x. The -x flag
> > can be dropped, as they're not needed.
>
> Is this something like what you are looking for?
>
> sub getRelationship($, $) {
^^^^
What is the comma doing there?
> my ($commandline, $relationships) = @_
^
Missing semicolon.
> my @commands = split /\s -/, $commandline = @_;
^^^^^^
Why are you assigning the array size to $commandline?
> my $key = shift(@commands);
> foreach (@commands) {
> if (/^x/) {
> s/^x\s+//;
There is no need to do a match AND a substitution.
if ( s/^x\s+// ) {
> $$relationships{$key} = $commandline;
> }
> }
> }
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]