Thanks to Sudarshan and John,
for the suggestions.
Very much appreciated!
Rgds
Denham
DISCLAIMER
This message is for the named person's use only. It may contain confidential,
proprietary or legally priv
>> The main problem appears to be that instead of taking a different
>> branch
>> if open() or flock() fails you continue on as if they had succeeded.
flock($fh,LOCK_EX ) is a blocking call, so it won't return until the
lock is available.
// George Schlossnagle
// Principal Consultant
// Omni
"John W. Krahn" wrote:
>
> Jeff wrote:
> >
> > From: John W. Krahn [mailto:[EMAIL PROTECTED]]
> > >
> > > Jeff wrote:
> > > >
> > > > I'm use flat files to manage a list containing approx 25,000 records. For
> > > > updates, I write to a temp file then unlink main and rename temp file to
> > > >
Jeff wrote:
>
> From: John W. Krahn [mailto:[EMAIL PROTECTED]]
> >
> > Jeff wrote:
> > >
> > > I'm use flat files to manage a list containing approx 25,000 records. For
> > > updates, I write to a temp file then unlink main and rename temp file to
> > > main. I use flock for both temp and main
You have a race condition due to your flock being cancelled when you
close the file.
A open IN
A flock IN
A open OUT (truncates $tmp_db)
A while loop
B blocks
A close IN
B open IN
A close OUT
B open OUT (truncates $tmp_db)
A unlinks main_db
A tries to move $tmp_db to $main_bd, but $tmp_db is emp
John,
unix,
sub Update_db {
$main_db = $_[0];
$tmp_db = $_[1];
$update = $_[2];
open IN, "<$main_db" or print "Can't open $main_db: $!\n";
flock( IN, LOCK_EX ) or print "Unable to acquire lock: $!. Aborting";
open OUT, ">$tmp_db" or print "Can't open temporary file $tmp_db: $!\n";
Jeff wrote:
>
> I'm use flat files to manage a list containing approx 25,000 records. For
> updates, I write to a temp file then unlink main and rename temp file to
> main. I use flock for both temp and main files during update. My main file
> gets blown away on occasions. What gives? I can'
I'm use flat files to manage a list containing approx 25,000 records. For
updates, I write to a temp file then unlink main and rename temp file to
main. I use flock for both temp and main files during update. My main file
gets blown away on occasions. What gives? I can't figure out why this
h
On Wed, 2002-07-17 at 19:02, drieux wrote:
>
> On Wednesday, July 17, 2002, at 03:21 , Chas Owens wrote:
> [..]
> > however Inline::C is not always available,
> [..]
>
> http://search.cpan.org/search?dist=Inline
>
> yes from the Readme it notes:
>
> "Inline saves you from the hassle of hav
On Wednesday, July 17, 2002, at 03:21 , Chas Owens wrote:
[..]
> however Inline::C is not always available,
[..]
http://search.cpan.org/search?dist=Inline
yes from the Readme it notes:
"Inline saves you from the hassle of having to write and compile your own
glue code using facilities lik
> Ok, it's a slow day, I'll bite at that. Try as I might. I can't make
> your sort beat my map-based linear search.
Well, forcing the sort to copy the entire array isn't exactly fair.
The proper way to write the sort based max is
my $max = (sort { $a <=> $b } @array)[-1];
This keeps Perl
Ooops.. is this problem still not yet solved ?! :-(
Hmmm. I don't know if this is OT of not, but seems that would
be a problem for Win32 beginners need to deal with
If a dosprompt is too difficult to deal with, let's return to the idea
of using "double click".
You'll say, the scre
From: Wiggins d'Anconia <[EMAIL PROTECTED]>
> Possibly time to step in here and suggest XML rather than creating
> some new or using some pre-existing config file standard. I am not an
> XML zealot, in fact I have been rather resistant to it for a while,
> but this sounds like opportunity knocki
Hi -
A quick look at perldoc perlcc shows that you must perlcc Pg.pm (or
whatever .pm Pg is in) to create a "shared object" that can be used by your
main program. (NB: the doc states that shared objects are not available for
Win32).
Also - perlcc is quite expermental - be careful!
Denham Eva wrote:
>
> Hello listers,
Hello,
> I would like to submit a script I have written and it does work. However I
> am sure that it can be:
> a. Shorter
> b. Faster
> As you will see it is not very well written. Certainly nothing compared to
> some of the listers code I have seen here.
>
Ok thanks,
Got it working As silly of me as this was, I accidentally had the code
inside a if statement that was returning false :-)
My bad...
--
me
- Original Message -
From: "Chris Knipe" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 17, 2002 10:38 PM
Subject
I got it working on the shell now:
savage@netsonic:~/src# perl -MIPC::Open2 -e'open2(*rd, *wr, "/bin/ls -al");
while () { print; } exit;'
total 32
drwxr-x--- 8 root wheel512 Jul 17 03:29 .
drwxr-xr-x 8 root wheel512 Jul 16 05:38 ..
-rwxr-x--- 1 root wheel 21955 Jul 17 22:36 Apache
> -Original Message-
> From: Chris Knipe [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, July 17, 2002 4:19 PM
> To: [EMAIL PROTECTED]
> Subject: Re: executing binaries
>
>
> I had a look
>
> The documentation is *very* lacking.
>
> savage@netsonic:~/src# perl -MIPC::Open2 -e'ope
On 2002-07-16 12:22:45 -0700, drieux wrote:
> Or are you folks just DEMONS in PerlieCoderCloth,
> trying to lead the innocent into Perdition
Perldition? };-)
--
Morten Liebach <[EMAIL PROTECTED]>, webpages at http://kallisti.dk/
PGP-key: http://kallisti.dk/
Chris Knipe wrote:
> savage@netsonic:~/src# perl -MIPC::Open2 -e'open2($rd, $wr, "ls -al");
while
> (<$rd>) { print; } exit;'
> open2: wtr should not be null at -e line 1
It may have to do with the fact that you can't write to ls...the following
worked for me
use IPC::Open2;
use strict;
my ($rd
James Campbell wrote:
>
> Hi Everyone
Hello,
> I'm having a spot of bother with a query string.
>
> The program below attempts to mimic a web form. It should post the value of
> 'QUERY ..' to the cgi in $location.
>
> What is actually happening is that 'QUERY ..' itself is being sent as the
>
I had a look
The documentation is *very* lacking.
savage@netsonic:~/src# perl -MIPC::Open2 -e'open2($rd, $wr, "ls -al"); while
(<$rd>) { print; } exit;'
open2: wtr should not be null at -e line 1
Needless to say, I am *totally* clueless :(((
- Original Message -
From: "Tan
> -Original Message-
> From: Maureen E Fischer [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, July 17, 2002 2:37 PM
> To: [EMAIL PROTECTED]
> Subject: exec statement
>
>
> Hello,
> I am trying to go to a script from within a script. This is
> a Perl CGI
> script and I want to transfer t
Dear,
I've tried to compile my code source with perlcc, but it has returned errors at the
time of compilation.
I've used the command line "use Pg;" and I think this is the problem, because if I
remove this line the compilation gets success.
The error returned at the time of compilation is:
Thanks a million...
I'll give the module a read or two or ten :p)
Regards,
Chris Knipe
Cell: (072) 434-7582
MegaLAN Corporate Networking Services
- Original Message -
From: "Tanton Gibbs" <[EMAIL PROTECTED]>
To: "Chris Knipe" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, Ju
I may have missed something in the discussion as to the ultimate goal,
but what about doing the sorting at the DB level, as this would
seemingly make your code more readable and the DB is likely faster at
this than Perl (as wonderful as it is).
Or was the original intent to sort the keys of th
Possibly time to step in here and suggest XML rather than creating some
new or using some pre-existing config file standard. I am not an XML
zealot, in fact I have been rather resistant to it for a while, but this
sounds like opportunity knocking for it.
That way "coming up with parsing algori
The Perl Cookbook recipie 16.8 says
use the standard IPC::Open2 module:
use IPC::Open2;
open2(*README, *WRITEME, $program);
print WRITEME "Here's your input\n";
$output = ;
close(WRITEME);
close(README);
However, it warns that there could be problems if the other program buffers
input or output
Lo all,
What's the best way to execute a binary command from within perl, and read
text returned by the binary, as well as write data to certain prompts that
the program may have?
Say, I have...
#>./myprogram
This is my program, I will ask you a question now
Please give me your name: WHATEVER
Hello,
I am trying to go to a script from within a script. This is a Perl CGI
script and I want to transfer to various other perl cgi scripts based on
user selections. From what I read I want to use exec for this -- since
I want to leave and not return to the transferring script. The
trasferrin
From: "Dan Fish" <[EMAIL PROTECTED]>
> Okay... maybe this is just so simple that I can't see the forest
> through the trees, but I've never had a need to do it before and so
> that inherently makes it difficult :-)
>
> I've got a script that runs gnuplot via system(). In order to use a
> custom
kinda like this?
system(qq/export FIT_LOG="check toilet"; gnuplot -some options/);
> -Original Message-
> From: Dan Fish [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, July 17, 2002 1:27 PM
> To: Perl List
> Subject: Setting environment variable for process spawned
> with system()
>
>
I'm not sure about in Perl, but you can usually do it on the command line
(depending on shell).
For example, if you use the bash shell, you can say in
your perl script
system( "FIT_LOG=value gnuplot args" );
Tanton
- Original Message -
From: "Dan Fish" <[EMAIL PROTECTED]>
To: "Perl List
Okay... maybe this is just so simple that I can't see the forest through the
trees, but I've never had a need to do it before and so that inherently
makes it difficult :-)
I've got a script that runs gnuplot via system(). In order to use a custom
path for gnuplot's "fit" regression function, It
On Jul 17, Michael D. Risser said:
>Can anyone tell me what the escape sequence for the field seprator (^])
>is, or point me to where I can find it? Basically I need to do a split
>on it to parse some records.
On the offchance that you REALLY do need ^], you can get the character in
Perl via:
On Jul 17, Michael D. Risser said:
>Can anyone tell me what the escape sequence for the field seprator (^])
>is, or point me to where I can find it? Basically I need to do a split
>on it to parse some records.
The default field separator is ^\, not ^]. Perl stores that value in the
$; variable.
Can anyone tell me what the escape sequence for the field seprator (^])
is, or point me to where I can find it? Basically I need to do a split
on it to parse some records.
TIA
--
Michael D. Risser
Software Engineer/Linux Administrator
=
Machine Vision Products, Inc.
w
On Jul 17, Jilani, Mohammad K said:
>How can I generate a whole number betwee 10 - 99?
Well, using int(rand(10)) gives you an integer from 0 to 9. If you add 10
to it, you get an integer from 10 to 19.
To get an integer from 10 to 99, you need to come up with an expression of
the form
X + i
you for got the int.. he said whole numbers
my $rand_num = int(rand(90) + 10);
> -Original Message-
> From: drieux [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, July 17, 2002 12:25 PM
> To: begin begin
> Subject: Re: Random generator
>
>
>
> On Wednesday, July 17, 2002, at 09:15 , Jil
Use double quotes ( " ) for surrounding, instead of apostrophy ( ' ). Thus
it will interpret it and not translate it litterally.
--
Best Wishes,
Yasen Petrov
ICQ 163 671 835
"James Campbell" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi Everyone
>
> I'm
On Wednesday, July 17, 2002, at 09:15 , Jilani, Mohammad K wrote:
> How can I generate a whole number betwee 10 - 99?
>
perldoc -f rand
and then tweek it
since rand runs from 0 you might try say
my $rand_num = rand(90) + 10;
ciao
drieux
---
--
To unsubscribe, e-mail: [EMAIL PR
On Wednesday, July 17, 2002, at 09:14 , Konrad Foerstner wrote:
[..]
> short example with 3-letter-lines:
>
> $input = 'ABCDEFGHI';
>
> ---> $output = 'ABCDEFGHI'
what you will want to look at are
perldoc CGI
perldoc HTML::Parser
for access to the p() function/method.
The res
On Jul 17, Konrad Foerstner said:
>does anyone know a function or a module which
>i can use to format a text which i get in a string.
Text::Format comes to mind.
>short example with 3-letter-lines:
>
>$input = 'ABCDEFGHI';
>
>---> $output = 'ABCDEFGHI'
This is a very simple case:
$len = 3;
> -Original Message-
> From: Dan Finch [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, July 17, 2002 12:03 PM
> To: [EMAIL PROTECTED]
> Subject: Pattern Matching
>
>
> I'm working on a script that I need to use some pattern
> matching in. I've
> got a couple books that I have been readin
How can I generate a whole number betwee 10 - 99?
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
This message is intended only for the personal and confidential use of
hi,
does anyone know a function or a module which
i can use to format a text which i get in a string.
i would like to get out of the string lines of 40 letters
which are surrounded by "" and ; the
result should be stored in an string.
short example with 3-letter-lines:
$input = 'ABCDEFGHI';
Here is one way:
/(n=[^']*)/;
which says find a n= and then everything up to the next '
You probably want to wrap in if statement so if not a hit, then can
do something.
Wags
-Original Message-
From: Dan Finch [mailto:[EMAIL PROTECTED]]
Sent: We
hi,
does anyone know a function or a module which
i can use to format a text which i get in a string.
i would like to get out of the string lines of 40 letters
which are surrounded by "" and ; the
result should be stored in an string.
short example with 3-letter-lines:
$input = 'ABCDEFGHI';
Hi,
I am building a wrapper between some Perl code and C library. I am using XS
for this.
I want to compile the wrapper as a Shared Lib that is dynamically loaded by
perl.
Today I compile a Shared Lib statically linked to the C library (I link with
the "C Lib".asl) in one big Shared Lib.
I'm working on a script that I need to use some pattern matching in. I've
got a couple books that I have been reading about it and thought I knew how
to seach for what I'm after but its just not working.
Here is a test script I've been playing with to get this working. I want to
be able to pars
On Wednesday, July 17, 2002, at 08:16 , Kevin Old wrote:
> Name "main::opt_C" used only once: possible typo at ./cdma.pl line 42.
[..]
> Use of uninitialized value in numeric eq (==) at ./cdma.pl line 42.
>
> 1) How do I "fix" lines that say "used only once" or possible typo?
> Maybe at this poi
On Jul 17, Kevin Old said:
>Name "main::opt_C" used only once: possible typo at ./cdma.pl line 42.
>Name "main::mar_cdl_format" used only once: possible typo at ./cdma.pl
>line 64.
>Name "main::daily" used only once: possible typo at ./cdma.pl line 46.
>Name "CDMAConfig::PDF_FILE_PATH" used only
Hello all,
Well, I have yet another question. I have started turning on warnings
in my scripts, and get something like the following output when running
my script.
Name "main::opt_C" used only once: possible typo at ./cdma.pl line 42.
Name "main::mar_cdl_format" used only once: possible typo at
On Jul 17, Faymon, Kurt said:
>We are currently moving from Omnimark to PERL so I guess it's time to learn
>some PERL. Giving the following scenario, I am wondering if PERL can cope
>with the following scenario and, if so, what would the code look like:
Oh wow. I'm truly astonished. Omnimark,
Hola,
someone has used the module Term::ReadPassword with the module use
Term::ANSIScreen ???
When i call the "cls" (clear screen) function of ANSI module before of
"read_password" of ReadPassword module, the "cls" function don't work.
Ex.
sub read{
cls;
$pass=read_password;
}
##don'
On Jul 17, Ho, Tony said:
> $sth->bind_param(1, @$_->[0]);
You've already fixed your problem, so that's good, but I would use
$sth->bind_param(1, $_->[0]);
instead of
$sth->bind_param(1, @$_->[0]);
Yours works by some bizarre coincidence of Perl's parsing. It should be
considere
>
Which one is the more preferred : perl2exe or perlapp (Active state Perl Development
Kit). I have not done much with perlapp and I did run into small problem using
perl2exe. Just wanted to know their merits.
Thanks
Shishir
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands,
Hi Everyone
I'm having a spot of bother with a query string.
The program below attempts to mimic a web form. It should post the value of
'QUERY ..' to the cgi in $location.
What is actually happening is that 'QUERY ..' itself is being sent as the
value. I copied the name 'QUERY ..' from the tex
On Tuesday, July 16, 2002, at 08:18 , Parag Dhake wrote:
[..]
>I'm new to this mailing list (and to the world of Perl, as well) Would
> appreciate if you can suggest me some good books on "Network programming
> in Perl".
It all sorta depends on where you are jumping off the cliff.
One can
Hello listers,
I would like to submit a script I have written and it does work. However I
am sure that it can be:
a. Shorter
b. Faster
As you will see it is not very well written. Certainly nothing compared to
some of the listers code I have seen here.
I am new at perl so here goes. Some of you
Greetings,
We are currently moving from Omnimark to PERL so I guess it's time to learn
some PERL. Giving the following scenario, I am wondering if PERL can cope
with the following scenario and, if so, what would the code look like:
Input Text:
Text of article...
And it says in Documents 1,2,3 an
> I have tried numerous variations of this simple script:
>
> print ("hello\n");
>
> perl -e "print qq~Hello\n~"
>
> C:\> perl
> print "Hello\n"; then press 'controll Z'
>
>
> print "hello";
>
> and press 'control C'
>
You have to enter CTRL+Z and ENTER on an empty line:
C:\> per
Chas, et al --
...and then Chas Owens said...
%
% On Tue, 2002-07-16 at 08:25, David T-G wrote:
...
% > program, though, I'd like even more to be able to define a *prefix* for
% > the original file so that instead of file.bak I have .#file after an edit
...
%
%
% If the extension d
Hi Guys
I have just resolved the problem.
The problem was the array variable "array_given" in the subroutine.
I replaced :
my @array_given = $_[0];
with
my @array_given = @_;
It works fine.
Thanks for the help.
Tony
> -Original Message-
> From: Ho, Tony
> Sent: Wednesday,
Many thanks!!!
Shawn wrote:
>Hello,
>
>- Original Message -
>From: "Francesco Guglielmo" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Wednesday, July 17, 2002 4:35 AM
>Subject: # question
>
>
>>($uno,$due,$tre,$quattro,$cinque,$sei) = split (/\s+/);
>>s/\#//;
>>
>
>You probably w
Hello,
- Original Message -
From: "Francesco Guglielmo" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 17, 2002 4:35 AM
Subject: # question
> ($uno,$due,$tre,$quattro,$cinque,$sei) = split (/\s+/);
> s/\#//;
You probably want to write:
$sei=~s/\#//;
Shawn
> prin
Hi Guys
I was wondering if you could help me.
I have a multi-dimensional array and I would like to pass it to a subroutine
as follows :
my @multi_array = ([1,2,3,4], [5,6,7,8]);
my @result = process_array(@multi_array);
print "The result is : @result\n";
sub process_array {
my @array_pro
($uno,$due,$tre,$quattro,$cinque,$sei) = split (/\s+/);
s/\#//;
print $sei;
Is it right to have $sei without #?
thanks
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
O.K. - I run Perl on win2k - screen dumps follow:
C:\>PATH
PATH=C:\Perl\bin\;C:\Tcl\bin;..
C:\>perl -e "print qq~Hello\n~"
Hello
C:\>perl
print "hello\n"
hello
^C
C:\>
So, Perl works.
Now, I have some scripts (one of which is called 'example.pl' - the one from
the start of 'Learning Perl'
Lance wrote:
>
> Are you looking for how many elements the array has? If so:
>
> $lastElement = $#array;
That does NOT give you the number of elements in an array. That gives
you the index of the last element in the array.
$ perl -le'
@array = qw/ a b c d e f /;
print q(The number of element
I just tried it, and it does not work for me either. I too run on win2k.
I have always just put the code in a file or a module and executed it that
way. At least if you save them you will have a record of your progress.
"Cory" <[EMAIL PROTECTED]> wrote in message
001c01c22d40$b4107710$7c33aa18@
Are you looking for how many elements the array has? If so:
$lastElement = $#array;
"Konrad Foerstner" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>
> sorry a small but important mistake
>
> Im looking for a method to extract the
> biggest element (number)
[EMAIL PROTECTED] (Nikola Janceski) writes:
>
>
> The first element is a filehandle (or reference to one) and once the
> filehandle is closed the element is now uninitialized.
The filehandle is closed in DESTORY of the package, so could happen
till untie is called or the array goes out of sc
please see perl -V output:
Summary of my perl5 (revision 5.0 version 6 subversion
1) configuration:
Platform:
osname=linux, osvers=2.4.7-10,
archname=i686-linux-thread
uname='linux linux72 2.4.7-10 #1 thu sep 6
17:27:27 edt 2001 i686 unknown '
config_args='-Dusethreads -Duse5005thre
75 matches
Mail list logo