[7592] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1218 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 23 09:33:01 1997

Date: Thu, 23 Oct 97 06:01:16 -0700
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 Oct 1997     Volume: 8 Number: 1218

Today's topics:
     Re: catching exit() within eval() ??? (Charles DeRykus)
     Re: Checking for the existence of subroutines <seay@absyss.fr>
     Console emulator <robertn@dawid.com.pl>
     Console emulator <robertn@dawid.com.pl>
     Re: Data driven code...? <mcguirk@indirect.com>
     enlightened language (Janne Leppdnen)
     Re: Huge files, <>, and sysread() (Mordechai T. Abzug)
     Installing Perl <jason@enterpriselink.com>
     Minimal match regular expression <erac.eramsva@memo.ericsson.se>
     Re: Minimal match regular expression <cnwetzel@linguistik.uni-erlangen.de>
     Re: Minimal match regular expression <eike.grote@theo.phy.uni-bayreuth.de>
     Re: Minimal match regular expression <Matthew.Rice@ftlsol.com>
     Re: Minimal match regular expression <Matthew.Rice@ftlsol.com>
     Re: Newbie Question : remove files named $files (Harold Kloosterhof)
     Re: Newbie Question : remove files named $files <mcguirk@indirect.com>
     non-locking fileread <robert.friberg@eductus-vast.com>
     Re: OR v. Randal: Employees have no 1st Amendment Right <seay@absyss.fr>
     Polling console in Win32 (John Thomas Mongan)
     Problems locking a file <xavi@teclata.es>
     Q: stat() on Win32 (Periat Henri)
     Regexp optimizing <roarl@metaphor.no>
     Re: Regexp optimizing (Mike Heins)
     Strange error with close() <techno@pedal.se>
     Re: Un-require lib files (Charles DeRykus)
     Use perl from Visual Basic (Milivoj Ivkovic)
     Wanted Perl Programmer to set Up database <sdwb@earthlink.net>
     What School Best for Perl & Programming <sdwb@earthlink.net>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 22 Oct 1997 21:54:32 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: catching exit() within eval() ???
Message-Id: <EIH3Ix.Lzt@bcstec.ca.boeing.com>

In article <344D369D.83319413@intershop.de>,
Christian Mallwitz  <mallwitz@intershop.de> wrote:
 > Hi folks,
 > 
 > I want to catch a call to exit() within a eval(). The code in eval is actually a
 > require(something) and I can't change "something" :-( 
 > 
 > Here is was I tried:
 > 
 > eval "exit;";
 > warn "outside: [$@]" if $@;
 > print "finishing ...";
 > END { print "within END block\n"; }
 > 
 > As expected the END block is executed but not the print statement.
 > 
 > Is there any work around ?
 > 

Maybe something like this:

eval { $require_did_not_exit = 0; require(something) };
$require_did_not_exit = 1;
if ($@) {
 ...
else {
 ....
}
END {
   if ($require_did_not_exit) {
      ...
   } else {
     ...

}
   
   
HTH,
--
Charles DeRykus


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

Date: Thu, 23 Oct 1997 10:10:33 +0200
From: Doug Seay <seay@absyss.fr>
To: Arvid Peterson <apeterso@ctberk.com>
Subject: Re: Checking for the existence of subroutines
Message-Id: <344F0679.188F6E84@absyss.fr>

[posted and mailed]

Arvid Peterson wrote:
> 
> Is there any way in perl 4 to check for the existence of a certain
> subroutine in a program and call that subroutine only if it exists??

With the debugger it is possible to snoop around in the Symbol Table, so
maybe you could do whatever it does.  You should also be able to use
eval() and trab the lack of existance of the subroutine.  The classic
Camel should help (and is much easier to read than that damned 115 page
long manpage of 4.036).


> The reason for this is, I need to call subroutines for specific variable
> values, and want to name the subroutine with the value. Let's say...
> 
> $var1= "grub";
> <more perl code>
> &$var1;

I don't think that &$var is legal Perl4 syntax.  Soft references didn't
exist yet.  If you want to be dynamic, you'll need to use either eval()
or a TYPEGLOB.  Both are ugly, but I prefer the eval().

> I have tried...
> &$var1 || warn "subroutine $var1 is not defined\n";

Did "-w" scream about this?  I trink it would.


> as well as...
> #define FIRST &$var1
> #if FIRST
>    &$var1
> #endif

I don't see how running this through cpp would change anything.

- doug


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

Date: Thu, 23 Oct 1997 11:28:16 +0100
From: "Robert Nosko" <robertn@dawid.com.pl>
Subject: Console emulator
Message-Id: <62n56l$m6m$1@sunsite.icm.edu.pl>

Hi,
Some programs on linux require input directly from console.
I want my script to be able to send input to such programs.
How can I:
1. write console emulator in perl?
2. link this emulator with any program?
thanks,
--
++++++++++++++++++++++++++++++++++++++++++
 Robert Nosko        e-mail: robertn@dawid.com.pl
 studio DAWID        ICQ: 1219984
 Lodz                        IRC nickname: ninja
++++++++++++++++++++++++++++++++++++++++++




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

Date: Thu, 23 Oct 1997 11:33:52 +0100
From: "Robert Nosko" <robertn@dawid.com.pl>
Subject: Console emulator
Message-Id: <62n63g$oe8$1@sunsite.icm.edu.pl>

Hi,
Some programs on linux require input directly from console.
I want my script to be able to send input to such programs.
How can I:
1. write console emulator in perl?
2. link this emulator with any program?
thanks,
--
++++++++++++++++++++++++++++++++++++++++++
Robert Nosko        e-mail: robertn@dawid.com.pl
studio DAWID        ICQ: 1219984
Lodz                        IRC nickname: ninja
++++++++++++++++++++++++++++++++++++++++++


--
++++++++++++++++++++++++++++++++++++++++++
 Robert Nosko        e-mail: robertn@dawid.com.pl
 studio DAWID        ICQ: 1219984
 Lodz                        IRC nickname: ninja
++++++++++++++++++++++++++++++++++++++++++




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

Date: Thu, 23 Oct 1997 07:21:14 -0600
From: Dan McGuirk <mcguirk@indirect.com>
To: pfortin@cisco.com,mcguirk@indirect.com
Subject: Re: Data driven code...?
Message-Id: <877609026.16296@dejanews.com>

In article <344E3D82.2E9C0C07@cisco.com>,
  pfortin@cisco.com wrote:
> I'm trying to write code to read lines from a file and invoke specific
> subroutines based on the input data (i.e., $data = "foo", so invoke:
> eval $data.'(@bar)'; which is really foo(@bar); ...)  So far, so good;
> but there are cases where the resulting call is to a non-existant
> routine (at least until I get arround to writing one).  I just need to
> know that this is not a valid routine name (and might never be).
>
> Is there a way to determine to "-w|use strict"'s satisfaction that a
> routine exists:
> - locally
> - externally
> - at all
> - other?

How about:

#!/usr/bin/perl5 -w

use strict;

sub foo {};

$::str = "foo";
print "$::str defined? ", defined(&$::str) ? "yes" : "no", "\n";
$::str = "bar";
print "$::str defined? ", defined(&$::str) ? "yes" : "no", "\n";

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 23 Oct 1997 11:45:15 GMT
From: Janne.Leppanen@metla.fi (Janne Leppdnen)
Subject: enlightened language
Message-Id: <62ndcb$m1j$1@bambu.metla.fi>

I'd like to get new newsgroup for a new language called 
enlightened syntax extension language (ESEL). Rather than
develop it secretly by myself I decided to post this message 
to comp.lang.perl.misc and comp.lang.c++.moderated because 
it's based on existing technology (PERL and C++). One could call 
ESEL also a highly advanced preprocessing language.

I encourage PERL and C++ developers to think about this idea.

What's ESEL about answered in a sentence?

The power of syntax definition given to the programmer.



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

Date: 20 Oct 1997 19:17:03 -0400
From: mabzug1@umbc.edu (Mordechai T. Abzug)
Subject: Re: Huge files, <>, and sysread()
Message-Id: <62gopf$fcu@umbc6.umbc.edu>

In article <yf1hgac6usz.fsf@iniki.gsfc.nasa.gov>,
"J-F Pitot de La Beaujardiere " <delabeau@iniki.gsfc.nasa.gov> spake thusly:
> 
> A colleague just came to me with a Perl problem.  He is attempting to read a
> huge (20MB) text file.  Everything works if he attempts to process test
> lines snipped from the file, but if he tries to process the entire file it
> takes forever (forever = longer than patience permits).  Stepping through
> with the debugger suggests that the line
> 
> 	foreach $line (<FILE>)

The evaluation of <FILE> depends on context.  If it's in a scalar context,
it returns the next line.  If it's in a list context, it slurps the whole
file.  Guess which one you've got?  :)

For a scalar context, say:

while ($line = <FILE>)

-- 
			     Mordechai T. Abzug
morty@umbc.edu            morty@sled.gsfc.nasa.gov     http://umbc.edu/~morty
>>>>> My employer isn't paying for my opinions, so they must be *mine*. <<<<<
A clean desk is a sign of a cluttered desk drawer. 


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

Date: Wed, 22 Oct 1997 16:45:44 -0700
From: Jason North <jason@enterpriselink.com>
Subject: Installing Perl
Message-Id: <344E9028.8ED66515@enterpriselink.com>

Does anyone know exactly where I can find some docs on installing the
perl intreptor and getting it fully functional on a web server (Netscape
Enterprise Server).

Please reply directly by email.

Thanks,
-zava



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

Date: Thu, 23 Oct 1997 10:22:49 +0100
From: "Martin Svanstrvm" <erac.eramsva@memo.ericsson.se>
Subject: Minimal match regular expression
Message-Id: <344F1769.665D99A@memo.ericsson.se>

Huuh....

I have a problem which I'm starting to get very annoyed with.
Let's see if I can explain it:

My variable $text contains a complete text file. It looks something like
this:
BLA BLA<title>BLA BLA text BLA BLA</title><title>BLA BLA BLA
BLA</title><title>BLA BLA  BLA text</title>  and so on.

I want to create a reg exp which searches for all <title>  </title>
enclosures which contains the string  "text" and print everything inside
the enclosure.
I've tried, on $text, something like:

while (s/<title>(.*?text.*?)<\/title>//) {
   print "$1\n";
    }

This, however, will find everything from the first found <title> to
"text", while I want it to find the <title> which is closest to "text"

Difficult to explain......

Does anyone have any ideas?

Thanks alot everyone,
Martin






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

Date: Thu, 23 Oct 1997 11:31:27 +0200
From: Christian Wetzel <cnwetzel@linguistik.uni-erlangen.de>
Subject: Re: Minimal match regular expression
Message-Id: <344F196F.6BF6@linguistik.uni-erlangen.de>

Martin Svanstr=F6m wrote:

> My variable $text contains a complete text file. It looks something lik=
e
> this:
> BLA BLA<title>BLA BLA text BLA BLA</title><title>BLA BLA BLA
> BLA</title><title>BLA BLA  BLA text</title>  and so on.
> =

> I want to create a reg exp which searches for all <title>  </title>
> enclosures which contains the string  "text" and print everything insid=
e
> the enclosure.
> I've tried, on $text, something like:
> =

> while (s/<title>(.*?text.*?)<\/title>//) {
>    print "$1\n";
>     }

I'm sure you didn't try on $text but on $_, right?

> This, however, will find everything from the first found <title> to
> "text", while I want it to find the <title> which is closest to "text"

If there are no other tags inside and no "text" outside a =

<title></title> group, you could use this:

  while (s/<title>([^<]*?text[^<]*?)<\/title>//) {
    print "$1\n";
  }

Better is this one:

  @titles =3D split ("title>");
  foreach $title (@titles) {
      print "$1\n" if ($title =3D~ s/^(.*text.*)<\/$//);
  }

The "</$" part of the condition tests whether the actual =

substring comes from _inside_ a <title></title> group.

Bye,
    Christian
-- =

  Keiner direkten Sonnenbestrahlung oder
  sonstigen Waermequellen aussetzen.


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

Date: Thu, 23 Oct 1997 12:31:56 +0200
From: Eike Grote <eike.grote@theo.phy.uni-bayreuth.de>
Subject: Re: Minimal match regular expression
Message-Id: <344F279C.41C6@theo.phy.uni-bayreuth.de>

Hi,

Martin Svanstrvm wrote:
> 
> My variable $text contains a complete text file. It looks something like
> this:
> BLA BLA<title>BLA BLA text BLA BLA</title><title>BLA BLA BLA
> BLA</title><title>BLA BLA  BLA text</title>  and so on.
> 
> I want to create a reg exp which searches for all <title>  </title>
> enclosures which contains the string  "text" and print everything inside
> the enclosure.

Try to do the pattern matching in two steps: first extract the
'<title>..</title>' and then check if it contains 'text':


   while (s/<title>(.*?)<\/title>//) {
       print "$&\n" if($1 =~ /^.*?text.*?$/);
   }

or maybe you prefer this one ...

   while (s/<title>(.*?)<\/title>//) {
       print "&`$&$'\n" if($1 =~ /text/);
   }



Bye, Eike
-- 
=======================================================================
>>--->>    Eike Grote  <eike.grote@theo.phy.uni-bayreuth.de>    <<---<<
-----------------------------------------------------------------------
 Home Page, Address, PGP,...:  http://www.phy.uni-bayreuth.de/~btpa25/
-----------------------------------------------------------------------
 PGP fingerprint:      1F F4 AB CF 1B 5F 4B 1D 75 A1 F9 C5 7B 3F 37 06
=======================================================================


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

Date: 23 Oct 1997 08:29:38 -0400
From: Matthew Rice <Matthew.Rice@ftlsol.com>
Subject: Re: Minimal match regular expression
Message-Id: <m34t68mzm5.fsf@hudson.ftlsol.com>

"Martin Svanstrvm" <erac.eramsva@memo.ericsson.se> writes:

> while (s/<title>(.*?text.*?)<\/title>//) {
>    print "$1\n";
>     }
> 
> This, however, will find everything from the first found <title> to
> "text", while I want it to find the <title> which is closest to "text"

I won't ask why you've got multiple <title>'s in your doc but...
Here's a start:

#!/usr/bin/perl -w

$_ = "ABC<title>hello</title>DEF<title>goodbye</title>GHI";

foreach (split "<title>") {
    next if not m/<\/title>/;  # Must have a matching </title>
    s/<\/title>.*//;
    print $_, "\n";
}

-- 
Matthew Rice                             e-mail: matthew.rice@ftlsol.com


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

Date: 23 Oct 1997 08:37:14 -0400
From: Matthew Rice <Matthew.Rice@ftlsol.com>
Subject: Re: Minimal match regular expression
Message-Id: <m33elsmz9h.fsf@hudson.ftlsol.com>

Matthew Rice <Matthew.Rice@ftlsol.com> writes:

> "Martin Svanstrvm" <erac.eramsva@memo.ericsson.se> writes:
> 
> > while (s/<title>(.*?text.*?)<\/title>//) {
> >    print "$1\n";
> >     }
> > 
> > This, however, will find everything from the first found <title> to
> > "text", while I want it to find the <title> which is closest to "text"
> 
> Here's a start:
> 
> #!/usr/bin/perl -w
> 
> $_ = "ABC<title>hello text</title>DEF<title>goodbye</title>GHI";
> 
> foreach (split "<title>") {
>     next if not m/<\/title>/;  # Must have a matching </title>
>     s/<\/title>.*//;
>     print $_, "\n";
> }

Sorry to answer my own post but I missed the part about matching
"text".  Just add a 'm/text/ or next;' line before you print.

Regards,
-- 
Matthew Rice                             e-mail: matthew.rice@ftlsol.com


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

Date: 23 Oct 1997 11:01:45 +0200
From: haroldkl@stack.nl (Harold Kloosterhof)
Subject: Re: Newbie Question : remove files named $files
Message-Id: <62n3pp$3o0@turtle.stack.nl>

faust@wwa.com (Faust Gertz) writes:

>On 22 Oct 1997 19:49:24 +0200, haroldkl@stack.nl (Harold Kloosterhof)
>wrote:

>>I want to remove all files in directory /www/dir1/
>>which which have '.blah.' in the name (this 'blah' I don't know,
>>that's what the perl script finds out)
>>Now I've got this string $files="/www/dir1/*.blah.*"
>>
>>I tried 
>>   unlink ($files)
>>and
>>   unlink (<$files>)
>>but that didn't do the trick. The camel does not help
>>me any further ...

>Yes, the camel and the manpages do help and if you read this
>newsgroup, you would have seen me answer a similar question yesterday.

That is true, but was _not_ the same question. I want to use a
variable named $files to delete some files.
I knew that 'unlink </www/dir1/*.blah.*>' would do the trick,
but that is not what I want, because the program figures out
the 'blah' thing, not me the programmer.

$dir="/www/dir1/";
$id="blah";
$namepart=".".$id."."; 
$files=$dir."*".$namepart."*";
unlink (<$files>)

does not work, but

$dir="/www/dir1/";
$id="blah";
$namepart=".".$id."."; 
unlink (<$dir*$namepart*>);

will do the trick.

Thanks for your help,

Harold

-----------------------+------------------------------------------------------
 Harold Kloosterhof    |  Units Conversion Page : www.stack.nl/~haroldkl/si/ 
 haroldkl@stack.nl     |  World News Index      : www.stack.nl/~haroldkl/
 +31-(0)70 - 311 3536  |
-----------------------+------------------------------------------------------



>I have no idea why you think this would work.  Think about the
>differences between a scalar and list context.  When you do, I think
>you will see that what you meant to write was:

>unlink <./www/dir1/*.blah.*>;

>If you still don't get it, look in the perlfunc manpage.

>:NAME 
>:
>:unlink - remove one link to a file 
>:
>:
>:
>:SYNOPSIS 
>:
>:unlink LIST 
>:
>:unlink 
>:
>:
>:
>:DESCRIPTION 
>:
>:Deletes a list of files. Returns the number of files successfully deleted. 
>:
>:    $cnt = unlink 'a', 'b', 'c';
>:    unlink @goners;
>:    unlink <*.bak>;
>:
>:Note: unlink will not delete directories unless you are superuser and the -U flag is supplied to Perl. Even if these conditions are
>:met, be warned that unlinking a directory can inflict damage on your filesystem. Use rmdir instead. 
>:
>:If LIST is omitted, uses $_. 

>If you still don't get it, try looking at the perldata manpage
>(Especially the 'Context' subsection).  If that doesn't do the trick,
>ask again.


>Streben nach Wahrheit

>Faust Gertz
>Philosopher at Large


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

Date: Thu, 23 Oct 1997 07:01:39 -0600
From: Dan McGuirk <mcguirk@indirect.com>
To: mcguirk@indirect.com,haroldkl@stack.nl
Subject: Re: Newbie Question : remove files named $files
Message-Id: <877607909.15383@dejanews.com>

In article <62n3pp$3o0@turtle.stack.nl>,
  haroldkl@stack.nl (Harold Kloosterhof) wrote:
> That is true, but was _not_ the same question. I want to use a
> variable named $files to delete some files.
> I knew that 'unlink </www/dir1/*.blah.*>' would do the trick,
> but that is not what I want, because the program figures out
> the 'blah' thing, not me the programmer.
>
> $dir="/www/dir1/";
> $id="blah";
> $namepart=".".$id.".";
> $files=$dir."*".$namepart."*";
> unlink (<$files>)
>
> does not work, but
>
> $dir="/www/dir1/";
> $id="blah";
> $namepart=".".$id.".";
> unlink (<$dir*$namepart*>);
>
> will do the trick.

The problem is that when you do "<$files>", perl thinks you're trying
to read from indirect filehandle "$files" instead of glob.  Instead
try:

	unlink glob($files);

(or even "unlink /${files}/;")

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 23 Oct 1997 09:51:36 GMT
From: "Robert Friberg" <robert.friberg@eductus-vast.com>
Subject: non-locking fileread
Message-Id: <01bcdf99$553d43c0$c82da8c0@akilles.ittek.org>

If i'm reading a file like this:

   open( FILE, "<$file" ) || die "Can't open $file";
   @slurp = <FILE>;
   close FILE;

and several instances of the script 
can be launched simultaneously, is file locking neccesary? 
Does it matter which OS the script is running under?

Would the following work or is it very stupid?

   for $try (1..5){
      $ok = true;
      last if open( FILE, "<$file" ); 
      $ok=false;
   }
   die "Sorry, but I gave it five tries.." unless $ok;

The size of the file is always < 2k,
the OS is either NT 3.51, NT4 or LINUX.
The perl version is either 4 or 5.
What might the failure procentage be at
a call rate of 10, 50 and 100 evenly distributed
calls per minute?

-- 
-robban

#######################################
#
#   Robert Friberg	
#   robert.friberg@eductus-vast.com
#
#######################################



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

Date: Thu, 23 Oct 1997 11:29:48 +0200
From: Doug Seay <seay@absyss.fr>
To: "Nathanael T. Brooks-English" <nenglish@geo.Arizona.EDU>
Subject: Re: OR v. Randal: Employees have no 1st Amendment Rights
Message-Id: <344F190C.37EB4588@absyss.fr>

[posted and mailed]
[followups trimmed]

Nathanael T. Brooks-English wrote:
> 
> To whom it may concern,
>         I was very interested to read the post concerning Mr. Randall.
> Please elaborate on the facts of the case as you know them.  Was he trying
> to crack a security network, or did he just write a report listing the
> weaknesses of the Intel Security.

IIRC there were two main issues
	- he ran crack on a computer that wasn't "his"
	- he had a personal gateway outside the firewall

Had either of these been blessed by the powers-that-be, no big deal.  He
had already been warned about this second issue by internal security,
but I think it was the first that ruffled everyone's feathers.  Randal
says he ran crack to show the poor level of internal security and thus
increase his chance of getting his contract renewed.  I don't think
anyone thinks Randal wears a black hat, but nearly everyone (Randal
included) agrees that this was a major misjudgment.

Go look at URL http://www.lightlink.com/spacenka/fors/ for more
information.  "fors" is "Friends of Randal Schwartz", so I don't know if
they are biased or not.  You'll need to read a bit and decide this for
yourself.

- doug


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

Date: 23 Oct 1997 06:23:46 GMT
From: john@leland.Stanford.EDU (John Thomas Mongan)
Subject: Polling console in Win32
Message-Id: <62mqhi$9fh$1@nntp.Stanford.EDU>

I want to read a character from the console, but not block if there's no
character available.  I need this so I can provide input to a program from
the keyboard, but have it continue to update its display even when it's
not getting input.

I think there are two problems to be surmounted: 1) turning off buffering
of STDIN 2) doing a non-blocking read.

The camel book mentions using stty to turn off buffering, but I can't find
an equivalent procedure for Win32.  I thought I might be able to use
select on the STDIN handle to see if it's ready for read, but under Win32
perl it seems to always return true.

Does anyone have any ideas on how I might be able to accomplish my
objective using Win32 perl?

Thanks,

John Mongan


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

Date: Thu, 23 Oct 1997 06:20:21 +0200
From: Xavier Tarafa Mercader <xavi@teclata.es>
Subject: Problems locking a file
Message-Id: <344ED083.AA4A168E@teclata.es>

I posted a similar question 15 days ago, but I didn't get the answer I
was looking for.

I've a  script which open a file (with exclusive lock) wait for ten
seconds and then close the file. The script also return to me the value
returned by flock function.


What I do is running the script twince in less than 10 seconds. So it
was suposed to the second time I run it to get an error value as a
return of flock function, but it doesn't  happen.

Here is the script, if someone can find what i'm doing wrong please
answer me.


#!/usr/bin/perl
$ENV{PATH} = '/usr/bin:/bin';

$LOCK_EX                                = 2;
$LOCK_UN                                = 8;
$trouble_email           = 'mail@adress;


#Open file

if(!(open(TABLE,">./test"))){
 print STDERR "Couldn't open Table: $table_content file.";
 exit(0);
}



#lock the file

$valor=flock(TABLE,$LOCK_EX);


#Get a mail with flock return value

open(OUT,"|mail $trouble_email");
print OUT "flock value is $valor";
close(OUT);

#Abort program if was not flocked
    if($valor == 0){
 print STDERR "Couldn't flock Table: $table_content file";
 exit(0);
    }

sleep(10);


#Close table
if(!close(TABLE)){
 print STDERR "Could not close Table: $table_content file";
 exit(0);
}






Xavier Tarafa
Teclata.




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

Date: 23 Oct 1997 10:32:07 GMT
From: periat@ens.ascom.ch (Periat Henri)
Subject: Q: stat() on Win32
Message-Id: <62n937$rmh@ascomax.hasler.ascom.ch>

Hi everybody

Can someone explain me what i get from the funxtion 'stat()' on
a 'Windows NT' and a 'Windows 95' system?


Thanks
Henri



-- 
-----------------------------------------------------------------------
Henri Periat				Phone:	0041 32 624 35 78
Ascom Business Systems AG		E-Mail:	periat@ens.ascom.ch
Dep. 3578				Fax:	0041 32 624 31 56
Ziegelmattstr. 1
CH-4503 Solothurn
Switzerland
-----------------------------------------------------------------------




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

Date: Thu, 23 Oct 1997 10:52:21 +0200
From: Roar Andre Lauritzsen <roarl@metaphor.no>
Subject: Regexp optimizing
Message-Id: <344F1045.41C6@metaphor.no>

I made a small program for searching through our 6MB of C source code
for the definition of a specific identifier. When I expanded the regexp
to search for macro definitions as well, the program got very slow. Then
I found out that by splitting the regexp the program became efficient
again.

Question: Why is
  /^([(\w][()*\w\s]*[)*\s])?$id\s*([(;=]|$)/o || /^#define\s*$id\b/o
10 times faster than
  /^(([(\w][()*\w\s]*[)*\s])?$id\s*([(;=]|$))|(#define\s*$id\b)/o
???

Perl version is 5.001
The whole program:

$id = shift @ARGV;
@fs = <*.c *.h>;
for $f (@fs) {
    open F,$f or die "Cannot open file $f\n";
    (/^([(\w][()*\w\s]*[)*\s])?$id\s*([(;=]|$)/o || /^#define\s*$id\b/o)
        && print "$f:$.: $_" while (<F>);
    close F;
}

-- 
Roar Lauritzsen (http://www.metaphor.no/staff/roar.html)
Metaphor Systems AS (http://www.metaphor.no)
"Time is an illusion, lunchtime doubly so" -DA


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

Date: 23 Oct 1997 09:06:19 GMT
From: mheins@prairienet.org (Mike Heins)
Subject: Re: Regexp optimizing
Message-Id: <62n42b$jmc$1@vixen.cso.uiuc.edu>

Roar Andre Lauritzsen (roarl@metaphor.no) wrote:
: I made a small program for searching through our 6MB of C source code
: for the definition of a specific identifier. When I expanded the regexp
: to search for macro definitions as well, the program got very slow. Then
: I found out that by splitting the regexp the program became efficient
: again.
: 
: Question: Why is
:   /^([(\w][()*\w\s]*[)*\s])?$id\s*([(;=]|$)/o || /^#define\s*$id\b/o
: 10 times faster than
:   /^(([(\w][()*\w\s]*[)*\s])?$id\s*([(;=]|$))|(#define\s*$id\b)/o
: ???

Less copying during the pattern match (2 less paren sets) and
the efficient anchoring of the opening strings ^[\w(] and ^#define.

The latter allows Perl to optimize and quickly find places where
the regex might match, while the alternation operator doesn't
allow that optimization.

Read Friedl's book "Mastering Regular Expressions", Chapter 7, 
to find out more.

-- 
Regards,
Mike Heins

This post reflects the
opinion of my employer.


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

Date: Thu, 23 Oct 1997 09:47:32 +0200
From: Martin <techno@pedal.se>
Subject: Strange error with close()
Message-Id: <344F0113.38986DEB@pedal.se>

I made a script for generating a HTML-page with information brought back
by a query sent to an SQL-server via ODBC.
It works just fine, all the information i requested gets exactly where I
wanted it.....
But after sending the SQL-query I want to close the connection to the
database and Perl returns an errorcode. I have included some of the code
below:

use win32::ODBC;

$DSN = "budwin2";
$db = new Win32::ODBC($DSN);

$db->Sql("SELECT payer_nr, dropped, price, date, reference, worknr,
from_name, to_name
FROM bud WHERE
payer_nr='$data{'customer'}' AND date>='$data{'fdate'}' AND
datum<='$data{todate}' AND status=0
AND worknr='$data{worknr}'");

    # Ok, this shhould work without a problem, and it does.....but
during the output (below) I get a strange error, appearing
    # at different positions every time, about a "call to undefined
function......." And I have NOT called the function mentioned.

while($db->FetchRow())
{
      @values = $db->Data;
 $price = $db->Data("price");
 $payer = $db->Data("payer_nr");
 $date = $db->Data("date");
 $reference = $db->Data("reference");
 $worknr = $db->Data("worknr");
 $from = $db->Data("fran_namn");
 $to = $db->Data("till_namn");
 $dropped = $db->Data("dropped");
 @justDate = split(/ /, $date);
 @price2 = split(/.000/,$price);

print "<tr> <td><font size=2>$justDate[0]</td>
  <td><font size=2>$to</td>
  <td><font size=2>$from</td>
  <td><font size=2>$reference</td>
  <td><font size=2>$worknr</td>
  <td><font size=2>$price2[0]</td>
  <td align=right><font size=2>$dropped</td></tr>";
}

print "</table></html>";

# It seemes to be the line below causing all the trouble... Am I using
it wrong? What happens if I remove it?
$db->close();




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

Date: Wed, 22 Oct 1997 21:17:52 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Un-require lib files
Message-Id: <EIH1tt.J8u@bcstec.ca.boeing.com>

In article <344CFED8.5437@us.oracle.com>,
Allen Choy  <achoy@us.oracle.com> wrote:
 > Anyone know of a way to undo a previous require statement?
 >

Erasing your main package's memory of the 'required' package's
variables is probably the best you could do, e.g,

while ( ($var, $glob_value) = each %{"${packagename}::"} ) {
    *alias = $glob_value;
    undef $alias; undef %alias; undef @alias;
 }


Take a look at pg. 95-96 (Accessing the Symbol Table) in
Advanced Perl Programming by Sriram Srinivasan. There's
a really good discussion of variable storage and symbol 
tables. 


HTH,
--
Charles DeRykus


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

Date: Thu, 23 Oct 1997 12:12:19 GMT
From: ivkovic@compuserve.com (Milivoj Ivkovic)
Subject: Use perl from Visual Basic
Message-Id: <344f3d56.25072933@news.compuserve.com>

May sound like a heresy, but:
I would like to benefit from some perl advantages in MS apps where I
have to use VBA code.
So, I would like to be able to include perl code into VBA code. I
don't know if/how I can call the PerlIIS.dll from VB and get the
return values.
Or, if I shell to perl.exe executing a script, how do I send things
from VB to <STDIN> of the perl script, and how do I get back in VB
what perl prints to <STDOUT>?

Thank you for any help...

Milivoj


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

Date: Wed, 22 Oct 1997 22:59:08 -0700
From: Joe Jones <sdwb@earthlink.net>
Subject: Wanted Perl Programmer to set Up database
Message-Id: <344EE7AC.780F@earthlink.net>

I need a programmer to develop perl code for Singles Website.
Complete automation is required to allow members and potential members
to post their biography information and make updates and changes.
Only paid members to be allowed access to other members email address.
System must allow potential members to browse but not see email address.
Also require search by state, sex, age, sex preference.  Would like to
add capability to match potential mates based upon values and likes &
dislikes.

I have developed a statement of work that roughly outlines what will be
required.
I need coding complete and site operational in the next 4 weeks.

Joe (Long Beach, California)


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

Date: Wed, 22 Oct 1997 23:13:48 -0700
From: Joe Jones <sdwb@earthlink.net>
Subject: What School Best for Perl & Programming
Message-Id: <344EEB1C.113F@earthlink.net>

Would like to go back to school to obtain a computer programming degree.
What is best school in Southern California area, ie., LA, Orange County,
Long Beach, area.
Current Interest in Perl.
Joe


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 1218
**************************************

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