--- Craig Sharp <[EMAIL PROTECTED]> wrote: > Hi all, > > I have a file with lines that are in the following > format: > > 20011219 074645 b03 3524 switch 10.3.xxx.xxx 3 > > I need to do a substitution so that the line appears > as: > > 20011219 074645 b03-3524-switch 10.3.xxx.xxx 3 <snip>
Another possible solution: [tested on win98, build 521] [please mind the line wrap.] # ----- use strict; my $old1 = '20011219 074645 b03 3524 switch 10.3.xxx.xxx 3'; my $old2 = '20011206 175228 b50 suite-Y switch-A 10.50.xxx.xxx 1'; print "old1: $old1\n"; my $new1 = &dashes( "$old1" ); print "new1: $new1\n\n"; print "old2: $old2\n"; my $new2 = &dashes( "$old2" ); print "new2: $new2\n\n"; sub dashes { my ($s) = @_; my @t = split ' ', $s; my $u = $t[0] . " " . $t[1] . " " . $t[2] . "-" . $t[3] . "-" . $t[4] . " " . $t[5] . " " . $t[6]; return $u; } # ----- --- Jim __________________________________________________ Do You Yahoo!? Send FREE video emails in Yahoo! Mail! http://promo.yahoo.com/videomail/ _______________________________________________ Perl-Unix-Users mailing list. To unsubscribe go to http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users