Conf.pm at line 76

Ivan Kohler ivan at sisd.com
Tue May 11 03:16:46 PDT 1999


I've patched Conf.pm in CVS, and attached the patch.  It won't solve your
problem, but it will at least give us a more informative error message. 

On Wed, Apr 28, 1999 at 05:23:46PM -0700, Joel Griffiths wrote:
> 
>  sub config {
>   my($self,$file)=@_;
>   my($dir)=$self->dir;
>   my $fh = new IO::File "<$dir/$file" or return;
>   if ( wantarray ) {
>     map {
>       /^(.*)$/ or die "Illegal line in $fh $dir/$file:\n$_\n";
                                         ^^^
Incidentally, your transcription of this line is wrong.  There is no `$fh',

>       $1;
>     } <$fh>;
>   } else {
>     <$fh> =~ /^(.*)$/ or die "Illegal line in $dir/$file:\n$_\n";
>     $1;
>   }
> }  

I think you're at the right section of code but, yes, the rest is kinda
off base.  If you're insterested in learning more, check umm the perlre
manpage, the perldata manpage (esp. Context section)... 

patch appended

> It appears that the whole file is being read in as a single line with the
> /^(.*)$/ command. I tried to change the /^(.*)$/ to /^(.*)$/m and it obviously
> didn't work but then the the extra lines weren't even seen. I'm not much at
> Perl so the problem could be something else. Could this be where the problem
> is. I am running Perl 5.005_2 so I'm a thinking something changed in Perl that
> broke this.
> 
> This is out of the manual.....
> 
>       By default, the "^" character is guaranteed to match at
>        only the beginning of the string, the "$" character at
>        only the end (or before the newline at the end) and Perl
>        does certain optimizations with the assumption that the
>        string contains only one line.  Embedded newlines will not
>        be matched by "^" or "$".  You may, however, wish to treat
>        a string as a multi-line buffer, such that the "^" will
>        match after any newline within the string, and "$" will
>        match before any newline.  At the cost of a little more
>        overhead, you can do this by using the /m modifier on the
>        pattern match operator.  (Older programs did this by
>        setting $*, but this practice is now deprecated.)
> 
> If I am entirely off base, please be kind with the flaming. I have too much
> email to sort through already.
> 
> -- Joel                                                
>            

-- 
Ivan Kohler <ivan at sisd.com> - finger for PGP key - <moc.dsis at navi> Relhok Navi
Open-source billing and administration for ISPs - http://www.sisd.com/freeside
20 4,16 * * * saytime # please don't be surprised if you find me dreaming too


patch follows:

===================================================================
RCS file: /home/cvs/cvsroot/freeside/site_perl/Conf.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- freeside/site_perl/Conf.pm  1999/03/29 01:29:33     1.3
+++ freeside/site_perl/Conf.pm  1999/05/11 10:09:13     1.4
@@ -73,11 +73,13 @@
   my $fh = new IO::File "<$dir/$file" or return;
   if ( wantarray ) {
     map {
-      /^(.*)$/ or die "Illegal line in $dir/$file:\n$_\n";
+      /^(.*)$/
+        or die "Illegal line (array context) in $dir/$file:\n$_\n";
       $1;
     } <$fh>;
   } else {
-    <$fh> =~ /^(.*)$/ or die "Illegal line in $dir/$file:\n$_\n";
+    <$fh> =~ /^(.*)$/
+      or die "Illegal line (scalar context) in $dir/$file:\n$_\n";
     $1;
   }
 }
@@ -112,6 +114,9 @@
 sub exists forgot to fetch $dir ivan at sisd.com 98-sep-27
 
 $Log: Conf.pm,v $
+Revision 1.4  1999/05/11 10:09:13  ivan
+try to diagnose strange multiple-line problem
+
 Revision 1.3  1999/03/29 01:29:33  ivan
 die unless the configuration directory exists
 



More information about the freeside-users mailing list