For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > October 2006 > Re: Fw: Reg:need to find the particular pattern in a line and assign









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Fw: Reg:need to find the particular pattern in a line and assign
John W. Krahn

2006-10-30, 7:03 pm

pradeep reddy wrote:
> Hello all,


Hello,

> Iam new member to this group and also beginner to PERL.
> Here is my question,plz let me know your inpus:
> I have a PERL script which gives error report at the end.
> Here is the output.
>
> cleartool: Error: Unable to create label "Pradeep" on "/vob/rootinclude/paer.c" version "/main/3".
> cleartool: Error: Unable to create label "Pradeep" on "/vob/rootinclude/pcme.h" version "/main/2".
>
> I need to grab the two elements between the two quotes.
> Iam very much beginer to the PERL script.
> Iam trying this bit of code, not sure how to go on.
>
> foreach (@problemLines) {
> push $outLine,@problemLines; /"here Iam trying to get the each line into outLine"/


The first argument to push() must be an array so that will not work.


> if ($outLine =~ / cleartool: Error: Unable to create label /) { /"here Iam trying to match the pattern"/
> my @values = split(' " ',$outline); /"Here Iam splitting the outline"/
> my $pathName = @values[3];
> my $Version = @values[5];
> cleartool mklabel $RECURSE $REPLACE -version $Version $labelName $pathName; /"This is the comand Iam using"/
> print "$_\n";
>
> }


You probably want something like this:

my ( $labelName, $pathName, $Version ) = $outline =~ /"([^"]+)"/g;



John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com