Re: Creating hash with multiple keys for an array

2004-08-06 Thread Edward WIJAYA
Thanks so much for your reply Gunnar,
The purpose is as follows.
For example these lines:
AGCAG,AGCCG,AGCCGGGCG,AGCCAGGAG 15.188721875540
AGCGGAGCG,AGCCGAGGG,AGCGGAGGG   16.163408331891
\_/ \_/
  @Array1   $Key1
Is that an array with 7 elements?
No. They are 2 arrays each with 4 elemeents and 3 elements.
For this I want to store them in hash of array.
What do you mean by the scalar variable $Key1 that points to 2
numbers?
What I mean by scalar of variable is : $Key2=scalar(@Array1)
i.e the number of elements of that array.
So $Key2 for line1 = 4,
and $Key2 for line2 = 3
I want to sort the hash based on this value as well as $Key1.
I am sorry for my unclear statement previously.

Can you try to explain again what it is you want to know?
Am I doing the right thing by using hash with multiple keys
for sorting purpose?
Regards
Edward WIJAYA
SINGAPORE
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



iterate over the fields of a struct?

2004-08-06 Thread Christopher J. Bottaro
is there a way to iterate over the fields of a Class::Struct (in the order
they were declared)?

something like:

foreach my $i (@{my_struct->fields()})  {
print "$i = my_struct->value($i)\n";
}

yeah i know its a long shot, but perl sometimes does things for me that i
never would have believed...much less knew to expect...;)

also, i know you can do this with hashes (although in "random" order, unless
you sort the keys), but hashes are too error prone for my liking.  i.e.
$my_hash{TYPO} = $blah; does not result in an error...=(

thanks.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: using regexp to substitute - problem

2004-08-06 Thread Radhika Sambamurti
>
> You probably want to use the word boundary assertion:
>
>  s/\bTR\b/TC/g;
>
> See "perldoc perlre".
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl

Thanks! This worked.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: using regexp to substitute - problem

2004-08-06 Thread Gunnar Hjalmarsson
Radhika Sambamurti wrote:
I am trying to substitute "TR" for "TC".
But I do not want words like "AUDIT TRAIL" to be substituted.
So my regexp is:
if( =~ / TR / ) {
s/TR/TC/g
}
But this is not exactly working.
You probably want to use the word boundary assertion:
s/\bTR\b/TC/g;
See "perldoc perlre".
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



using regexp to substitute - problem

2004-08-06 Thread Radhika Sambamurti
Hi,
I am trying to substitute "TR" for "TC".
But I do not want words like "AUDIT TRAIL" to be substituted.

So my regexp is:

if( =~ / TR / ) {
s/TR/TC/g
}
But this is not exactly working.

As i want only those instances when TR is surrounded by spaces ie not part
of any other word to be substituted. The sample file i want to make the
changes in is below:

if ($_ eq $AUDIT_TRAIL_FIELD)
  my $doc = "TR" . $pr . "Doc";
  mark_urls($q->escapeHTML($fields{$AUDIT_TRAIL_FIELD})),
  my $page = "Edit TR $pr";
error_page("You must specify a TR number");
   Clone this TR for other release ";
print "Edit TR: $pr";
if ( $default =~ /\s/ ) # we got multiple releases TR
my $doc = "TR" . $pr . "Doc";
if ( confirm ("State was changed to
feedback, but Responsible was not
re-assigned.\\n Click Cancel to re-assign
Responsible, click OK to submit TR as
is.\\n") )
  mark_urls($q->escapeHTML($fields{$AUDIT_TRAIL_FIELD})),
  my $page = 'Edit TR Results';
error_page("You must specify a TR number");
  print "debugging -- TR edits not submitted";
  error_page("Sorry, TR $pr has been modified since you started
editing it.",
'or "TR\'s", not "bugs".');

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Using binding in order to pass values to a sql statement.

2004-08-06 Thread NYIMI Jose \(BMB\)


> -Original Message-
> From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] 
> Sent: Friday, August 06, 2004 6:09 PM
> To: jason corbett; perl beginners
> Subject: Re: Using binding in order to pass values to a sql statement.
> 
> 
> > 
> > Hello all. I am trying to use bind_param to create a list 
> of values in
> the form of an array. Then I want to query the data base 
> using a basic sql statement where each value in my list 
> (array) will be sent to the DBI in order to return a value. I 
> am getting and error that says can't call method "bind_param" 
> on defined value at line *&&. Here in the subroutine that 
> will attempt to do this.
> >  
> >  
> >  
> > sub kill_porq{
> > my @banlist=qw(
> > 222497190
> 
> > 222800122
> > );
> >  my $ban='';
> >  foreach $ban (@banlist){
> >  
> >  
> >  $sth->bind_param (1, "$ban");
> 
> Normally you would prepare the statement once, since it 
> doesn't change. If you prepare it each time through the loop 
> you lose the efficiency gain. So move the prepare before the foreach.
> 
> That will also solve the scoping problem you have, are you 
> using 'strict'?  $sth in the above line should not yet be 
> defined. You should have,
> 
> my $sth;
> 
> Inside the loop, this would help you see the issue.
> 
> > 
> >  
> >  $sth=$dbh->prepare("select request_no, ban, request_sts, 
> status_act,
> NPAC_Process_ind, external_req_no
> >   from vstappo.port_request
> >where ban = ?
> >  ");
> >  
> >  
> >  $sth->execute();
> >
> 
> You can also call execute with your bind params in the call, 
> so that you only need to make one method call, so,
> 
> $sth->execute($ban);
> 
> Should be sufficient without the 'bind_param' call at all.
>   
> Of course you aren't doing anything with $sth here?  And you 
> will need to store your result set as each execute on the 
> $sth will clear the previous one (I believe).
> 
> Alternatively you could build a "better" statement using the 
> $ban list and pass all of it to the database at once to get 
> all of the data in a single execute.
> 
> > return;
> > }
> > 
> > 
> 
> HTH,

You all right Wiggins ...
Prepare once and execute everywhere :-)


José.


 DISCLAIMER 

"This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Using binding in order to pass values to a sql statement.

2004-08-06 Thread Wiggins d Anconia
> 
> Hello all. I am trying to use bind_param to create a list of values in
the form of an array. Then I want to query the data base using a basic
sql statement where each value in my list (array) will be sent to the
DBI in order to return a value. I am getting and error that says can't
call method "bind_param" on defined value at line *&&. Here in the
subroutine that will attempt to do this.
>  
>  
>  
> sub kill_porq{
> my @banlist=qw(
> 222497190

> 222800122
> );
>  my $ban='';
>  foreach $ban (@banlist){
>  
>  
>  $sth->bind_param (1, "$ban");

Normally you would prepare the statement once, since it doesn't change.
If you prepare it each time through the loop you lose the efficiency
gain. So move the prepare before the foreach.

That will also solve the scoping problem you have, are you using
'strict'?  $sth in the above line should not yet be defined. You should
have,

my $sth;

Inside the loop, this would help you see the issue.

> 
>  
>  $sth=$dbh->prepare("select request_no, ban, request_sts, status_act,
NPAC_Process_ind, external_req_no
>   from vstappo.port_request
>where ban = ?
>  ");
>  
>  
>  $sth->execute();
>

You can also call execute with your bind params in the call, so that you
only need to make one method call, so,

$sth->execute($ban);

Should be sufficient without the 'bind_param' call at all.
  
Of course you aren't doing anything with $sth here?  And you will need
to store your result set as each execute on the $sth will clear the
previous one (I believe).

Alternatively you could build a "better" statement using the $ban list
and pass all of it to the database at once to get all of the data in a
single execute.

> return;
> }
> 
> 

HTH,

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Using binding in order to pass values to a sql statement.

2004-08-06 Thread NYIMI Jose \(BMB\)


> -Original Message-
> From: jason corbett [mailto:[EMAIL PROTECTED] 
> Sent: Friday, August 06, 2004 5:44 PM
> To: perl beginners
> Subject: Using binding in order to pass values to a sql statement.
> 
> 
> Hello all. I am trying to use bind_param to create a list of 
> values in the form of an array. Then I want to query the data 
> base using a basic sql statement where each value in my list 
> (array) will be sent to the DBI in order to return a value. I 
> am getting and error that says can't call method "bind_param" 
> on defined value at line *&&. Here in the subroutine that 
> will attempt to do this.
>  
>  
>  
> sub kill_porq{
> my @banlist=qw(
> 222497190
> 291529832
> 285471249
> 280768305
> 276573798
> 278628710
> 297888281
> 297002394
> 271831939
> 127465
> 245710698
> 314086723
> 347803890
> 253926979
> 226200204
> 250702348
> 246597179
> 301791980
> 332270292
> 344909948
> 283580543
> 325838931
> 349835609
> 248436566
> 240499101
> 245185000
> 353432496
> 246334241
> 279430907
> 222800122
> );
>  my $ban='';
>  foreach $ban (@banlist){
>  
>  
>  $sth->bind_param (1, "$ban");
> 
>  
>  $sth=$dbh->prepare("select request_no, ban, request_sts, 
> 

Binding should come after preparing ...

José.


 DISCLAIMER 

"This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Using binding in order to pass values to a sql statement.

2004-08-06 Thread jason corbett
Hello all. I am trying to use bind_param to create a list of values in the form of an 
array. Then I want to query the data base using a basic sql statement where each value 
in my list (array) will be sent to the DBI in order to return a value. I am getting 
and error that says can't call method "bind_param" on defined value at line *&&. Here 
in the subroutine that will attempt to do this.
 
 
 
sub kill_porq{
my @banlist=qw(
222497190
291529832
285471249
280768305
276573798
278628710
297888281
297002394
271831939
127465
245710698
314086723
347803890
253926979
226200204
250702348
246597179
301791980
332270292
344909948
283580543
325838931
349835609
248436566
240499101
245185000
353432496
246334241
279430907
222800122
);
 my $ban='';
 foreach $ban (@banlist){
 
 
 $sth->bind_param (1, "$ban");

 
 $sth=$dbh->prepare("select request_no, ban, request_sts, status_act, 
NPAC_Process_ind, external_req_no
  from vstappo.port_request
   where ban = ?
 ");
 
 
 $sth->execute();
 
return;
}


Re: Creating hash with multiple keys for an array

2004-08-06 Thread Gunnar Hjalmarsson
Edward Wijaya wrote:
Is there anyway in Perl to create hash with multiple key for an
array?
Yes.
my %HoA = ( key1 => [ @array1 ] );
$HoA{key2} = $HoA{key1};
The purpose is as follows.
For example these lines:
AGCAG,AGCCG,AGCCGGGCG,AGCCAGGAG 15.188721875540
AGCGGAGCG,AGCCGAGGG,AGCGGAGGG   16.163408331891
\_/ \_/
  @Array1   $Key1
Is that an array with 7 elements?
What do you mean by the scalar variable $Key1 that points to 2
numbers?
I want to store @Array1 under hash with $Key1 AND scalar(@Array1)
as $Key2.
Now I for one am lost.
Because later I need to sort the hash based on $Key1 and $Key2.
Does still not make sense to me.
Can you try to explain again what it is you want to know?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Creating hash with multiple keys for an array

2004-08-06 Thread Edward WIJAYA
Hi,
Is there anyway in Perl to create
hash with multiple key for an array?
The purpose is as follows.
For example these lines:
AGCAG,AGCCG,AGCCGGGCG,AGCCAGGAG 15.188721875540
AGCGGAGCG,AGCCGAGGG,AGCGGAGGG   16.163408331891
\_/ \_/
  @Array1   $Key1
I want to store @Array1 under hash with $Key1 AND
scalar(@Array1) as $Key2.
Because later I need to sort the hash
based on $Key1 and $Key2.
Thanks so much for your time.
Regards,
Edward WIJAYA
SINGAPORE

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: floating point convertion

2004-08-06 Thread Charles K. Clarkson
Mark Cohen <[EMAIL PROTECTED]> wrote:

: Hello Charles,
: I don't understand why you are getting differnet
: results. I checked approximatley 1000 records
: containing different floating points and it seems
: that the result is similar to the results I'm
: getting from SAS but I'll try to understand why
: this happens. I have a member that is required
: from the main program which uses this statement:
: 
: $R723CCPU=&floatmvs(substr($_record,$offsec+32,8));

Well, it looks like you are passing a 8
characters long argument here, while the example
you gave has 16 characters. To really be certain
we are using the same input, you'll have to
verify it.

You might add something like this. Print the
report near the program end. You should get a list
of arguments, followed by results.

$R723CCPU=&floatmvs(substr($_record,$offsec+32,8));

push @report, [
substr( $_record, $offsec + 32, 8 ),
$R723CCPU ];

.
.
.

printf "%s => %s\n\n", @$_ foreach @report;


If the results are fine here, check them
against the sub you presented. Do this check in
a separate script.


foreach my $arguments ( @report ) {
my $result = floatmvs( $arguments->[0] );

printf "%-6s --- %s => %s\n",
$result == $arguments->[1] ? 'true' : 'false',
$arguments->[0],
$result;
}

If everything comes up true, we have
eliminated errors due to copying and the
modification of the result by a module in the
original script.

When testing a rewrite of a section of code
do the testing under very controlled conditions.
Know exactly what the input and output is.
Isolate that code in a separate script when
possible. Do a *lot* of testing.

When you are satisfied. Test some more.
Then plug it back into the script and test some
more. Never assume the new code will work by
logically stepping through the program. Actually
Test it.


: : sub floatmvs {
: :  my $mat=0;
: :  my $firstbyte = unpack "H2", $_[0];
: :  my $exp=$firstbyte-40;  # base 16
: :  my $bin=unpack('B*',substr($_[0],1,7));
: :for ($start=0; $start <56; $start+=1) {
: : $bit=substr($bin,$start,1);
: : $bitpos=$start+1;
: : if ($bit == 1) {
: : $val=(1/2)**($bitpos);
: : $mat=$mat+$val;
: : }
: :}
: :my $num=$mat*(16**$exp);
: :return $num;
: : }
: 
: With 'strict' and 'warnings' turned on, I get
: the same result with this.
: 
: use strict;
: use warnings;
: 
: print floatmvs2( '44FE8800' );
: 
: sub floatmvs2 {
: my @bits = split //, unpack 'B*', substr( $_[0], 1, 7 );
: 
: my $mat = 0;
: foreach my $pos ( 0 .. $#bits ) {
: $mat += $bits[ $pos ] * ( 1 / 2 ) ** ( $pos + 1 );
: }
: 
: my $exp = unpack( 'H2', $_[0] ) - 40;
: return $mat * ( 16 ** $exp );
: }
: 

: I think the only difference between your
: subroutine and mine is the way you split the
: bits.

That's not the only one. Your subroutine
uses variables that are not in scope to the
subroutine. I'm referring to $start, $bit,
$bitpos, and $val.

My version uses lexically scoped variables
only. Chances are they are both as fast. You'll
have to benchmark them to find out.


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: RE : cryptic error messages in modules

2004-08-06 Thread Christopher J. Bottaro
Jose Nyimi wrote: 
> I made a copy-paste of your above code, added the following to call f():
> 
> package main;
> My::Class::f();
> 
> And got the error message below:
> Global symbol "$s" requires explicit package name at try.pl line 31.
> Execution of try.pl aborted due to compilation errors.
> 
> Which tells exactly what is going wrong: missing to declare $s in
> DESTROY().
> I'm wondering why you have got an other message.
> Double check ...

that is strange indeed.  when i use my posted code, i get the proper error
message, but in the code i'm really using, its as clear as day:  if i don't
declare $s in DESTROY(), perl complains about not finding new() in FHEAD
(which is a Class::Struct that i declared).  if i declare $s, the error
message goes away.

i'd post my code that is causing it, but i'd have to post 4 files...=/  if
you are really curious, just send me an email and i'll send you the 4
files.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Sorting an array of hashes

2004-08-06 Thread Chris Mortimore

-Original Message-
From: Chris Mortimore [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 05, 2004 5:19 PM
To: [EMAIL PROTECTED]
Subject: Sorting an array of hashes

I want to sort an AoH.  Not each hash by its keys, but the array by the
value of one of the keys in each hash. I know how to sort a simple
array. I know how to sort a hash by the keys. Could someone kindly point
me to the documentation on sorting arrays of hashes?
 
Thank you!
Chris.

Hope this gives you some ideas...


#! /usr/local/bin/perl @AoH=({office=>C,employees=>500},{office=>A,
employees=>30}); $ndx=0; foreach (@AoH){
print "$_->{office}, $ndx \n";
$IofH{$_->{office}} = $ndx++;
}
foreach (sort keys %IofH){
print "$_, $IofH{$_}\n";
%nH = %{$AoH[$IofH{$_}]};
print "Office $_ has employees $nH{employees}\n";
}

jwm


Thank you John.  How to build the index and relate it back to the
original array of hashes is exactly what I was trying to figure out!
Gratefully, Chris.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Using "do" versus "use" for subroutine

2004-08-06 Thread Bob Showalter
Edward Wijaya wrote:
> Hi,
> 
> I would like to know which of this
> is better and what is the pro and cons:
> 
> 1. A file "mysub.pl" which stored
> a subroutine, and later called by
> main file using:  do "mysub.pl"
> 
> or
> 
> 2. A file "mysub.pm" and called
> in main file using : use "mysub.pm"

The second construct is not valid; the argument to "use" must be a bareword.

It's not really possible to answer your question without knowing more
details. I'm not clear about what's actually in mysub.pl. The general answer
is that "use" is the preferred method for bringing in routines, and you
should use proper module construction techniques for writing modules.

See 

   perldoc -q require

for a comparison of the various methods available to you in Perl.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Sorting HTML tables

2004-08-06 Thread Jeff 'japhy' Pinyan
On Aug 4, Perl said:

>die "You must enter an argument. \n" if $#ARGV <0;

I'd suggest using:

  die ... if @ARGV == 0;

because it's easier to read and understand.

>$logfile = chomp ($ARGV);

Is that really your code?  That doesn't make any sense to me.  I think you
meant:

  $logfile = $ARGV[0];

There's no reason to chomp() here, and besides, chomp() doesn't return the
modified string, it returns a number.

-- 
Jeff "japhy" Pinyan %  How can we ever be the sold short or
RPI Acacia Brother #734 %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %-- Meister Eckhart



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: doubt in Definition of sub routine.

2004-08-06 Thread Jeff 'japhy' Pinyan
On Aug 5, Jose Alves de Castro said:

>sub trim($), for instance, means that trim will work on a scalar.

It means that trim() expects ONE argument and will enforce scalar context
on it.  trim($foo) and trim(@bar) both work.

>This is useful to, instead of something such as
>
>trim($var)
>
>use something such as
>
>trim $var

That has nothing to do with prototypes.  That is only the case when trim()
is defined before it's used (or before that specific use of the function).

>Also,
>
>trim
>
>by itself is interpreted as trim($_)

Not so; trim($) means it *must* have an argument sent to it.

-- 
Jeff "japhy" Pinyan %  How can we ever be the sold short or
RPI Acacia Brother #734 %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %-- Meister Eckhart


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: How to avoid writing files that is used by other programs?

2004-08-06 Thread Gunnar Hjalmarsson
Nyimi Jose ) wrote:
Gunnar Hjalmarsson wrote:
Shu Hung wrote:
I am writing a script to relocate some tar files in a folder.
Since those tar files are scheduled to be written daily, I want
to make sure I'm not moving any files which are being written
by other programs...
How can I do so?
You can lock them.
perldoc -f flock
perldoc -q "lock a file"
It seems that (from original post) there are 2 programs there:
Program1: writing the tar files
Program2: trying to relocate tar files created by program1
My understanding is that the "lock" should be done by the program1
to avoid program2 relocate files untill it (program1) finishs
writting them.
If the program1 is not under your control, how to use the "lock"
solution you suggested ?
You can't. Locking must be done by the "other programs" (which I
assumed the OP is able to modify...).
Thanks for pointing it out.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Using "do" versus "use" for subroutine

2004-08-06 Thread Edward Wijaya
Hi,
I would like to know which of this
is better and what is the pro and cons:
1. A file "mysub.pl" which stored
a subroutine, and later called by
main file using:  do "mysub.pl"
or
2. A file "mysub.pm" and called
in main file using : use "mysub.pm"
Thanks so much for your time
Regards,
Edward WIJAYA
SINGAPORE
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: How to avoid writing files that is used by other programs?

2004-08-06 Thread NYIMI Jose \(BMB\)


> -Original Message-
> From: Gunnar Hjalmarsson [mailto:[EMAIL PROTECTED] 
> Sent: Friday, August 06, 2004 10:49 AM
> To: [EMAIL PROTECTED]
> Subject: Re: How to avoid writing files that is used by other 
> programs?
> 
> 
> Shu Hung wrote:
> > I am writing a script to relocate some tar files in a folder.
> > 
> > Since those tar files are scheduled to be written daily, I want to 
> > make sure I'm not moving any files which are being written by other 
> > programs...
> > 
> > How can I do so?
> 
> You can lock them.
> 
>  perldoc -f flock
>  perldoc -q "lock a file"
> 

I have a question,
It seems that (from original post) there are 2 programs there:
Program1: writing the tar files
Program2: trying to relocate tar files created by program1

My understanding is that the "lock" should be done by the program1 to avoid
program2 relocate files untill it (program1) finishs writting them.

If the program1 is not under your control, how to use the "lock" solution you 
suggested ?

Thanks,

José.


 DISCLAIMER 

"This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: How to avoid writing files that is used by other programs?

2004-08-06 Thread Gunnar Hjalmarsson
Shu Hung wrote:
I am writing a script to relocate some tar files in a folder.
Since those tar files are scheduled to be written daily, I want to
make sure I'm not moving any files which are being written by other
programs...
How can I do so?
You can lock them.
perldoc -f flock
perldoc -q "lock a file"
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



How to avoid writing files that is used by other programs?

2004-08-06 Thread Shu Hung (Koala)
I am writing a script to relocate some tar files in a folder.

Since those tar files are scheduled to be written daily,
I want to make sure I'm not moving any files which are being
written by other programs...

How can I do so?

Thanks a lot

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]