[25512] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 7756 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 8 18:10:23 2005

Date: Tue, 8 Feb 2005 15:10:15 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 8 Feb 2005     Volume: 10 Number: 7756

Today's topics:
        Now what am I doing wrong catcher39@www.com
    Re: Now what am I doing wrong <phaylon@dunkelheit.at>
    Re: Now what am I doing wrong <Red.Grittybrick@SpamWeary.Foo>
    Re: Now what am I doing wrong catcher39@www.com
    Re: Now what am I doing wrong catcher39@www.com
    Re: Now what am I doing wrong <tadmc@augustmail.com>
    Re: Perl - permute? <postmaster@castleamber.com>
    Re: Perl - permute? <phaylon@dunkelheit.at>
    Re: Perl - permute? <socyl@987jk.com.invalid>
    Re: Perl - permute? <postmaster@castleamber.com>
    Re: Perl - permute? <1usa@llenroc.ude.invalid>
        pod2man newbie needs help bkimelman@hotmail.com
    Re: pod2man newbie needs help <phaylon@dunkelheit.at>
    Re: pod2man newbie needs help bkimelman@hotmail.com
    Re: pod2man newbie needs help <wksmith@optonline.net>
        Q: Why does this match not work? <cooljake@gmail.com>
    Re: Q: Why does this match not work? (Anno Siegel)
    Re: Q: Why does this match not work? <noreply@gunnar.cc>
    Re: Regular expression woes <nospam-abuse@ilyaz.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 8 Feb 2005 11:22:07 -0800
From: catcher39@www.com
Subject: Now what am I doing wrong
Message-Id: <1107890527.231747.251090@o13g2000cwo.googlegroups.com>

I realize it must be obvious and won't mind if someone just wants to
point me to the correct page.

while(<EMAIL>)
{
  chomp;
  $ifile="/mnt/ops/automail/$_";
  my $size = -s $ifile;
  if($size > 1)
  {
  my $attaches = 0;
  if($_ ne "ATTACH")
  {
    open IFILE,"$ifile" or die "could not open '$ifile'  $!";
    $ofile="$_.mail";
    open OFILE,">$ofile";
    $fromaddr='PostMaster\@123.com';
    while(<IFILE>)
    {
      chomp;
      if(substr($_,0,3) eq '@@@')
      {
        chomp($basename=substr($_,3,(length $_)-4));
        $aname="/mnt/opserve/automail/ATTACH/" . $basename;
        $base="$aname.base64";
        system "/usr/bin/mimencode -o $base <$aname";
        print OFILE "\n--Message-Boundary--\n";
        print OFILE "Content-type:
Application/octet-stream;name=\"$basename\"$
        print OFILE "Content-transfer-encoding: BASE64\n\n";
        close OFILE;
        system "cat $base >> $ofile";
        open OFILE,">>$ofile";
        system "cp $base /usr/mailAttached/`date +%d`/";
        system "rm -f $base";
        system "rm -f $aname";
        $attaches=1;
      };
      if(substr($_,0,5) eq "From:")
      {
       $fromaddr=(substr($_,5));
      };
      };
      if(substr($_,0,3) ne "\@\@\@")
      {
        print OFILE $_ ."\n";
      };
    }
    close IFILE;
    system "\\rm -f $ifile";
#problem is here    <===========================================
    if($attaches=1)
      {  print OFILE "\n--Message-Boundary----\n";
         $attaches=0;
      };
    close OFILE;


The problem is that the code that is in "if($attaches=1)" is always
running.
Is my construct wrong, my decleration wrong or my test wrong?
Thanks.



------------------------------

Date: Tue, 08 Feb 2005 20:20:25 +0100
From: phaylon <phaylon@dunkelheit.at>
Subject: Re: Now what am I doing wrong
Message-Id: <pan.2005.02.08.19.20.24.306173@dunkelheit.at>

catcher39 wrote:

> The problem is that the code that is in "if($attaches=1)" is always
> running.                                             ^

Your too stingy with your = sings, spend that expression another one :)

g&scnr,phay

-- 
http://www.dunkelheit.at/

The mind is its own place, and in itself
Can make a heaven of hell, a hell of heaven.  -- Milton, »Paradise Lost«



------------------------------

Date: Tue, 8 Feb 2005 20:12:18 +0000 (UTC)
From: RedGrittyBrick <Red.Grittybrick@SpamWeary.Foo>
Subject: Re: Now what am I doing wrong
Message-Id: <cub6f1$c4k$1@sparta.btinternet.com>

catcher39@www.com wrote:
> I realize it must be obvious and won't mind if someone just wants to
> point me to the correct page.

Abigail cruelly squashed my brilliant idea but I am going to jump in 
here anyway - take the following with a large pinch of salt. At the end 
I answer your real question.

You need
  use strict;
  use warnings;


> while(<EMAIL>)

Lexical filehandles seem to be preferred nowadays.

> {
>   chomp;
>   $ifile="/mnt/ops/automail/$_";

You may need to untaint user provided input (including contents of files).

>   my $size = -s $ifile;
>   if($size > 1)
>   {
>   my $attaches = 0;
>   if($_ ne "ATTACH")
>   {
>     open IFILE,"$ifile" or die "could not open '$ifile'  $!";

Useless use of quotes?
Three way opens seem to be preferred nowadays.

>     $ofile="$_.mail";
>     open OFILE,">$ofile";

All the above comments apply here too.
I'd check the result with an "or die ..."

>     $fromaddr='PostMaster\@123.com';

Do you really need to escape the at sign here?
You would with double quotes but not with single.

>     while(<IFILE>)
>     {
>       chomp;
>       if(substr($_,0,3) eq '@@@')

I tend to write "if (/^@@@/)" but YMMV.

>       {
>         chomp($basename=substr($_,3,(length $_)-4));

If you read the perldoc for substr you may find that negative arguments 
do the right thing more simply than you realise.

>         $aname="/mnt/opserve/automail/ATTACH/" . $basename;

Double quotes are usually used for interpolating variables into strings.
  = 'foo'.$bar;
  = "foo.$bar";

>         $base="$aname.base64";

Curious mix of styles.

>         system "/usr/bin/mimencode -o $base <$aname";

I'd consider checking the outcome of this before proceeding.

>         print OFILE "\n--Message-Boundary--\n";
>         print OFILE "Content-type:
> Application/octet-stream;name=\"$basename\"$
>         print OFILE "Content-transfer-encoding: BASE64\n\n";
>         close OFILE;

I tend to do
   print "foo",
         "bar",
         "baz";
instead of
   print "foo";
   print "bar";
   print "baz";

You could also use a here-document for clarity.

>         system "cat $base >> $ofile";

Couldn't you do this when mimencoding it?

>         open OFILE,">>$ofile";
>         system "cp $base /usr/mailAttached/`date +%d`/";

Perl has lots of date functions. You could avoid some calls to external 
programs and thus simplify the overall solution.

>         system "rm -f $base";
>         system "rm -f $aname";

Perl has functions for deleting files. You seem to be ignoring errors.

>         $attaches=1;
>       };
>       if(substr($_,0,5) eq "From:")

I prefer
   if (/^From:/)

>       {
>        $fromaddr=(substr($_,5));
>       };
Or something like ...
   if (/^From:(.*)/) { $fromaddr = $1; }

>       };
>       if(substr($_,0,3) ne "\@\@\@")

You only need to escape ats because you use " instead of '
I prefer "if (/^regexp/) ... "

>       {
>         print OFILE $_ ."\n";

You always pick the type of quote mark I wouldn't use!

>       };
>     }
>     close IFILE;
>     system "\\rm -f $ifile";

See above

> #problem is here    <===========================================
>     if($attaches=1)

You seem to be confusing assignment with comparison. Consider "=" and 
"==" and "eq". Have a think about "if ($attaches)".

>       {  print OFILE "\n--Message-Boundary----\n";
>          $attaches=0;
>       };
>     close OFILE;
> 
> 
> The problem is that the code that is in "if($attaches=1)" is always
> running.
> Is my construct wrong, my decleration wrong or my test wrong?


> Thanks.
> 


------------------------------

Date: 8 Feb 2005 13:02:19 -0800
From: catcher39@www.com
Subject: Re: Now what am I doing wrong
Message-Id: <1107896257.415341.108260@f14g2000cwb.googlegroups.com>


phaylon wrote:
> catcher39 wrote:
>
> > The problem is that the code that is in "if($attaches=1)" is always
> > running.                                             ^
>
> Your too stingy with your = sings, spend that expression another one
:)
>
Thanks! I *KNEW* that it was something
"smack my forehead against the keyboard stupid" .



------------------------------

Date: 8 Feb 2005 13:02:33 -0800
From: catcher39@www.com
Subject: Re: Now what am I doing wrong
Message-Id: <1107896553.563757.72250@l41g2000cwc.googlegroups.com>


RedGrittyBrick wrote:
> catcher39@www.com wrote:
>
> >         $base="$aname.base64";
>
> Curious mix of styles.
>
Well, I am the 3rd inheritor of this program.
Thanks for your short perl lessons.
I am going to print them out and see how they can be combined with the
previous comments made on this thread ("need assistance with an
inherited script that process email") but they sure look good.

http://groups-beta.google.com/group/comp.lang.perl.misc/browse_thread/thread/1db1d936dfcddf39/1ea5af1b1a0c25c9?q=need+assistance&_done=%2Fgroup%2Fcomp.lang.perl.misc%2Fsearch%3Fgroup%3Dcomp.lang.perl.misc%26q%3Dneed+assistance%26qt_g%3D1%26searchnow%3DSearch+this+group%26&_doneTitle=Back+to+Search&&d#1ea5af1b1a0c25c9



------------------------------

Date: Tue, 8 Feb 2005 15:10:23 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Now what am I doing wrong
Message-Id: <slrnd0ialv.1h0.tadmc@magna.augustmail.com>

catcher39@www.com <catcher39@www.com> wrote:

> Subject: Now what am I doing wrong


Please put the subject of your article in the Subject of your article!


> I realize it must be obvious


So obvious that a *machine* can find the problem.

It is demeaning to be asked to do the work of a machine,
please don't do that to us.


>     if($attaches=1)


You should always enable warnings when developing Perl code!


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: 8 Feb 2005 19:09:50 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Perl - permute?
Message-Id: <Xns95F785E90206Dcastleamber@130.133.1.4>

phaylon wrote:

> John Bokma wrote:
> 
>> True, but there are still people who use Usenet without an Internet
>> connection, and hence Usenet is not a subset of Internet.
> 
> Well, okay, depends on the point of view.

No, Usenet has a definition, and per definition it (still) exists outside 
of Internet. So it's not a subset of it.

> But still, what's the problem with no real name?

Nothing :-D. I just didn't like the aol posting you did anonymously.

> Haven't found anything in the posting guidelines that
> says it's "requested".

It's not. And if it was, most people would invent names anyway (unless you 
have to show some form of ID).

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


------------------------------

Date: Tue, 08 Feb 2005 20:14:22 +0100
From: phaylon <phaylon@dunkelheit.at>
Subject: Re: Perl - permute?
Message-Id: <pan.2005.02.08.19.14.21.375271@dunkelheit.at>

John Bokma wrote:

> No, Usenet has a definition, and per definition it (still) exists outside
> of Internet. So it's not a subset of it.

Ok, if you like: It depends on how one defines 'Internet'.
 
> Nothing :-D. I just didn't like the aol posting you did anonymously.

Would you have it better if I told you my name? I haven't changed my mind
since that, and I don't think I'm going to be.
 
> It's not. And if it was, most people would invent names anyway (unless
> you have to show some form of ID).

Yeah, but I get a lot out of this group. If "it" would ask me to put my
Realname in the From:, I would do it.


p

-- 
http://www.dunkelheit.at/

The first rule of project mayhem is: you do not ask questions.
                              -- Fight Club



------------------------------

Date: Tue, 8 Feb 2005 19:55:24 +0000 (UTC)
From: kj <socyl@987jk.com.invalid>
Subject: Re: Perl - permute?
Message-Id: <cub5fc$e14$1@reader2.panix.com>

In <1107709033.0d15271ffc45f8463e1fcde7dddd2c79@bubbanews> Ej <justsurge@mailcan.com> writes:

>Hi,
>How can I take an array (a,b,c,d,e) and list ALL possible [3 LETTER] combos 
>of these letters, I want the output to look like

>abc
>acb
>aab
>aaa

Iterative or recursive, take your pick.

sub all_sequences {
  my ($alphabet, $n) = @_;
  return []   unless @$alphabet;
  return [''] unless $n;

  my @words = @$alphabet;

  for (2..$n) {
    for my $i (reverse 0..$#words) {
      my $word = $words[$i];
      splice @words, $i, 1, map "${word}$_", @$alphabet;
    }
  }

  return \@words;
}

sub all_sequences_recursive {
  my ($alphabet, $n) = @_;
  return []   unless @$alphabet;
  return [''] unless $n;
  return
    [ map { my $word = $_; map "${word}$_", @$alphabet }
      @{all_sequences_recursive($alphabet, $n-1)} ]
}

__END__

  DB<1> x all_sequences_recursive([ qw(a b c d e) ], 3);
0  ARRAY(0x23dae4)
   0  'aaa'
   1  'aab'
   2  'aac'

 ...

   122  'eec'
   123  'eed'
   124  'eee'


-- 
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.


------------------------------

Date: 8 Feb 2005 20:18:21 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Perl - permute?
Message-Id: <Xns95F79186FB3C4castleamber@130.133.1.4>

phaylon wrote:

> John Bokma wrote:
> 
>> No, Usenet has a definition, and per definition it (still) exists
>> outside of Internet. So it's not a subset of it.
> 
> Ok, if you like: It depends on how one defines 'Internet'.

Usenet can be (and is) transported over non-Internet. It has nothing to 
do how you define Internet.

You can say that a part of Internet takes part in Usenet.

>> Nothing :-D. I just didn't like the aol posting you did anonymously.
> 
> Would you have it better if I told you my name? I haven't changed my
> mind since that, and I don't think I'm going to be.

Do you think it would change my opinion? I mean: *I* think it's wrong to 
see someone as stupid because he/she calls something a permutation in 
the subject and a combination in the original message.

Also, just pointing to the *wrong* module (as was obvious from the 
examples the OP gave) at CPAN and then ending the message with "ok, it's 
not right, find it out yourself" is wrong to me.

And next trying to argue that the OP was stupid to justify a wrong 
posting.

And then some other people with a huge ego considered it funny to state 
the current status of their kill file. And "plonk" messages are for 
lamers. Often the same lamers who get their daily kick out of bashing 
"new" people on the Usenet since they are so 733+.

>> It's not. And if it was, most people would invent names anyway
>> (unless you have to show some form of ID).
> 
> Yeah, but I get a lot out of this group. If "it" would ask me to put
> my Realname in the From:, I would do it.
 
Ah, personally I consider it nicer. On the other hand, you risk people 
calling you at home :-D.

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


------------------------------

Date: Tue, 08 Feb 2005 20:56:28 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Perl - permute?
Message-Id: <Xns95F7A23597875asu1cornelledu@127.0.0.1>

John Bokma <postmaster@castleamber.com> wrote in 
news:Xns95F79186FB3C4castleamber@130.133.1.4:

> phaylon wrote:

>> Yeah, but I get a lot out of this group. If "it" would ask me to put
>> my Realname in the From:, I would do it.
>  
> Ah, personally I consider it nicer. On the other hand, you risk people 
> calling you at home.

I instinctively take people who post under their real names more seriously 
than others. There are exceptions to this but so far it's been a useful 
rule for me.

As for someone calling me at home, the closest I ever came to something 
like that happening in the last decade or so was actually here a few weeks 
ago when a certain someone expressed his desire to "reach out and touch 
me". I am going to be an optimist an assume that the reason he has not 
been back since that posting is due to the fact that AT&T is a diligent 
ISP :)

Sinan.


------------------------------

Date: 8 Feb 2005 11:04:14 -0800
From: bkimelman@hotmail.com
Subject: pod2man newbie needs help
Message-Id: <1107889453.975555.98620@g14g2000cwa.googlegroups.com>

I decided to try and document some Perl scripts of mine using POD style
documentation. However whenever I run pod2man I receive the following
error message :

pod2man: Invalid man page - 1st pod line is not NAME in x2.pl

Here is a partial listing of x2.pl (enough to show the problem).

     1  #!/usr/bin/perl -w
     2
     3  use Getopt::Std;
     4  use strict;
     5
     6  my ( %options , $status );
     7
     8  %options = ( "d" => 0 , "n" => 0 );
     9  exit 0;
    10
    11  __END__
    12  =head1 NAME
    13  A Perl script to display the requested data
    14
    15  =head1 SYNOPSIS
    16  es.pl [-dn] lookup_value
    17
    18  =head1 ABSTRACT
    19  This script will display environment variables in a
    20  highly flexible manner.

As you can see my 1st pod line is indeed a NAME value. So what is
pod2man trying to tell me ? I looked at some other Perl modules on my
system and I am using the same style as those modules, but I am not
having any luck.

Thanks in advance for any help you can give.



------------------------------

Date: Tue, 08 Feb 2005 20:02:39 +0100
From: phaylon <phaylon@dunkelheit.at>
Subject: Re: pod2man newbie needs help
Message-Id: <pan.2005.02.08.19.02.38.210735@dunkelheit.at>

bkimelman wrote:

> As you can see my 1st pod line is indeed a NAME value. So what is pod2man
> trying to tell me ? I looked at some other Perl modules on my system and I
> am using the same style as those modules, but I am not having any luck.

AFAIR are the docs recommending empty lines between POD-"blocks". A short
test here (line numbers are very unhandy for c&p) says the same.

g,phay

-- 
http://www.dunkelheit.at/
codito, ergo sum.



------------------------------

Date: 8 Feb 2005 11:16:23 -0800
From: bkimelman@hotmail.com
Subject: Re: pod2man newbie needs help
Message-Id: <1107890183.609061.117710@z14g2000cwz.googlegroups.com>


bkimelman@hotmail.com wrote:
> I decided to try and document some Perl scripts of mine using POD
style
> documentation. However whenever I run pod2man I receive the following
> error message :
>
> pod2man: Invalid man page - 1st pod line is not NAME in x2.pl
>
> Here is a partial listing of x2.pl (enough to show the problem).
>
>      1  #!/usr/bin/perl -w
>      2
>      3  use Getopt::Std;
>      4  use strict;
>      5
>      6  my ( %options , $status );
>      7
>      8  %options = ( "d" => 0 , "n" => 0 );
>      9  exit 0;
>     10
>     11  __END__
>     12  =head1 NAME
>     13  A Perl script to display the requested data
>     14
>     15  =head1 SYNOPSIS
>     16  es.pl [-dn] lookup_value
>     17
>     18  =head1 ABSTRACT
>     19  This script will display environment variables in a
>     20  highly flexible manner.
>
> As you can see my 1st pod line is indeed a NAME value. So what is
> pod2man trying to tell me ? I looked at some other Perl modules on my
> system and I am using the same style as those modules, but I am not
> having any luck.
>
> Thanks in advance for any help you can give.


A slight typo when I was cutting and pasting into my original post. I
do indeed have a blank line between the "__END__" and "=head1" lines as
stated in the manual page for perlpod



------------------------------

Date: Tue, 8 Feb 2005 17:23:53 -0500
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: pod2man newbie needs help
Message-Id: <0%aOd.839$N52.245@fe12.lga>


<bkimelman@hotmail.com> wrote in message
news:1107889453.975555.98620@g14g2000cwa.googlegroups.com...
> I decided to try and document some Perl scripts of mine using POD
style
> documentation. However whenever I run pod2man I receive the following
> error message :
>
> pod2man: Invalid man page - 1st pod line is not NAME in x2.pl
>
> Here is a partial listing of x2.pl (enough to show the problem).
>
>      1  #!/usr/bin/perl -w
>      2
>      3  use Getopt::Std;
>      4  use strict;
>      5
>      6  my ( %options , $status );
>      7
>      8  %options = ( "d" => 0 , "n" => 0 );
>      9  exit 0;
>     10
>     11  __END__
>     12  =head1 NAME
>     13  A Perl script to display the requested data
>     14
>     15  =head1 SYNOPSIS
>     16  es.pl [-dn] lookup_value
>     17
>     18  =head1 ABSTRACT
>     19  This script will display environment variables in a
>     20  highly flexible manner.
>
> As you can see my 1st pod line is indeed a NAME value. So what is
> pod2man trying to tell me ? I looked at some other Perl modules on my
> system and I am using the same style as those modules, but I am not
> having any luck.
>

The NOTES section of perldoc pod2man gives the spec for developing
manpages in POD.  Your NAME line does not conform to that spec.  I
believe that this is your problem.  I have found that POD requires
a lot of blank lines.  It has to do with the fact that blank lines
are used to separate "paragraphs" as that word is used in the spec.

I find it easier to leave a blank line before and after every POD
command than to learn (and remember) the applicable rules.
The unnecessary (if any) blank lines do not appear in the manpage.

Good luck,
Bill




------------------------------

Date: 8 Feb 2005 13:33:44 -0800
From: "jake1138" <cooljake@gmail.com>
Subject: Q: Why does this match not work?
Message-Id: <1107898424.952268.314030@z14g2000cwz.googlegroups.com>

Can anyone explain this to me?

This works:

while(<FILE>) {
  chop;
  if (/^int config_write\s*\(.*\)\s*[^;]?\s*$/i) {
    print "$_\n";
  }
  if (/^int config_read\s*\(.*\)\s*[^;]?\s*$/i) {
    print "$_\n";
  }
}

But this doesn't (only matches the first string "int_config_read"):

while(<FILE>) {
  chop;
  for my $func_def ("int config_read", "int config_write") {
    if (/^$func_def\s*\(.*\)\s*[^;]?\s*$/i) {
      print "$_\n";
    }
  }
}

If I reverse the strings...

  for my $func_def ("int config_write", "int config_read") {

 ...it matches "int config_write" and not "int config_read".

I'm really confused because it does indeed process both strings if I
use code like this:

for my $func_def ("int config_read", "int config_write") {
  print "$func_def\n";
}



------------------------------

Date: 8 Feb 2005 21:47:37 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Q: Why does this match not work?
Message-Id: <cubc1p$drb$3@mamenchi.zrz.TU-Berlin.DE>

jake1138 <cooljake@gmail.com> wrote in comp.lang.perl.misc:
> Can anyone explain this to me?

[...]
 
> But this doesn't (only matches the first string "int_config_read"):
> 
> while(<FILE>) {
>   chop;
>   for my $func_def ("int config_read", "int config_write") {
>     if (/^$func_def\s*\(.*\)\s*[^;]?\s*$/i) {
>       print "$_\n";
>     }
>   }
> }

Something else is going on.  It works as intended for me.  Check the
input data.

Anno


------------------------------

Date: Tue, 08 Feb 2005 23:21:23 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Q: Why does this match not work?
Message-Id: <36ssb6F55prppU1@individual.net>

Anno Siegel wrote:
> jake1138 wrote:
>> But this doesn't (only matches the first string "int_config_read"):
>>
>> while(<FILE>) {
>>   chop;
>>   for my $func_def ("int config_read", "int config_write") {
>>     if (/^$func_def\s*\(.*\)\s*[^;]?\s*$/i) {
>>       print "$_\n";
>>     }
>>   }
>> }
> 
> Something else is going on.  It works as intended for me.

For me too.

But why not just

     while (<FILE>) {
         print if /^int config_(?:read|write)\s*\(.*\)\s*[^;]?\s*$/i
     }

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


------------------------------

Date: Tue, 8 Feb 2005 22:42:06 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Regular expression woes
Message-Id: <cubf7u$2g9n$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Mark (News)
<news@mail.adsl4less.com>], who wrote in article <1107875179.397295.104110@c13g2000cwb.googlegroups.com>:
> The if (! some-test) { ... } has the negation as part of the if
> statement (I may have erroneously called this negation "using the
> shell", whereas it might have been more precise to say "part of the if
> statement"). What I was challenging was to achieve the same result, but
> keeping any negations inside the RE: if(some-re-test). Hope that makes
> sense. My actual requirements are to enjoy solving this challenge -
> nothing more. :-)

Keep in mind that there *is* a legitimate situation when such a
requirement is not bogus: some programs take a REx as a command-line
argument.  Given this design, you may be forced to provide some REx
aerobatics if you want squeeze more from such programs.

[If the program is not updated often, sometimes it is easier to change
the source code. ;-]

Hope this helps,
Ilya


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 7756
***************************************


home help back first fref pref prev next nref lref last post