Srting matching again

2001-06-26 Thread Yvonne Murphy

Hi all,
The following problem has been causing me alot of hassle and I'd really
appreciate some help with it.

I have the following piece of code which matches perfectly  for a string
between the single qoute and the semi-colon:-

use strict;

#this part is to remove the functions from the qoutes that
#were added when the C::Scan was done.

my($mymatch,$line,@arr,$arr,$i);

open (FILE, "functions2.log") or die $!;
open (OUTFILE, ">thosecoolfuncs.log");

while ($mymatch =  ) {

 if ($mymatch =~  m/\'(.+)\;/gis) { #matches anything between the single
qoute and semi-colon and places it in the '$1' variable

 print OUTFILE $1,  "\n\n";

  }
  }
close (OUTFILE);


But the problem occurs when I add this into a bigger code segment, it
just goes crazy! And seems to match te complete opposite.

And ideas?

YM








Re: removing white space

2001-06-27 Thread Yvonne Murphy

Has anyone used the whitespace module. I downloaded it from CPAN but I
couldn't get it to work for me at all.
YM




Re: Srting matching again

2001-06-27 Thread Yvonne Murphy

Hasanuddin Tamir wrote:

> On Tue, 26 Jun 2001, Yvonne Murphy <[EMAIL PROTECTED]> wrote,
>
> 
>
> >  if ($mymatch =~  m/\'(.+)\;/gis) { #matches anything between the single
>  ^^
> 
> >
> >
> > But the problem occurs when I add this into a bigger code segment, it
> > just goes crazy! And seems to match te complete opposite.
> >
> > And ideas?
>
> You seem to be bitten by the greedy match.  By default, the quantifiers
> (such as + and *) will match as many as possible.  You need the ? to
> suppress the greed behaviour.  This ? is different form the ? used to
> optional unit.
>
> $_ = "'first; second;";
> print $1, "\n" if /'(.+);/;   # first; second
> print $1, "\n" if /'(.+?);/;  # first
>
> Btw, /gis seems redundant to me.  So do the backslases.
>
> hth;
>
> __END__
> --
> s::a::n->http(www.trabas.com)

The data in the functions2.log file takes the following format:

'fdecls' => ARRAY(0x80e53c0)
   0  'int fibonacci(int degree);'
   1  'int towerOfHanoiMoves(int numOfDisks);'
   2  'void xyzzy(char* easterEgg);'
   3  'char* interesting();'
   4  'extern void  system_alarm_run(int *alarm);'
   5  'extern void  system_alarm_pause(int *alarm);'
   6  'extern int *system_timer_new( unsigned long tag );'
   7  'extern int *system_timer_callback_new( void (*callback_function)
  (unsigned long tag), unsigned long tag );'
   8  'int system_timer_start( int * timer, long time );'
   9  'longsystem_timer_pause( int * timer );'
   10  'int system_timer_stop( int * timer );'
   11  'int system_timer_del( int * timer );'

And I need to remove the actual function declaration and assign each of
the words to variables, such as, $return_type, $function_name, etc.

Is that any clearer?

Thanks,
YM




Regex......some help quickly!!!!

2001-07-13 Thread Yvonne Murphy

Hi All,
It's Friday evening and my brain is already beginning to close down for
the weekend although I haven't yet given it
permission to do so! I need to get this regex problem I have sorted
soon, but my brain refuses to co-operate with me.

I need to match the following type of #include statement found in a C
header file:


#include " test/bar.h "
#include " other/foo.h "

I need to be able to work on the actual header files so I need to be
able to store
the directory pathnames in a varible.
Any idea/help/suggestions would be so gratefully appreciated
Thanks in advance
Mich



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




Changing to new directory.

2001-07-25 Thread Yvonne Murphy

Hi all,
Thanks for all your help with previous questions I've had. What I need
to figure out now is how I can strip the actual directory from the
following pathname that I have stored in a variable :

(Just one sample of what I have but there will be different variations
of the $pathname below)

$pathname = /home/username/folders/test/bar.h

So what I really need to be able to do is remove the filename from the
end of the path and once I have the new path I want to be able  to
change to that directory.

So I want to change to say '/home/username/folders/test'

I don't have any idea how to do this so any help would be grateful.

Thanx,
YM



Another regular expression question?

2001-04-20 Thread Yvonne Murphy

I am also very new to Perl! I need to figure out how I could skip a
block of comments in a C header file. For example, if I have something
like the following:

/* This is my block of comments.blah
blah.and
lots more comments here
and then even more here! with my end of comments
indentifier on the next line!.

*/

And then the actual code down further needs to be processed. Any help
would mean alot to a beginner like me.
Thanks
YM