[31175] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2420 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 15 16:09:58 2009

Date: Fri, 15 May 2009 13:09:19 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 15 May 2009     Volume: 11 Number: 2420

Today's topics:
    Re: comma operator <frank@example.invalid>
        DBI and fork <shurikgefter@gmail.com>
    Re: DBI and fork <glex_no-spam@qwest-spam-no.invalid>
    Re: Define alarm in threads <rvtol+usenet@xs4all.nl>
        Help with rename function <mparker@ygptech.com>
    Re: How to replace c:\Program Files with Program Files  <NoSpamPleaseButThisIsValid3@gmx.net>
    Re: IO::Socket::INET on OSX or TCP stack problem <derykus@gmail.com>
    Re: IO::Socket::INET on OSX or TCP stack problem <stuart@otenet.gr>
    Re: IO::Socket::INET on OSX or TCP stack problem <uri@PerlOnCall.com>
    Re: IO::Socket::INET on OSX or TCP stack problem <stuart@otenet.gr>
        My error log is growing dangerously large... <nigel@bouteyres.com>
    Re: My error log is growing dangerously large... <mail@bananas-playground.net>
    Re: My error log is growing dangerously large... <glennj@ncf.ca>
    Re: My error log is growing dangerously large... <jurgenex@hotmail.com>
    Re: My error log is growing dangerously large... <noreply@gunnar.cc>
    Re: My error log is growing dangerously large... <nigel@bouteyres.com>
    Re: My error log is growing dangerously large... <jurgenex@hotmail.com>
    Re: My error log is growing dangerously large... <tadmc@seesig.invalid>
    Re: My error log is growing dangerously large... <jurgenex@hotmail.com>
    Re: My error log is growing dangerously large... <rvtol+usenet@xs4all.nl>
    Re: My error log is growing dangerously large... <jurgenex@hotmail.com>
    Re: My error log is growing dangerously large... <rvtol+usenet@xs4all.nl>
        perl 5 grammar <mikesamuel@gmail.com>
    Re: perl 5 grammar <uri@PerlOnCall.com>
    Re: perl 5 grammar <jurgenex@hotmail.com>
    Re: perl 5 grammar <uri@PerlOnCall.com>
    Re: perl 5 grammar <jurgenex@hotmail.com>
    Re: perl 5 grammar <uri@PerlOnCall.com>
    Re: problems with writing to an output file <jurgenex@hotmail.com>
    Re: problems with writing to an output file <tadmc@seesig.invalid>
    Re: s/(The N)e(urdsburg Affair)/$1$2/ looks dumb <tzz@lifelogs.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 15 May 2009 13:42:33 -0700
From: Franken Sense <frank@example.invalid>
Subject: Re: comma operator
Message-Id: <n9xz6jtv6q9l$.abdg4l179oq6$.dlg@40tude.net>

In Dread Ink, the Grave Hand of Uri Guttman Did Inscribe:

> and finally WTF is franken sense asking dumb sidebar questions and
> getting answers. he needs to focus on learning perl and not obscure side
> issues like comma ops and lvalues (i bet he doesn't even know what the term
> lvalue means)

Fuck off, Uri.  I'll bet you're an asshole in every time zone.
-- 
Frank

When you encounter seemingly good advice that contradicts other seemingly
good advice, ignore them both.
~~ Al Franken,


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

Date: Fri, 15 May 2009 12:48:58 -0700 (PDT)
From: "shurikgefter@gmail.com" <shurikgefter@gmail.com>
Subject: DBI and fork
Message-Id: <cf0c864d-c6bd-4de1-a598-e6003860135b@m24g2000vbp.googlegroups.com>

I create a DBI connection and after that run fork() command

In the child process I close the DBI connection.

Does it affected on parent process?


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

Date: Fri, 15 May 2009 14:53:14 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: DBI and fork
Message-Id: <4a0dbd51$0$1332$815e3792@news.qwest.net>

shurikgefter@gmail.com wrote:
> I create a DBI connection and after that run fork() command
> 
> In the child process I close the DBI connection.
> 
> Does it affected on parent process?

What happened whey you tried it?

You should be able to answer that by actually taking the time
to run your code.


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

Date: Fri, 15 May 2009 21:00:10 +0200
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: Define alarm in threads
Message-Id: <4a0dbbba$0$201$e4fe514c@news.xs4all.nl>

Sébastien Cottalorda wrote:

> eval {
>     my $thr = threads->new(\&run_cmd, params);
> };
> if ($@){
>     print "$@\n";
> }

You are not using $thr.

Below an alternative that uses the return value of eval
(in stead of relying on the global $@)

   eval {
       threads->new(\&run_cmd, @params);
       1;  # success
   }
   or do {
       my $err = $@ || "unknown";
       print "$err\n";
   };

-- 
Ruud


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

Date: Fri, 15 May 2009 12:56:58 -0700 (PDT)
From: "mparker@ygptech.com" <mparker@ygptech.com>
Subject: Help with rename function
Message-Id: <681019bf-9987-41a2-8a0c-88e8567f9119@s16g2000vbp.googlegroups.com>

Hi all,

I have a perl script that ftp's to a server and downloads a file
everyday.  The file name is currently called ag051509.txt(051509 is
the date and changes daily).  I need to rename that file to agents.txt
using a script.  Since the name changes everyday I need to do
something that is equivalent to ag*.txt in unix.  Is there something I
can write that is close to -

rename(ag*.txt, agents.txt)

Any help would be greatly appreciated.  Thanks in advance!


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

Date: Fri, 15 May 2009 16:23:37 +0200
From: Wolf Behrenhoff <NoSpamPleaseButThisIsValid3@gmx.net>
Subject: Re: How to replace c:\Program Files with Program Files (x86) in all scripts?
Message-Id: <4a0d7aea$0$30231$9b4e6d93@newsspool1.arcor-online.net>

Ben Morrow schrieb:
> For reference, the correct way to get the path of the Program Files
> directory is to call Win32::GetFolderPath with CSIDL_PROGRAM_FILES. To
> get the path of the x86 Program Files directory on 64bit windows, you
> need
>     
>     use constant CSIDL_PROGRAM_FILESX86 => 0x002a;
> 
> since Win32 doesn't currently supply this constant.

Right. And in case some old programs use the hard coded string, one
could create a symlink:

mklink /d linkdirectory targetdirectory

This is what Vista also does with old XP folders, for example
"C:\Documents and Settings" is a now symlink to "C:\Users".

- Wolf


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

Date: Fri, 15 May 2009 11:26:00 -0700 (PDT)
From: CDeRykus <derykus@gmail.com>
Subject: Re: IO::Socket::INET on OSX or TCP stack problem
Message-Id: <0519a0c4-7705-483f-83aa-4a51f52dea80@d7g2000prl.googlegroups.com>

On May 15, 1:54=A0am, Stuart Gall <stu...@otenet.gr> wrote:
> On 2009-05-11 02:12:46 +0300, dery...@gmail.com said:
> ...
> I have sig alarm set anyway to catch the whole read/write loop.

Just a wild guess but you may want to try checking
sysread for failure since that's the first hint of
trouble. Also, that may be the best point to recover
since the alarm may be too late with errors cascading and getting even
more bizarre.


   use Errno; # check Errno for portability issues
   ...
   unless ( $socket->sysread($r,6) ) {
       if ( $! =3D=3D ECONNRESET ) {
           ... re-open socket etc


Otherwise, this is probably not a Perl issue and
you'll need to google.

--
Charles DeRykus



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

Date: Fri, 15 May 2009 21:30:34 +0300
From: Stuart Gall <stuart@otenet.gr>
Subject: Re: IO::Socket::INET on OSX or TCP stack problem
Message-Id: <gukccb$cmt$1@mouse.otenet.gr>

EURIKA!!!!

The problem is the tcp timestamps.
OSX is adding tcp timestamps, mandrivia does not.

These little modbus devices only have a 16 bit time stamp counter. Once 
this counter hits FFFF and goes back to 0 OSX thinks it has got an old 
packet from a looped sequence number.

So either I have to turn off time stamps, or I have to disable PAWS on the OSX.

Any ideas how I do that?

TIA
Stuart



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

Date: Fri, 15 May 2009 14:40:49 -0400
From: "Uri Guttman" <uri@PerlOnCall.com>
Subject: Re: IO::Socket::INET on OSX or TCP stack problem
Message-Id: <87preaus3y.fsf@quad.sysarch.com>

>>>>> "SG" == Stuart Gall <stuart@otenet.gr> writes:

  SG> EURIKA!!!!

eureka

  SG> The problem is the tcp timestamps.
  SG> OSX is adding tcp timestamps, mandrivia does not.

  SG> These little modbus devices only have a 16 bit time stamp
  SG> counter. Once this counter hits FFFF and goes back to 0 OSX thinks it
  SG> has got an old packet from a looped sequence number.

  SG> So either I have to turn off time stamps, or I have to disable
  SG> PAWS on the OSX.

  SG> Any ideas how I do that?

so this is not a perl problem as we forecast. maybe there is some option
for doing this to a socket but you would need to google to find out.

on linux man -s 7 socket shows this socket option:

       SO_TIMESTAMP
              Enable or disable the receiving of the SO_TIMESTAMP control mes]
              sage.   The  timestamp  control  message  is  sent  with   level
              SOL_SOCKET  and the cmsg_data field is a struct timeval indicat]
              ing the reception time of the last packet passed to the user  in
              this call.  See cmsg(3) for details on control messages.

so it could be done if you have that constant in perl from socket.pm or
similar and you use the setsockopt call correctly. they can be tricky to
get done right in c but likely easier in perl.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Fri, 15 May 2009 22:51:07 +0300
From: Stuart Gall <stuart@otenet.gr>
Subject: Re: IO::Socket::INET on OSX or TCP stack problem
Message-Id: <gukh3c$ee2$1@mouse.otenet.gr>

On 2009-05-15 21:30:34 +0300, Stuart Gall <stuart@otenet.gr> said:

> EURIKA!!!!
> 
> The problem is the tcp timestamps.
> OSX is adding tcp timestamps, mandrivia does not.
> 
> These little modbus devices only have a 16 bit time stamp counter. Once 
> this counter hits FFFF and goes back to 0 OSX thinks it has got an old 
> packet from a looped sequence number.
> 
> So either I have to turn off time stamps, or I have to disable PAWS on the OSX.
> 
> Any ideas how I do that?
> 
> TIA
> Stuart

OK Its fixed
sudo sysctl -w net.inet.tcp.rfc1323=0

or add the line

net.inet.tcp.rfc1323=0
to /etc/sysctl.conf'

This disables tcp window scaling also but that is not a issue for me.

I have also contacted the manufacture of the modbus devices to suggest 
they inplement tcp timestamps properly or not at all.

Many thanks to all who posted, your coments were a big help.


Stuart.



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

Date: Fri, 15 May 2009 06:13:47 -0700 (PDT)
From: Nigel <nigel@bouteyres.com>
Subject: My error log is growing dangerously large...
Message-Id: <00ec9a1b-301b-4b86-b655-46ce80103e89@t10g2000vbg.googlegroups.com>

Hi there,

I'm by no means a newbie, but I've obviously missed something very
basic in my learning of Perl (entirely self-taught). I have a problem
with a web-based database I've written using Perl. The apache
error_log grows at the rate of several hundred Mb per day! I've looked
at the log contents and most of the messages refer to the use of
uninitialized values - for example in concatenations of strings.

I have three questions:

1. Do I understand from this that in Perl every variable should be
initialised - not simply defined - before it is referenced? I use
strict and all my varaibles are defined thus:

my $foo;

Should I be doing this instead:

my $foo = "";

2. Given that I've already written over seventy programs, many of
which are many thousands of lines long, is there a safe way of
stopping the error log filling up in this way...without going back and
making major changes to all my programs?

3. My programs are working fine or at least doing what I would expect
them to do. So is there actually a problem in refering to
uninitialized variables - other than the one I am specifically asking
about?

Many thanks in advance for your advice/comments (hopefully none too
rude!)

Nigel


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

Date: Fri, 15 May 2009 16:04:56 +0200
From: =?ISO-8859-1?Q?=22j=2Eke=DFler=22?= <mail@bananas-playground.net>
Subject: Re: My error log is growing dangerously large...
Message-Id: <gujsqb$a4h$01$1@news.t-online.com>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Nigel wrote:
> Hi there,
> 
> I'm by no means a newbie, but I've obviously missed something very
> basic in my learning of Perl (entirely self-taught). I have a problem
> with a web-based database I've written using Perl. The apache
> error_log grows at the rate of several hundred Mb per day! I've looked
> at the log contents and most of the messages refer to the use of
> uninitialized values - for example in concatenations of strings.
> 
> I have three questions:
> 
> 1. Do I understand from this that in Perl every variable should be
> initialised - not simply defined - before it is referenced? I use
> strict and all my varaibles are defined thus:
> 
> my $foo;
> 
> Should I be doing this instead:
> 
> my $foo = "";
> 
> 2. Given that I've already written over seventy programs, many of
> which are many thousands of lines long, is there a safe way of
> stopping the error log filling up in this way...without going back and
> making major changes to all my programs?
> 
> 3. My programs are working fine or at least doing what I would expect
> them to do. So is there actually a problem in refering to
> uninitialized variables - other than the one I am specifically asking
> about?
> 
> Many thanks in advance for your advice/comments (hopefully none too
> rude!)
> 
> Nigel
I can only tell something about the webserver part.

Normally the log rotationg service which is configured as a service in your
server should handle the archiving of the log files. The webserver service
itself does this not.

So it sounds like that the log handling service is not working.

such servcies are syslogd and klogd or even metalog

j.keßler
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v2.0.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEUEARECAAYFAkoNdogACgkQE++2Zdc7EtdMPACTBFvI+UKpDVGxXPPNM0e1DTk3
fwCgqvBrNVkXxd8XICHWDuL0nVzOOGw=
=z3uD
-----END PGP SIGNATURE-----


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

Date: 15 May 2009 14:15:22 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: My error log is growing dangerously large...
Message-Id: <slrnh0qu7r.s35.glennj@smeagol.ncf.ca>

At 2009-05-15 09:13AM, "Nigel" wrote:
>  1. Do I understand from this that in Perl every variable should be
>  initialised - not simply defined - before it is referenced? I use
>  strict and all my varaibles are defined thus:
>  
>  my $foo;
>  
>  Should I be doing this instead:
>  
>  my $foo = "";

IMO you should either initialize your variables or at least check your
variables are defined() before referencing them.
    print $foo if defined $foo;
  
>  2. Given that I've already written over seventy programs, many of
>  which are many thousands of lines long, is there a safe way of
>  stopping the error log filling up in this way...without going back and
>  making major changes to all my programs?

If you don't want to fix your programs, turn off warnings.


-- 
Glenn Jackman
    Write a wise saying and your name will live forever. -- Anonymous


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

Date: Fri, 15 May 2009 08:02:24 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: My error log is growing dangerously large...
Message-Id: <9h0r059k33gdjofm0gsc7457f9pr8upuuc@4ax.com>

Nigel <nigel@bouteyres.com> wrote:
>[...]The apache
>error_log grows at the rate of several hundred Mb per day! I've looked
>at the log contents and most of the messages refer to the use of
>uninitialized values[...]
>
>2. Given that I've already written over seventy programs, many of
>which are many thousands of lines long, is there a safe way of
>stopping the error log filling up in this way...without going back and
>making major changes to all my programs?

As a stop-gap measure you could disable this particular warning in your
programs until you can fix the actual code problems. That would require
only one single consistant modification in every program.

>3. My programs are working fine or at least doing what I would expect
>them to do. So is there actually a problem in refering to
>uninitialized variables - other than the one I am specifically asking
>about?

Possibly. "Unitialized value" doesn't only come from undefined variables
but in my experience more often from edge case where all of a sudden a
variable value is no longer defined in the last loop or first loop or
failed pattern match or similar logic or coding errors.

jue


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

Date: Fri, 15 May 2009 17:47:36 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: My error log is growing dangerously large...
Message-Id: <775h4sF1fd9brU1@mid.individual.net>

Glenn Jackman wrote:
> At 2009-05-15 09:13AM, "Nigel" wrote:
>>  1. Do I understand from this that in Perl every variable should be
>>  initialised - not simply defined - before it is referenced? I use
>>  strict and all my varaibles are defined thus:
>>  
>>  my $foo;
>>  
>>  Should I be doing this instead:
>>  
>>  my $foo = "";
> 
> IMO you should either initialize your variables or at least check your
> variables are defined() before referencing them.
>     print $foo if defined $foo;
>   
>>  2. Given that I've already written over seventy programs, many of
>>  which are many thousands of lines long, is there a safe way of
>>  stopping the error log filling up in this way...without going back and
>>  making major changes to all my programs?
> 
> If you don't want to fix your programs, turn off warnings.

Or maybe just

     no warnings 'uninitialized';

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


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

Date: Fri, 15 May 2009 10:39:10 -0700 (PDT)
From: Danish <nigel@bouteyres.com>
Subject: Re: My error log is growing dangerously large...
Message-Id: <554c063c-84db-4ae0-bafe-41b2565d3dd5@v17g2000vbb.googlegroups.com>

On May 15, 5:47=A0pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> Glenn Jackman wrote:
> > At 2009-05-15 09:13AM, "Nigel" wrote:
> >> =A01. Do I understand from this that in Perl every variable should be
> >> =A0initialised - not simply defined - before it is referenced? I use
> >> =A0strict and all my varaibles are defined thus:
>
> >> =A0my $foo;
>
> >> =A0Should I be doing this instead:
>
> >> =A0my $foo =3D "";
>
> > IMO you should either initialize your variables or at least check your
> > variables are defined() before referencing them.
> > =A0 =A0 print $foo if defined $foo;
>
> >> =A02. Given that I've already written over seventy programs, many of
> >> =A0which are many thousands of lines long, is there a safe way of
> >> =A0stopping the error log filling up in this way...without going back =
and
> >> =A0making major changes to all my programs?
>
> > If you don't want to fix your programs, turn off warnings.
>
> Or maybe just
>
> =A0 =A0 =A0no warnings 'uninitialized';
>
> --
> Gunnar Hjalmarsson
> Email:http://www.gunnar.cc/cgi-bin/contact.pl- Hide quoted text -
>
> - Show quoted text -

I think I know how to turn off warnings : remove the -w in the first
line of each program, is that right?

But where/how would I implement: no warnings 'uninitialised'?

Thanks for all the help so far.

Nigel


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

Date: Fri, 15 May 2009 10:46:18 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: My error log is growing dangerously large...
Message-Id: <3dar0552839g5to6snhihjd9t4eglroejj@4ax.com>

Danish <nigel@bouteyres.com> wrote:
>I think I know how to turn off warnings : remove the -w in the first
>line of each program, is that right?

Rather by commenting out or removing the line

	use warnings;

"-w" has been obsolete for quite some time ;-)

>But where/how would I implement: no warnings 'uninitialised'?

At the beginning of the scope, for which you want to disable the
warning(s).

jue


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

Date: Fri, 15 May 2009 12:24:41 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: My error log is growing dangerously large...
Message-Id: <slrnh0r9ap.crd.tadmc@tadmc30.sbcglobal.net>

Nigel <nigel@bouteyres.com> wrote:

> The apache
> error_log grows at the rate of several hundred Mb per day! I've looked
> at the log contents and most of the messages refer to the use of
> uninitialized values - for example in concatenations of strings.


If you had written the programs to be "warnings clean", then you
would not be experiencing this problem.

You should not count development completed until your code is warnings clean.


> I have three questions:
>
> 1. Do I understand from this that in Perl every variable should be
> initialised - not simply defined - before it is referenced? 


No you should not need to initialize every variable. The fact that
a variable has not been initialized (defined) is useful for discovering
edge cases and other unexpected bugs.

No, unitialized values do not emit warnings when they are referenced:

------------------------
#!/usr/bin/perl
use warnings;
use strict;

my $var;

if ( $var ) {
    print "$var is true\n";
}

my $foo = $var;
------------------------

$var is uninitialized and is referenced twice, yet there are no warnings.

Uninitialized values (not necessarily in a variable) emit a warning
when "used as if it were already defined", as it says in perldiag
for that particular message.


> I use
> strict and all my varaibles are defined thus:
>
> my $foo;


That does NOT "define" a variable.

That "declares" a variable. 

The variable's value is still undef (uninitialized).


> Should I be doing this instead:
>
> my $foo = "";


Whether you should do that or not depends on what $foo is expected
to signify.

Leaving it undef is a common way of signalling some unexpected condition
for example.


> 2. Given that I've already written over seventy programs, many of
> which are many thousands of lines long, is there a safe way of
> stopping the error log filling up in this way...without going back and
> making major changes to all my programs?


Since it would be "major changes" then we should assume that these
warnings are coming from many different lines in your programs?

It may be the case that it is only a few lines inside of a loop that
iterates many times, in which case it would not be very painful to
fix properly.

I have written thousands of Perl programs, *all* of them designed to
never emit an uninitialized value message, so that when I _do_ get
such a message, I'll realize that something happened that I did not
consider when I wrote the program (i.e. it announces that I have a bug).


> 3. My programs are working fine or at least doing what I would expect
> them to do. So is there actually a problem in refering to
> uninitialized variables - 


Sometimes there is and sometimes there isn't.

If, upon inspecting the code that is generating a particular warning,
you determine that it is not really a problem, that is, you expect
that there are at least some cases what a value will never be
assigned, then you should insert code that avoids the warning.

There are several ways to do this, I will go to quite some trouble to
avoid the last one:

   my $sum = 0;   # define a default value
   ...            # here is code that only _might_ modify $sum
   print "sum=$sum\n";  # zero = right answer, empty string = wrong answer

   $sum = 0 unless defined $sum;  # same thing, only later in the program
   print "sum=$sum\n";

   { # for some odd reason, a sum of the empty string is reasonable...
     no warnings 'uninitialized';
     print "sum=$sum\n";
   }

In that case you are never using an undefined value as if it was defined,
so you get no spurious warnings.

Simply ignoring the warnings makes in highly likely that a use that
is NOT what you were expecting will go unnoticed. Your bug will live on...


> other than the one I am specifically asking
> about?


You are not asking about a specific uninitialized value warning,
you are asking generally about a lot of such warnings.

If you want a comment on a specific case, then please post code
containing a specific case for us to comment on.


> Many thanks in advance for your advice/comments 


You're welcome. I hope it helps.


> (hopefully none too
> rude!)


Your feet stink!

(I don't take direction very well.)


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Fri, 15 May 2009 11:24:17 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: My error log is growing dangerously large...
Message-Id: <3jcr05h7ivn4fcenio1i7e54mm6bt5lo2i@4ax.com>

Tad J McClellan <tadmc@seesig.invalid> wrote:
>If you had written the programs to be "warnings clean", then you
>would not be experiencing this problem.
>You should not count development completed until your code is warnings clean.

While I agree with that statement in general you should remember that
those warnings often appear in edge cases which may have been missed
during regular testing.
Although, I have to admit that if there are megabytes of those warnings
being generated then it must have been a very frequent edge case.

jue


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

Date: Fri, 15 May 2009 21:07:41 +0200
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: My error log is growing dangerously large...
Message-Id: <4a0dbd7d$0$201$e4fe514c@news.xs4all.nl>

Jürgen Exner wrote:

> 	use warnings;
> 
> "-w" has been obsolete for quite some time ;-)

Not really. I for example like "-w" in the shebang of my scripts, 
because it enforces warnings into the used modules.

-- 
Ruud


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

Date: Fri, 15 May 2009 12:14:43 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: My error log is growing dangerously large...
Message-Id: <bifr059nj98bqe98nqbo5qvgene3naog7f@4ax.com>

"Dr.Ruud" <rvtol+usenet@xs4all.nl> wrote:
>Jürgen Exner wrote:
>
>> 	use warnings;
>> 
>> "-w" has been obsolete for quite some time ;-)
>
>Not really. I for example like "-w" in the shebang of my scripts, 
>because it enforces warnings into the used modules.

I agree, sometimes it has its uses if you know what you are doing. 

In your example its e.g. an easy way to force your developers to get
their modules clean. On the other hand it could also generate a slew of
nasty warnings if you are using an unclean third-party module where you
have no control over it.
It all depends....

jue


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

Date: Fri, 15 May 2009 21:24:54 +0200
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: My error log is growing dangerously large...
Message-Id: <4a0dc186$0$182$e4fe514c@news.xs4all.nl>

Jürgen Exner wrote:

 > [ -w ]
> its e.g. an easy way to force your developers to get
> their modules clean. On the other hand it could also generate a slew of
> nasty warnings if you are using an unclean third-party module where you
> have no control over it.

No control?
;)

-- 
Ruud


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

Date: Fri, 15 May 2009 11:21:06 -0700 (PDT)
From: Mike Samuel <mikesamuel@gmail.com>
Subject: perl 5 grammar
Message-Id: <c16f2e11-21e2-4997-b949-f275d8f43109@y10g2000prc.googlegroups.com>

I maintain the syntax highlighter for code.google.com and perl support
is rather lacking.

I know perl has a complex grammar, but can someone point me at a
simple lexical grammar for perl 5 that will allow me to at least
identify comment, string, and regex boundaries?

cheers,
mike


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

Date: Fri, 15 May 2009 14:32:05 -0400
From: "Uri Guttman" <uri@PerlOnCall.com>
Subject: Re: perl 5 grammar
Message-Id: <87vdo2usii.fsf@quad.sysarch.com>

>>>>> "MS" == Mike Samuel <mikesamuel@gmail.com> writes:

  MS> I maintain the syntax highlighter for code.google.com and perl support
  MS> is rather lacking.

  MS> I know perl has a complex grammar, but can someone point me at a
  MS> simple lexical grammar for perl 5 that will allow me to at least
  MS> identify comment, string, and regex boundaries?

forget about it. you can't properly parse perl5 since its syntax can
change based upon the modules and pragmas that you load. there are some
attempts at this with varying success. see cperl-mode.el for emacs
lisp. adam kennedy has a parser on cpan that is reasonable. there are
other attempts around.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Fri, 15 May 2009 11:43:25 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: perl 5 grammar
Message-Id: <avcr05dkfiluhr0mb25f89m0qkb02t88mt@4ax.com>

Mike Samuel <mikesamuel@gmail.com> wrote:
>I maintain the syntax highlighter for code.google.com and perl support
>is rather lacking.

Surprise, surprise. Considering what Google has done to Usenet I wonder
why so many people couldn't care less.

>I know perl has a complex grammar, but can someone point me at a
>simple lexical grammar for perl 5 that will allow me to at least
>identify comment, string, and regex boundaries?

The old saying goes "only perl can parse Perl".

Comments are easy: anything following a # sign in the same line or
anything enclosed as POD.

Strings are a different story, because there is no single set of
characters (like single or double quotes) identifying a string but there
are numerous operations and functions, which turn their argument into a
string, notably the quote and quote-like operators  

        Customary  Generic        Meaning        Interpolates
            ''       q{}          Literal             no
            ""      qq{}          Literal             yes
            ``      qx{}          Command             yes (unless '' is
delimiter)
                    qw{}         Word list            no
            //       m{}       Pattern match          yes (unless '' is
delimiter)
                    qr{}          Pattern             yes (unless '' is
delimiter)
                     s{}{}      Substitution          yes (unless '' is
delimiter)
                    tr{}{}    Transliteration         no (but see below)

for which you can use any number of delimiter, e.g. in m -foo*bar- the
text 'foo*bar' is a string (and an RE). This cannot be parsed on the
lexical level.

Same goes for regex boundaries. There isn't a given set of characters
like /.../., but a regexp is identified by its position as argument for
a specific operation. The first arguments in s/// and m// are regular
expressions, no matter if you are using the slash or some other
delimiter and the first argument of tr/// is not an RE, although I used
the slash. Again, this cannot be determined on the lexical level.

jue


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

Date: Fri, 15 May 2009 14:48:32 -0400
From: "Uri Guttman" <uri@PerlOnCall.com>
Subject: Re: perl 5 grammar
Message-Id: <8763g2urr3.fsf@quad.sysarch.com>

>>>>> "JE" == Jürgen Exner <jurgenex@hotmail.com> writes:

  JE> Same goes for regex boundaries. There isn't a given set of characters
  JE> like /.../., but a regexp is identified by its position as argument for
  JE> a specific operation. The first arguments in s/// and m// are regular
  JE> expressions, no matter if you are using the slash or some other
  JE> delimiter and the first argument of tr/// is not an RE, although I used
  JE> the slash. Again, this cannot be determined on the lexical level.

i wouldn't say s/// and m// have 'first' arguments but i get your
point. but the first arg to split is always a regex and it doesn't need
to be marked with // as any expression will do. and =~ will make its
right arg a regex as well even without m//.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Fri, 15 May 2009 12:08:47 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: perl 5 grammar
Message-Id: <aver059hoit6tc5kiv5c0heiguae9svkvr@4ax.com>

"Uri Guttman" <uri@PerlOnCall.com> wrote:
>>>>>> "JE" == Jürgen Exner <jurgenex@hotmail.com> writes:
>
>  JE> Same goes for regex boundaries. There isn't a given set of characters
>  JE> like /.../., but a regexp is identified by its position as argument for
>  JE> a specific operation. The first arguments in s/// and m// are regular
>  JE> expressions, no matter if you are using the slash or some other
>  JE> delimiter and the first argument of tr/// is not an RE, although I used
>  JE> the slash. Again, this cannot be determined on the lexical level.
>
>i wouldn't say s/// and m// have 'first' arguments but i get your
>point. 

Well, maybe not technically, but how would you call them? Operands? I
have always been looking for a good term and couldn't find one I liked.

Besides 
	s(foo)(bar) 
is valid and there you got a first argument, at least lexically :-)  

>but the first arg to split is always a regex and it doesn't need
>to be marked with // as any expression will do. and =~ will make its
>right arg a regex as well even without m//.

Good point, those are two more which are not listed under quote and
quote-like ops.

jue


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

Date: Fri, 15 May 2009 15:16:46 -0400
From: "Uri Guttman" <uri@PerlOnCall.com>
Subject: Re: perl 5 grammar
Message-Id: <87ws8itbvl.fsf@quad.sysarch.com>

>>>>> "JE" == Jürgen Exner <jurgenex@hotmail.com> writes:

  JE> "Uri Guttman" <uri@PerlOnCall.com> wrote:

  >> i wouldn't say s/// and m// have 'first' arguments but i get your
  >> point. 

  JE> Well, maybe not technically, but how would you call them? Operands? I
  JE> have always been looking for a good term and couldn't find one I liked.

  JE> Besides 
  JE> 	s(foo)(bar) 
  JE> is valid and there you got a first argument, at least lexically :-)  

true. i usually say regex and replacement parts (or left and right part
or first and second) of s///. it is a single operator with its own
syntax so i wouldn't use arguments but it is a minor nit. for m// i just
say the regex itself.

  >> but the first arg to split is always a regex and it doesn't need
  >> to be marked with // as any expression will do. and =~ will make its
  >> right arg a regex as well even without m//.

  JE> Good point, those are two more which are not listed under quote and
  JE> quote-like ops.

and a proper highlighter would mark those as regexes but not
strings. and =~ has an even worse case, a full expression! how would you
syntax highlight this:

	$foo =~ bar() ;
or
	$foo =~ join( '|', @list_of_parts ) ;

:)

and is the replacement part of s///e highlighted as a string or an
expression? what about s///ee!! :)

i disable highlighting in emacs as i get blurry eyes from all the
colors. if i wanted psychedelic code, i would take the appropriate
meds. :)

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Fri, 15 May 2009 06:37:46 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: problems with writing to an output file
Message-Id: <sprq051uj3d0lbjp592akdc0eovjmf3uhf@4ax.com>

Ameya <ameya.r.sathe@gmail.com> wrote:
[writing to a file]

>What could be the problem and how can I get my values to print in the
>file. Following is the code snippet explaining the read and write
>commands I use in my code.
>
>********************************************
>open my $fin, '<', $inFile or die "could not open file '$inFile' $!";
># Open the file for reading, $inFile is a CSV file
>while (my $line = <$fh>) {
>    chomp($line);
>    ...........
>    .........
>    $a = $line;
>}
>
>print $fout "$a\n" or die "Can't print in the file $outFile: $!"; #
>There is no value of $a in $outFile
>print $fout "Hello\n" or die "Can't print in the file $outFile: $!"; #
>There is no "Hello" statement in $outFile
>print "Hello\n" or die "Can't print in the file $outFile: $!"; #Prints
>Hello on the screen
>************************************************

In the code you are showing above you never open $fout. 

That may or may not be a problem (maybe you are opening it in the part
you snipped), but we cannot analyse something that we cannot see. Please
post a minimal, but complete program, strict and warnings clean, that we
can run and that demonstrates your problem.

jue


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

Date: Fri, 15 May 2009 13:04:24 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: problems with writing to an output file
Message-Id: <slrnh0rbl8.crd.tadmc@tadmc30.sbcglobal.net>

Ameya <ameya.r.sathe@gmail.com> wrote:

> I open $file 


There is no $file variable in the code you have posted.


> What could be the problem 


Did you get any error messages?

If so, what did they say?

How was $fout open()ed? That also is not in the code you have posted.


> print $fout "$a\n" or die "Can't print in the file $outFile: $!"; #
> There is no value of $a in $outFile


Did the die() make any output?

If so, what did it say?



Have you seen the Posting Guidelines that are posted here frequently?

You have not provided the information we need to help you solve your
problem. The guidelines point out several things that will help us
to help you...


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Fri, 15 May 2009 10:30:59 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: s/(The N)e(urdsburg Affair)/$1$2/ looks dumb
Message-Id: <86ws8iidsc.fsf@lifelogs.com>

On Thu, 14 May 2009 11:00:28 +0800 jidanni@jidanni.org wrote: 

j> Sure I can do
j> s/(The N)e(urdsburg Affair)/$1$2/;
j> but something tells me that there ought to be a smarter looking way to
j> get the same functionality. Something like
j> s/The N(e)urdsburg Affair/... but what?

I've learned, with experience, to beware "smart" ways of solving simple
problems.  They usually become unmanageable messes, all for the sake of
stroking the programmer's ego.  I've been guilty of this too.

It's almost always (99.9% of the time) better to just do what others
would expect you to do, even if it's not emphatically clever.  As the
famous quote goes, code as if the person who will maintain your code is
a homicidal maniac who knows where you live.

Ted


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

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 V11 Issue 2420
***************************************


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