Rob, you were very helpful in showing me how the split and join work, but
since I wasn't looking to change anything in $line except to replace the
character separating the email addrs, I used what you gave me, and rebuilt
the $line. I think it's kinda ugly, though, and I'm wondering if there
is a better way. Here's what I did:
$line = 'units = [EMAIL PROTECTED] [EMAIL PROTECTED]:[EMAIL PROTECTED]';
next unless $line =~ /^units/;
(my $units, my $rest) = split (/=\s+/,$line);
my @addrs = split /[:;\s]+/, $rest;
my $tmpline = join ',', @addrs;
$line = $units . " = " . $tmpline . "\n";
This accomplishes the task, but I'm using a lot of temporary variables. Is
there a better way?
Thanks,
deb
At 00:29:16, on 07.10.03:
Cracks in my tinfoil beanie allowed Rob Dixon to seep these bits into my brain:,
> Deb wrote:
> > Rob,
> >
> > Errr, I think I see this. Seems more elegant than a strict
> > search/replace. But, I don't understand this:
> >
> > next unless $line =~ s/^units\s+=\s+//;
> >
> > Substituting the left side with nothing? I must be reading this
> > wrong.
> >
> > I do understand the split and join, though - I've used split
> > a lot, but not join. I appreciate you giving an example.
>
> Sure. Look
>
> my $line = 'units = [EMAIL PROTECTED] [EMAIL PROTECTED]:[EMAIL
> PROTECTED]';
> $line =~ s/^units\s+=\s+//;
>
> print "[$line]\n";
>
> OUTPUT
>
> [EMAIL PROTECTED] [EMAIL PROTECTED]:[EMAIL PROTECTED]
>
> (the square brackets are there only to show that there's no leading
> or trailing whitespace).
>
> This line
>
> next unless $line =~ s/^units\s+=\s+//;
>
> says
>
> - Checking whether the line matches /^units\s+=\s+/
> - If so, then remove the matched text and continue
> - Otherwise go fetch the next line
>
> HTH,
>
> Rob
>
>
>
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
--
o _ _ _
_o /\_ _ \\o (_)\__/o (_)
_< \_ _>(_) (_)/<_ \_| \ _|/' \/
(_)>(_) (_) (_) (_) (_)' _\o_
http://zapatopi.net/afdb.html
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]