[25977] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8196 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 23 21:05:17 2005

Date: Thu, 23 Jun 2005 18:05:07 -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           Thu, 23 Jun 2005     Volume: 10 Number: 8196

Today's topics:
    Re: [OT] Re: "use CGI " hangs  "CGI time out " <stan.remove@bremove.lz.hmrprint.com>
    Re: [OT] Re: "use CGI " hangs  "CGI time out " <pfiland@mindspring.com>
    Re: [OT] Re: "use CGI " hangs  "CGI time out " <tadmc@augustmail.com>
    Re: Newbie Help <tony@heagren.com>
    Re: remove specific line from al ltext fiels in dir? <snail@localhost.com>
    Re: remove specific line from al ltext fiels in dir? <tadmc@augustmail.com>
        Switch and capturing regexes <jgottman@carolina.rr.com>
    Re: Switch and capturing regexes <skuo@psi.nsc.com>
    Re: Switch and capturing regexes <jgottman@carolina.rr.com>
    Re: The non-terminating script, revisited xhoster@gmail.com
    Re: The non-terminating script, revisited xhoster@gmail.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 23 Jun 2005 16:50:52 -0700
From: "Stan R." <stan.remove@bremove.lz.hmrprint.com>
Subject: Re: [OT] Re: "use CGI " hangs  "CGI time out "
Message-Id: <42bb4bd8$1_1@spool9-west.superfeed.net>

Eric Sosman wrote:
> Clark S. Cox III wrote:
>> On 2005-06-23 14:38:33 -0400, "Alfred Z. Newmane"
>> <a.newmane.remove@eastcoastcz.com> said:
>>>
>>> in c and c++ variables that are uninialized usually have a random
>>> value, not NULL or 0 (zero.)
>>
>>
>> Correct.
>
>    Well, partly correct.  An uninitialized variable of
> `auto' or `register' storage class "contains garbage" --
> formally, its value is indeterminate.
>
>    Things are different, though, for variables declared
> at file scope (outside any function) or for function-local
> variables declared `static'.  If no initializer is present,
> these variables are initialized to zero or NULL before
> the program starts executing.  At file scope,
>
> int i;
> double d;
> char *p;
>
> is equivalent to
>
> int i = 0;
> double d = 0.0;
> char *p = 0;    /* NULL */

Doesn't this depend on the compiler and platform?

-- 
Stan 




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

Date: Fri, 24 Jun 2005 00:46:18 GMT
From: pete <pfiland@mindspring.com>
Subject: Re: [OT] Re: "use CGI " hangs  "CGI time out "
Message-Id: <42BB57D9.F1@mindspring.com>

Stan R. wrote:
> 
> Eric Sosman wrote:

> >  At file scope,
> >
> > int i;
> > double d;
> > char *p;
> >
> > is equivalent to
> >
> > int i = 0;
> > double d = 0.0;
> > char *p = 0;    /* NULL */
> 
> Doesn't this depend on the compiler and platform?

In C, no.

-- 
pete


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

Date: Thu, 23 Jun 2005 19:50:11 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: [OT] Re: "use CGI " hangs  "CGI time out "
Message-Id: <slrndbmm63.4q2.tadmc@magna.augustmail.com>

Alfred Z. Newmane <a.newmane.remove@eastcoastcz.com> wrote:


> reason I added comp.lang.c to the ng list was that I wanted to move the 
> discussion to the c group, but not leave out the folks in c.l.p.m who 
> were following it out in the cold, 


Did you note in the message body that you were exanding 
the Newsgroups header?


> which to me would seem like a rude 
> thing to do. 


Not doing so is well established as being a rude thing to do.


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


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

Date: Thu, 23 Jun 2005 23:58:56 GMT
From: Tony heagren <tony@heagren.com>
Subject: Re: Newbie Help
Message-Id: <2005062400585616807%tony@heagrencom>

On 2005-06-23 11:56:35 +0100, John Bokma <john@castleamber.com> said:

> Tony heagren <tony@heagren.com> wrote:
> 
>> Hi all...
> 
> Hi: pick your subject with more care.
> 
>> I have 12 jpgs in a directory called "copy"
>> I need a script to rename "news1.jpg" to "news2.jpg"
>> and so on through the list.
> 
> I would fire up my editor, open a dos box, get the list of file names,
> paste them in the editor, record a macro, and let that one do the trick.

Thanks for all your help.
In the end (owing to time pressure) I did it in Flash
and let a simple .txt file cope with being rewritten to hold
the variable names then pump them back into flash with new
instance names.

I know this would hae been quicker in perl though...
Must read the books...

Best wishes
Tony



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

Date: Thu, 23 Jun 2005 15:11:56 -0700
From: "Snail" <snail@localhost.com>
Subject: Re: remove specific line from al ltext fiels in dir?
Message-Id: <d9fc0h$qmm$1@news.astound.net>

Tad McClellan wrote:
> Snail <snail@localhost.com> wrote:
>> I've been trying to find a way to remove a line containing a specific
>> string.
>
>> more than 95% of the text in the logs making them rather big.
>                                   ^^^^
>
> Are these "live" logs? That is, will logging writes be happening
> when you run your cleanup program?
>
> If so, then you better work file locking into the mix.

Yes and no. They are live during the day, but at night, for 10 minutes, 
its like a "maintence" time. My plan was to setup a cron job to strip 
the uneeded lines from the logs. The server daemon provides no way (and 
even worse, no source code :< ) to customize it's logs, thats why I 
wanted to take matters into my own hands.

`perl -ni -e'print unless /localhost|127\.0\.0\.1/' *.log`

Works almsot perfectly. If I run it from my shell window I see annoying

"Can't do inplace edit: backup is not a regular file."

type messages when it encouters a directory, and I can no way to supress 
them, even with 2>&1 appended to the end.

`perl -ni -e'print unless /localhost|127\.0\.0\.1/' *.log 2>&1`

I suppose it doesn't matter as this will be running from a cron job, but 
I think it would run a little after if there was a way to just skip dirs 
all together. Maybe it would be better to just write a full perl script 
using readdir, and checking each one with -f to see if it's a file.

Unless there is a way to achieve this on the cmd line?

Thanks again. 




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

Date: Thu, 23 Jun 2005 19:01:00 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: remove specific line from al ltext fiels in dir?
Message-Id: <slrndbmj9s.4q2.tadmc@magna.augustmail.com>

Snail <snail@localhost.com> wrote:

> `perl -ni -e'print unless /localhost|127\.0\.0\.1/' *.log`
> Works almsot perfectly. If I run it from my shell window I see annoying
> 
> "Can't do inplace edit: backup is not a regular file."
> 
> type messages when it encouters a directory, and I can no way to supress 
> them, even with 2>&1 appended to the end.
>
> `perl -ni -e'print unless /localhost|127\.0\.0\.1/' *.log 2>&1`
  ^                                                             ^
  ^                                                             ^

What's with the (shell) backticks?

Is that really how you are calling it?

Leave them off, or do the redirection outside of them, but you don't
what the annoying messages in your log file either, so make it 2>/dev/null
or some such.


> I suppose it doesn't matter as this will be running from a cron job, but 
> I think it would run a little after if there was a way to just skip dirs 
> all together. Maybe it would be better to just write a full perl script 
> using readdir, and checking each one with -f to see if it's a file.
> 
> Unless there is a way to achieve this on the cmd line?


You can muck about with @ARGV before you let -n's while(<>)
loop look at it (line wrapped for posting):

   perl -ni -e 'BEGIN{@ARGV = grep -f, @ARGV} 
                print unless /localhost|\Q127.0.0.1/' *.log


Or, even better, don't make subdirectories with silly names
that match *.log.   :-)


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


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

Date: Thu, 23 Jun 2005 23:41:19 GMT
From: "Joe Gottman" <jgottman@carolina.rr.com>
Subject: Switch and capturing regexes
Message-Id: <zMHue.19$XQ.48493@twister.southeast.rr.com>

I am having problem using Switch with capturing regexes. For instance, 
consider the following code:

use Switch;
my $foo = 'foo';
switch ($foo) {
    case /(.*)/ {print "Worked. Captured text = '$1'\n";}
    else {print "Didn't work\n";}
}

The output I get is
    Worked. Captured text = ''

Thus, the regular expression is matching as expected, but no data is being 
captured.



Joe Gottman




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

Date: Thu, 23 Jun 2005 17:17:28 -0700
From: Steven Kuo <skuo@psi.nsc.com>
Subject: Re: Switch and capturing regexes
Message-Id: <Pine.LNX.4.60.0506231706530.7130@psi.nsc.com>

On Thu, 23 Jun 2005, Joe Gottman wrote:

> I am having problem using Switch with capturing regexes. For instance,
> consider the following code:
>
> use Switch;
> my $foo = 'foo';
> switch ($foo) {
>    case /(.*)/ {print "Worked. Captured text = '$1'\n";}
>    else {print "Didn't work\n";}
> }
>
> The output I get is
>    Worked. Captured text = ''
>
> Thus, the regular expression is matching as expected, but no data is being
> captured.




Perhaps the $1 you expected is no longer in scope when the block of
code following 'case' is executed?  You'd have to look at source code
of the Switch module to verify that but this would seem to point in
that direction:


use Switch;
my $foo = 'foo';
$_ = 'foobar';
$_ =~ /(.{3})$/; # $1 = "bar";

my $save;

switch ($foo) {
     case /(.+)(?{ $save = $1 })/ {print "Worked. Captured text = $save $1\n";}
     else {print "Didn't work\n";}
}


By the way, /(.*)/ will match any string -- was that used
intentionally on your part?

-- 
Hope this helps,
Steven



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

Date: Fri, 24 Jun 2005 00:20:22 GMT
From: "Joe Gottman" <jgottman@carolina.rr.com>
Subject: Re: Switch and capturing regexes
Message-Id: <alIue.25$XQ.52894@twister.southeast.rr.com>


"Steven Kuo" <skuo@psi.nsc.com> wrote in message 
news:Pine.LNX.4.60.0506231706530.7130@psi.nsc.com...
> On Thu, 23 Jun 2005, Joe Gottman wrote:
>
>> I am having problem using Switch with capturing regexes. For instance,
>> consider the following code:
>>
>> use Switch;
>> my $foo = 'foo';
>> switch ($foo) {
>>    case /(.*)/ {print "Worked. Captured text = '$1'\n";}
>>    else {print "Didn't work\n";}
>> }
>>
>> The output I get is
>>    Worked. Captured text = ''
>>
>> Thus, the regular expression is matching as expected, but no data is 
>> being
>> captured.
>
>
>
>
> Perhaps the $1 you expected is no longer in scope when the block of
> code following 'case' is executed?  You'd have to look at source code
> of the Switch module to verify that but this would seem to point in
> that direction:
>
>
> use Switch;
> my $foo = 'foo';
> $_ = 'foobar';
> $_ =~ /(.{3})$/; # $1 = "bar";
>
> my $save;
>
> switch ($foo) {
>     case /(.+)(?{ $save = $1 })/ {print "Worked. Captured text = $save 
> $1\n";}
>     else {print "Didn't work\n";}
> }
>
>
> By the way, /(.*)/ will match any string -- was that used
> intentionally on your part?

   Yes, I just wanted to demonstrate the concept.  Thanks for your help.

Joe Gottman 




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

Date: 23 Jun 2005 23:44:58 GMT
From: xhoster@gmail.com
Subject: Re: The non-terminating script, revisited
Message-Id: <20050623194458.603$nk@newsreader.com>

Debo <mddibern@uwaterloo.ca> wrote:

>
> > Also, what is the point of setting RaiseError=1 if you are just going
> > to put evals around every single call?
>
> Am I totally missing the point here? It is possible that I am. I set
> RaiseError to 1, place an eval around the call, and then check $@ to see
> if anything has gone awry.

Why not just drop the eval and the RaiseError and then
check $DBI::errstr rather than $@?

> Most of the time, I don't *want* my script to
> die if the call fails -- I would like to attempt some sort of recovery.
>
> Is eval-wrapping a bad thing to do?

I think doing it for every call is a bad thing.  I use RaiseError, and then
eval wrap only specific calls which I expect to throw specific errors (i.e.
unique key constraint violations which are caused by race conditions upon
insert).  I don't bother to wrap select statements, deletes, inserts with
no potential for race conditions, etc., because if I get an error string of
"ORA-12345: Your select statement failed because the Oracle server is
currently on fire" there isn't much I can do about it anyway.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: 23 Jun 2005 23:47:54 GMT
From: xhoster@gmail.com
Subject: Re: The non-terminating script, revisited
Message-Id: <20050623194754.426$QG@newsreader.com>

Debo <mddibern@uwaterloo.ca> wrote:
>
> I did this before the putting everything together the first time, and it
> appeared that Bioperl was doing what it was supposed to. Now, though,
> I've narrowed the problem down to a specific Bioperl module, and for the
> first time I'm able to consistently reproduce the bug.

For the sake of future people suffering similar problems, which module was
it?

Thanks,

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

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 8196
***************************************


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