Re: Changing registry ACL?

2004-11-15 Thread K-sPecial
[EMAIL PROTECTED] wrote:
How do you compensate for the huge memory leak in Win32::Perms? When I run this script (which I don't know if it is correct) the memory climbs forcing me to kill the perl proccess. Anyone have an alternative means to get this to work? 

Thanks..
AD
 

#!C:\perl\bin\perl
use Win32::Perms;
$Dir = new 
Win32::Perms("HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\Eventlog");
$Dir->Add( {Account=>"Domain Admins", Mask=>FULL, Flag=>KEY} );
$Dir->Set();
$Dir->Dump;
 

 


Does anyone know of a way to change the registry ACL on a registry key
using Perl?

Check out the Win32::Perms module from http://www.roth.net/perl/
Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 


Change opperating systems? lol, stupid joke. I know it's a little late 
and i'm not sure if it even does "ACL" changes. But for all my registry 
needs i've used Tie::Registry from CPAN and have always had the success 
i've been looking for.

--K-sPecial
[ http://xzziroz.freeshell.org
  irc://xzziroz.dtdns.net   ]



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



Re: Searching tecknical documentation

2004-11-15 Thread K-sPecial
Chris Devers wrote:
On Tue, 16 Nov 2004, Renqilong wrote:

This is just what you want:
http://www.m--i.com/document/oreilly/

Yeah. Pirate the books. That'll keep new ones coming... 
Please don't encourage or link to sites like this. A lot of people would 
consider this a form of stealing from the authors of these books.


Yea he's got a point...
--K-sPecial

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



RE: Changing registry ACL?

2004-11-15 Thread adisegna
How do you compensate for the huge memory leak in Win32::Perms? When I run this 
script (which I don't know if it is correct) the memory climbs forcing me to 
kill the perl proccess. Anyone have an alternative means to get this to work? 

Thanks..

AD

 

#!C:\perl\bin\perl
use Win32::Perms;

$Dir = new 
Win32::Perms("HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\Eventlog");
$Dir->Add( {Account=>"Domain Admins", Mask=>FULL, Flag=>KEY} );
$Dir->Set();
$Dir->Dump;


 

 

> Does anyone know of a way to change the registry ACL on a registry key
> using Perl?

Check out the Win32::Perms module from http://www.roth.net/perl/

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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






Re: Searching tecknical documentation

2004-11-15 Thread Chasecreek Systemhouse
On Mon, 15 Nov 2004 23:08:07 -0500 (EST), Chris Devers
<[EMAIL PROTECTED]> wrote:
> Yeah. Pirate the books. That'll keep new ones coming... 

Besides, printed material has errors and needs to be kept updated --
it is better to study on your own.  There are PLENTY of already free
places to get help about Perl as well as other things =/

-- 
WC -Sx- Jones
http://insecurity.org/

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




Re: Searching tecknical documentation

2004-11-15 Thread Chris Devers
On Tue, 16 Nov 2004, Renqilong wrote:

> This is just what you want:
> 
> http://www.m--i.com/document/oreilly/

Yeah. Pirate the books. That'll keep new ones coming... 

Please don't encourage or link to sites like this. A lot of people would 
consider this a form of stealing from the authors of these books.



-- 
Chris Devers

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




Re: Searching tecknical documentation

2004-11-15 Thread K-sPecial
Renqilong wrote:
This is just what you want:
http://www.mamiyami.com/document/oreilly/
On Tue, 16 Nov 2004 11:02:18 +0800 (CST)
Stephen Liu <[EMAIL PROTECTED]> wrote:

Hi folks,
Please advise where can I find similar free
documentation on Internet, like;
programming perl (O'reilly)
Learning Perl (Llama)
Programming Perl (Camel)
Perl Cookbook (Ram)
Google search brought me tons of links which a
beginner finds it hard to sort out
TIA
B.R.
Stephen Liu
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 


Damn (if I may say so), nice link.
--K-sPecial
[ http://xzziroz.freeshell.org
  irc://xzziroz.dtdns.net   ]

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



Re: Searching tecknical documentation

2004-11-15 Thread K-sPecial
Stephen Liu wrote:
Hi folks,
Please advise where can I find similar free
documentation on Internet, like;
programming perl (O'reilly)
Learning Perl (Llama)
Programming Perl (Camel)
Perl Cookbook (Ram)
Google search brought me tons of links which a
beginner finds it hard to sort out
TIA
B.R.
Stephen Liu
perldoc.com is always a handy place to have as your quick check to lots 
of perl questions and answers.

--K-sPecial
[ http://xzziroz.freeshell.org
  irc://xzziroz.dtdns.net   ]

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



Re: Searching tecknical documentation

2004-11-15 Thread Renqilong
This is just what you want:

http://www.mamiyami.com/document/oreilly/

On Tue, 16 Nov 2004 11:02:18 +0800 (CST)
Stephen Liu <[EMAIL PROTECTED]> wrote:

> Hi folks,
> 
> Please advise where can I find similar free
> documentation on Internet, like;
> 
> programming perl (O'reilly)
> Learning Perl (Llama)
> Programming Perl (Camel)
> Perl Cookbook (Ram)
> 
> Google search brought me tons of links which a
> beginner finds it hard to sort out
> 
> TIA
> 
> B.R.
> Stephen Liu
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
> 
> 
> 


-- 
Whatever you do will be insignificant,but 
the important is you do it!

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




Searching tecknical documentation

2004-11-15 Thread Stephen Liu
Hi folks,

Please advise where can I find similar free
documentation on Internet, like;

programming perl (O'reilly)
Learning Perl (Llama)
Programming Perl (Camel)
Perl Cookbook (Ram)

Google search brought me tons of links which a
beginner finds it hard to sort out

TIA

B.R.
Stephen Liu

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




RE: Unlink ?

2004-11-15 Thread Jim
  
> I want to use the unlink command to programmatically delete files.
> 
> I have modified this code snippet but it no longer works, I 
> suspect that it's because unlink returns the number of deleted files.
> 
>   my $cmd = qq[unlink $srcFile];
>   $debug->printlog("command: $cmd");
>   my $cmdResult = `$cmd 2>&1`;
>   $debug->printlog("result: $cmdResult");
...

> 
> So want Im trying to achieve is delete file Write the 
> successful deletion or error to the log file then continue.
> But it executes the else clause each time.

why are you trying to assign the command to a variable, and why are you
using backtics to call it?
simply try:
$cnt = unlink $srcFile;
$result = $cnt ? "Deleted $cnt files" : "error";
$debug->printlog("result: $result");

 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.796 / Virus Database: 540 - Release Date: 11/13/2004
 


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




RE: Using cgi.pm for checkbox goups

2004-11-15 Thread Charles K. Clarkson
Johnstone, Colin <[EMAIL PROTECTED]> wrote:

Please use beginners-cgi to ask CGI related questions.

: Gidday all,
: 
: I have created a form with a group of checkboxes (see code
: below) 
: 
: I wish to use cgi.pm to process it.
: 
: When I use
: 
: my @deployBranch = $cgi->{form}{'deployBranch'};

What made you think that $cgi->{form}{'deployBranch'}
would return an array of values?

my @deployBranch = $cgi->param( 'deployBranch' );

Access objects using provided public methods, not by
attempting to access the data directly.


:my $list;
: 
: if ( @deployBranch ) {
:   $list = join ', ', @deployBranch;
: } else {
:   $list = 'None';
: }

my $list = 'None';
$list = join ', ', $cgi->param( 'deployBranch' )
if $cgi->param( 'deployBranch' );


[snip]
: 
: temp_partners:   

You need to add a submit button in there.

: 

HTH,

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


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




Using cgi.pm for checkbox goups

2004-11-15 Thread Johnstone, Colin
Gidday all,

I have created a form with a group of checkboxes (see code below)

I wish to use cgi.pm to process it. 

When I use 

my @deployBranch = $cgi->{form}{'deployBranch'};

   my $list;

if ( @deployBranch ) {
  $list = join ', ', @deployBranch;
} else {
  $list = 'None';
}


$debug->printlog("List: $list");

My debug log returns this 

List: ARRAY(0x3bf048)

Im expecting to see the value attributes of the checkbox group being
returned as a comma delimited list, What am I doing wrong?

Regards
Colin




bremer: 



brisbane_north: 



gold_coast: 



logan: 



tafeqld: 



temp_clients: 



temp_partners: 




Colin Johnstone 
Interwoven Teamsite Analyst Programmer 
eGovernment Delivery Team
QLD Department of Employment and Training
Telephone (07) 3244 6281
Fax (07) 3244 6265
Address Southbank Institute of TAFE - Kangaroo Point Campus
Visit: http://www.trainandemploy.qld.gov.au/ 



This E-Mail is intended only for the addressee. Its use is limited to that
intended by the author at the time and it is not to be distributed without the
author's consent. Unless otherwise stated, the State of Queensland accepts no
liability for the contents of this E-Mail except where subsequently confirmed in
writing. The opinions expressed in this E-Mail are those of the author and do
not necessarily represent the views of the State of Queensland. This E-Mail is
confidential and may be subject to a claim of legal privilege.

If you have received this E-Mail in error, please notify the author and delete 
this message immediately.



Re: postincrement in scalar

2004-11-15 Thread Ing. Branislav Gerzo
Charles K. Clarkson [CKC], on Monday, November 15, 2004 at 10:00
(-0600) wrote:

CKC> ( $seen{$item} ? $seen{$item}++ : $seen{$item} ) = 1;
CKC> When you probably meant this:
CKC> $seen{$item} ? ($seen{$item}++) : ($seen{$item} = 1);

CKC> According to the docs: "The operator may be assigned to
CKC> if both the 2nd and 3rd arguments are legal lvalues." A
CKC> post increment is not a valid lvalue. You are basically
CKC> saying this.

thanks for clean explanation. Now I'm a bit smarter :)

-- 

 ...m8s, cu l8r, Brano.

[Alamak!!!]



-=x=-
Skontrolované antivírovým programom NOD32


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




Re: Off Topic Question

2004-11-15 Thread JupiterHost.Net

Ian Harisay wrote:
Hi All, 
Hello,
Can anyone direct me to a Perl/MySQL shopping cart solution?  I would
Click Cart Pro is excellent!
like to use Authorize.net or Verisign as my gateway.  Since this is off
topic, please reply directly to me.  
I don't want to clutter the list with this subject. 
I don't think its clutter to discuss excellent Perl programs via the list :)
We use Click Cart Pro for our ecommerce package:
See the "Ecommerce" option at:
 http://www.jupiterhost.net/signup.pl
for details and a link to more info and eventually theri site.
Interchange is very excellent also:
 http://www.icdevgroup.org/
HTH :)
Lee.M - JupiterHost.Net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: postincrement in scalar

2004-11-15 Thread Chasecreek Systemhouse
On Mon, 15 Nov 2004 16:34:35 +0100, Ing. Branislav Gerzo <[EMAIL PROTECTED]> 
wrote:

> ok I understand, but I don't know why my line doesn't work. I thought
> (exp) ? (true) : (false) is the same as if (exp) {  } else { }

Here is an OLD example of short-circuited presedence issues:

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

my $count;

while(1) {
   (++$count) ? $count += $count-- : $count += $count++;

   print "$count\n"; exit if $count > 60_000;
   sleep 1;
}

__END__


Or, a practical example -

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

my $count;
my $index;
my $str;

while (++$index) {
   $count = $index;

   while(1) {
 (++$count) ? $count += $count--
: $count += $count++;

 $str = unpack("B32", pack("N", $count));
 print "$count \tis binary $str\n";
 last if $count > 60_000;
 sleep 1;
   }

exit if $index > 255;
}

__END__


Please read the whole thread here:

http://groups.google.com/groups?hl=en&lr=&safe=off&threadm=40853BDD.7050901%40insecurity.org&rnum=84&prev=/groups%3Fnum%3D100%26hl%3Den%26lr%3D%26safe%3Doff%26q%3Dyouve%2BJones%2BSx%2BPerl%26btnG%3DSearch


-- 
WC -Sx- Jones
http://insecurity.org/

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




Re: postincrement in scalar

2004-11-15 Thread JupiterHost.Net

Charles K. Clarkson wrote:
Ing. Branislav Gerzo <[EMAIL PROTECTED]> wrote:
: Charles K. Clarkson [CKC], on Monday, November 15, 2004 at
: 09:20 (-0600) typed: 
: 
: : : $seen{$item} ? $seen{$item}++ : $seen{$item} = 1; }
: : $seen{$item} = $seen{$item} ? ++$seen{$item} : 1;
: 
: ok I understand, but I don't know why my line doesn't work. I
: thought (exp) ? (true) : (false) is the same as if (exp) {  }
: else { } 

Try this:
perl -e 'my %seen = (foo => 0,bar =>1); for(keys %seen) { $seen{$_} += 
$seen{$_} ? 0 : 1;print "$_ : $seen{$_}\n"; }'

instead of this:
perl -e 'my %seen = (foo => 0,bar =>1); for(keys %seen) { $seen{$_} ? 
$seen{$_}++ : $seen{$_} = 1;print "$_ : $seen{$_}\n"; }'

Or to simplify a whole bunch:
 dostuff($_) if !$seen{$_};
and then in
sub dostuff {
  my $key = shift;
# do stuff
  $seen{$key}++;
}
HTH :)
Lee.M - JupiterHost.Net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



perl.beginners Weekly list FAQ posting

2004-11-15 Thread casey
NAME
beginners-faq - FAQ for the beginners mailing list

1 -  Administriva
  1.1 - I'm not subscribed - how do I subscribe?
Send mail to <[EMAIL PROTECTED]>

You can also specify your subscription email address by sending email to
(assuming [EMAIL PROTECTED] is your email address):

<[EMAIL PROTECTED]>.

  1.2 -  How do I unsubscribe?
Now, why would you want to do that? Send mail to
<[EMAIL PROTECTED]>, and wait for a response. Once you
reply to the response, you'll be unsubscribed. If that doesn't work,
find the email address which you are subscribed from and send an email
like the following (let's assume your email is [EMAIL PROTECTED]):

<[EMAIL PROTECTED]>

  1.3 - There is too much traffic on this list. Is there a digest?
Yes. To subscribe to the digest version of this list send an email to:

<[EMAIL PROTECTED]>

To unsubscribe from the digest, send an email to:

<[EMAIL PROTECTED]>

This is a high traffic list (100+ messages per day), so please subscribe
in the way which is best for you.

  1.4 - Is there an archive on the web?
Yes, there is. It is located at:

http://archive.develooper.com/beginners%40perl.org/

  1.5 - How can I get this FAQ?
This document will be emailed to the list once a week, and will be
available online in the archives, and at http://learn.perl.org/

  1.6 - I don't see something in the FAQ, how can I make a suggestion?
Send an email to <[EMAIL PROTECTED]> with your suggestion.

  1.7 - Is there a supporting website for this list?
Yes, there is. It is located at:

http://beginners.perl.org/

  1.8 - Who do I complain to?
You can send complaints to <[EMAIL PROTECTED]>

  1.9 - Who currently maintains the FAQ?
Kevin Meltzer, who can be reached at the email address (for FAQ
suggestions only) in question 1.6

  1.10 - Who will maintain peace and flow on the list?
Casey West, Kevin Meltzer and Ask Bjoern Hansen currently carry large,
yet padded, clue-sticks to maintain peace and order on the list. If you
are privately emailed by one of these folks for flaming, being
off-topic, etc... please listen to what they say. If you see a message
sent to the list by one of these people saying that a thread is closed,
do not continue to post to the list on that thread! If you do, you will
not only meet face to face with a XQJ-37 nuclear powered pansexual
roto-plooker, but you may also be taken off of the list. These people
simply want to make sure the list stays topical, and above-all, useful
to Perl beginners.

  1.11 - When was this FAQ last updated?
Feb 04, 2004

2 -  Questions about the 'beginners' list.
  2.1 - What is the list for?
A list for beginning Perl programmers to ask questions in a friendly
atmosphere.

  2.2 - What is this list _not_ for?
* SPAM
* Homework
* Solicitation
* Things that aren't Perl related
* Monkeys
* Monkeys solicitating homework on non-Perl related SPAM.

  2.3 - Are there any rules?
Yes. As with most communities, there are rules. Not many, and ones that
shouldn't need to be mentioned, but they are.

* Be nice
* No flaming
* Have fun

  2.4 - What topics are allowed on this list?
Basically, if it has to do with Perl, then it is allowed. You can ask
CGI, networking, syntax, style, etc... types of questions. If your
question has nothing at all to do with Perl, it will likely be ignored.
If it has anything to do with Perl, it will likely be answered.

  2.5 - I want to help, what should I do?
Subscribe to the list! If you see a question which you can give an
idiomatic and Good answer to, answer away! If you do not know the
answer, wait for someone to answer, and learn a little.

  2.6 - Is there anything I should keep in mind while answering?
We don't want to see 'RTFM'. That isn't very helpful. Instead, guide the
beginner to the place in the FM they should R :)

Please do not quote the documentation unless you have something to add
to it. It is better to direct someone to the documentation so they
hopefully will read documentation above and beyond that which answers
their question. It also helps teach them how to use the documentation.

  2.7 - I don't want to post a question if it is in an FAQ. Where should I
look first?
Look in the FAQ! Get acquainted with the 'perldoc' utility, and use it.
It can save everyone time if you look in the Perl FAQs first, instead of
having a list of people refer you to the Perl FAQs :) You can learn
about 'perldoc' by typing:

"perldoc perldoc"

At your command prompt. You can also view documentation online at:

http://www.perldoc.com and http://www.perl.com

  2.8 Is this a high traffic list?
YES! You have been warned! If you don't want to get ~100 emails per day
from this list, consider subscribing to the digest.

  2.9 Other tips before posti

RE: Append on top (easy sollution)

2004-11-15 Thread Ron Goral


> -Original Message-
> From: Gary Stainburn [mailto:[EMAIL PROTECTED]
> Sent: Monday, November 15, 2004 7:25 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Append on top (easy sollution)
>
>
> On Monday 15 November 2004 3:02 am, K-sPecial wrote:
> > Rajesh Dorairajan wrote:
> > > Does anyone know of a way to open a file in append mode and append
> > > on top of the file?
> > >
> > > Thanks in Advance,
> > >
> > > --Rajesh
> >
> > I don't know why people are having a problem with this sollution,
> > simply open in append mode so open doesn't clobber the file, then use
> > seek() to move to the beginning of the file. Done :)
> >
>
> The problem is that if you do that, you're going to overwrite the
> existing data with every write you do. What is required when appending
> to the front (oxymoron as append means to stick on the end), is that
> the existing data is shuffled down when you write.
>
> To clarify.
>
> if you had
>
> a
> b
> c
> d
>
> and did as you suggested to write 'f' you would end up with
>
> f
> b
> c
> d
>
> See?
>
> > --K-sPecial
> >
> > [ http://xzziroz.freeshell.org
> >irc://xzziroz.dtdns.net   ]
>
> --
> Gary Stainburn
>
> This email does not contain private or confidential material as it
> may be snooped on by interested government parties for unknown
> and undisclosed purposes - Regulation of Investigatory Powers
> Act, 2000

Perl FAQ 5 talks about this in the subsection entitled "How do I change one
line in a file/delete a line in a file/insert a line in the middle of a
file/append to the beginning of a file?"

Peace -
Ron Goral



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




RE: postincrement in scalar

2004-11-15 Thread Charles K. Clarkson
Ing. Branislav Gerzo <[EMAIL PROTECTED]> wrote:

: Charles K. Clarkson [CKC], on Monday, November 15, 2004 at
: 09:20 (-0600) typed: 
: 
: : : $seen{$item} ? $seen{$item}++ : $seen{$item} = 1; }
: : $seen{$item} = $seen{$item} ? ++$seen{$item} : 1;
: 
: ok I understand, but I don't know why my line doesn't work. I
: thought (exp) ? (true) : (false) is the same as if (exp) {  }
: else { } 

Further investigation leads me to believe perl interpreted
your original statement:

  $seen{$item} ? $seen{$item}++ : $seen{$item} = 1;

As this:

( $seen{$item} ? $seen{$item}++ : $seen{$item} ) = 1;

When you probably meant this:

$seen{$item} ? ($seen{$item}++) : ($seen{$item} = 1);

According to the docs: "The operator may be assigned to
if both the 2nd and 3rd arguments are legal lvalues." A
post increment is not a valid lvalue. You are basically
saying this.

if ( $seen{$item} ) {
$seen{$item}++ = 1;

} else {
$seen{$item} = 1;
}


HTH,

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


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




Re: postincrement in scalar

2004-11-15 Thread Peter Scott
In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Ing. Branislav Gerzo) writes:
>foreach my $item (@list) {
>chomp($item);
>$seen{$item} ? $seen{$item}++ : $seen{$item} = 1;
>}
>
>and perl says:
>
>Can't modify postincrement (++) in scalar assignment ...
>
>What I am doing bad ?

Ignoring precedence, which means that the last line is
evaluated as:

   ($seen{$item} ? $seen{$item}++ : $seen{$item}) = 1;

However, a far more standard and readable idiom would
be to write:

$seen{$item}++;

which will have the effect you want.  For two reasons:
(1) An undefined value is numerically equivalent to zero;
(2) The postincrement operation on an undefined value is
special cased not to trigger the "use of uninitialized value"
warning precisely because this idiom is so useful (you do
have warnings enabled, don't you?).

-- 
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/

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




Re: postincrement in scalar

2004-11-15 Thread Ing. Branislav Gerzo
Charles K. Clarkson [CKC], on Monday, November 15, 2004 at 09:20
(-0600) typed:

CKC> : $seen{$item} ? $seen{$item}++ : $seen{$item} = 1; }
CKC> $seen{$item} = $seen{$item} ? ++$seen{$item} : 1;

ok I understand, but I don't know why my line doesn't work. I thought
(exp) ? (true) : (false) is the same as if (exp) {  } else { }

CKC> chomp @list;
CKC> foreach my $item (@list) {
CKC> $seen{ $item }++;
CKC> }

very nice, thanks.

-- 

 ...m8s, cu l8r, Brano.

[Louisiana: It is against the law to gargle in public.]



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




Re: Difference between perl module and perl package

2004-11-15 Thread Chris Devers
On Sun, 14 Nov 2004, Harbhajan Julka wrote:

> Can someone tell the difference between a perl module
> and a perl package?

Packages implement modules. 

A set of code preceded by a 'package $foo;' statement can be referenced 
by another set of code preceded by a 'use $foo', provided that the first 
code is saved somewhere that the second code can find it (i.e. the file 
is in the same directory as the script that uses it, or in another 
directory referred to in the built-in @INC array).

Does this answer your question?


-- 
Chris Devers

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




RE: postincrement in scalar

2004-11-15 Thread Charles K. Clarkson
Ing. Branislav Gerzo <[EMAIL PROTECTED]> wrote:

: Hi [EMAIL PROTECTED],
: 
: I have code snippet, which gave me statistics of lines in file:
: 
: foreach my $item (@list) {
: chomp($item);
: if ($seen{$item}) {
: $seen{$item}++;
: } else {
: $seen{$item} = 1;
: }
: }
: 
: this is quite simple, so I rewrite that as:
: 
: foreach my $item (@list) {
: chomp($item);
: $seen{$item} ? $seen{$item}++ : $seen{$item} = 1; }
: 
: and perl says:
: 
: Can't modify postincrement (++) in scalar assignment ...
: 
: What I am doing bad?

$seen{$item} = $seen{$item} ? ++$seen{$item} : 1;


TIMTOWTDI:

chomp @list;
foreach my $item (@list) {
if ($seen{$item}) {
$seen{$item}++;
} else {
$seen{$item} = 1;
}
}
# --

chomp @list;
foreach my $item (@list) {
$seen{ $item }++;
}
# --

chomp @list;
$seen{ $_ }++ foreach @list;


HTH,

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



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




postincrement in scalar

2004-11-15 Thread Ing. Branislav Gerzo
Hi [EMAIL PROTECTED],

I have code snippet, which gave me statistics of lines in file:

foreach my $item (@list) {
chomp($item);
if ($seen{$item}) { 
$seen{$item}++;
} else { 
$seen{$item} = 1; 
}
}

this is quite simple, so I rewrite that as:

foreach my $item (@list) {
chomp($item);
$seen{$item} ? $seen{$item}++ : $seen{$item} = 1;
}

and perl says:

Can't modify postincrement (++) in scalar assignment ...

What I am doing bad ?

--

 --. ,--  ,- ICQ: 7552083  \|||/`//EB: www.2ge.us
,--' |  - |--IRC: [2ge](. .),\\SN: 2ge!2ge_us
`+==+=+===~  ~=-o00-(_)-00o-~
"It wasn't me who misplaced the Deltavid asteroid belt." - Q
 




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




Re: Append on top

2004-11-15 Thread Gary Stainburn
On Monday 15 November 2004 1:43 pm, NYIMI Jose \(BMB\) wrote:
> > However, if you do have these restrictions it can be done using the
> > psudocode below
> >
> > calculate write_size
> > seek EOF-buffer_size
> > read buffer_size
> > seek EOF-buffer_size+write_size
> > repeat until at BOF
Don't forget

Seek BOF
write new data
>
> Why should I care with all these details when Tie::File is available
> from CPAN. And now comes as standard dist of recent Perl version ?
>
> José.
>
Hi José.

You man want to know this, because, as I said in my OP there may be 
reasons why you can't create a new file and have to do the update in 
place.  Tie::File, like the other methods creates a new file and then 
copies that over the original.

Gary
-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 


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




Re: Accessing elements of an array passed by reference

2004-11-15 Thread Zeus Odin
"Colin Johnstone" <[EMAIL PROTECTED]> wrote ...

> Gidday all,

Hello.

> I wish to access the elements of an array passed by reference

> #get deploy list
> my @$deployList = $task->GetVariable('deployList');

> foreach( @$deployList ){
>
> }

If $task->GetVariable('deployList') returns a reference to an array, you
have two choices:

1) my $deployList = $task->GetVariable('deployList');
   foreach( @$deployList ){

2) my @deployList = @{ $task->GetVariable('deployList') };
   foreach( @deployList ){

I prefer the former.

-ZO



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




RE: Append on top

2004-11-15 Thread Shaw, Matthew
> Rajesh Dorairajan wrote:
> > Does anyone know of a way to open a file in append mode and append
on top of
>
> I don't know why people are having a problem with this sollution,
simply 
> open in append mode so open doesn't clobber the file, then use seek()
to 
> move to the beginning of the file. Done :)

Not quite so done -- this solution just plain doesn't work. When I want
to prepend text to the beginning of a file, I use perl's CLI edit in
place like this:

perl -ni.bak -we'print "Some next text here\n" if $. == 1; print;'
filetoedit.txt

Or from within a program:

push @ARGV, 'foobar.txt';
$^I = '.bak';
while (<>) {
print "Some new text here.\n" if $. == 1;
print; # print $_
}

Or, as suggested in the FAQ, Tie::File is good for stuff like this:

Use Tie::File;

my $file = 'textfile.txt';
my @tied;

tie @tied, 'Tie::File', $file or die $!;

unshift @tied, 'My new PRE-pended line!';
untie @tied;

None of these things actually 'edit the file in place', they re-write
the file. Hope this helps.

See also: perldoc -q append


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




RE: Append on top

2004-11-15 Thread NYIMI Jose \(BMB\)


> -Original Message-
> From: Gary Stainburn [mailto:[EMAIL PROTECTED] 
> Sent: Monday, November 15, 2004 2:25 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Append on top
> 
> 
> On Friday 29 October 2004 10:35 am, Ing. Branislav Gerzo wrote:
> > Rajesh Dorairajan [RD], on Thursday, October 28, 2004 at 18:11
> > (-0700) thoughtfully wrote the following:
> >
> > RD> Does anyone know of a way to open a file in append mode and
> > append on top of RD> the file?
> >
> > I don't think it is possible. You have to read source file, 
> and after 
> > print your results to new file (open through >) and append old file 
> > through >>
> 
> It is possible, but very messy.  The above method is the most 
> efficient, 
> but does require free disk space equivelent to the the size 
> of the new 
> file.  Not usually a problem these days, withthe low cost of HDDs.  
> 
> However, if you do have these restrictions it can be done using the 
> psudocode below
> 
> calculate write_size
> seek EOF-buffer_size
> read buffer_size
> seek EOF-buffer_size+write_size
> repeat until at BOF
> 

Why should I care with all these details when Tie::File is available from CPAN.
And now comes as standard dist of recent Perl version ?

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. This email is not intended to 
create or affect any contractual arrangements between the parties.
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: Accessing elements of an array passed by reference

2004-11-15 Thread Bob Showalter
Johnstone, Colin wrote:
> Gidday all,
> 
> I wish to access the elements of an array passed by reference

Erm, OK. I don't see any passing by reference going on below...

> 
> #get deploy list
> my @$deployList = $task->GetVariable('deployList');

This is not valid Perl. If GetVariable returns an array reference, you can
store it in a scalar. References are scalars.

  my $deployList = $task->GetVariable('deployList');

> 
> foreach( @$deployList ){

That's OK. You've now supplied the contents of the array to foreach().
Inside the loop, you refer to the current element with $_

> 
> }

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




Re: Append on top

2004-11-15 Thread Gary Stainburn
On Monday 15 November 2004 1:25 pm, Gary Stainburn wrote:
[snip]
>
> calculate write_size
> seek EOF-buffer_size
> read buffer_size
> seek EOF-buffer_size+write_size
> repeat until at BOF
>

Oops, missed out the final lines of code, which are:

seek BOF
write new data

bit of a pointless excercise without that.

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 


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




Re: Append on top

2004-11-15 Thread Gary Stainburn
On Friday 29 October 2004 10:35 am, Ing. Branislav Gerzo wrote:
> Rajesh Dorairajan [RD], on Thursday, October 28, 2004 at 18:11
> (-0700) thoughtfully wrote the following:
>
> RD> Does anyone know of a way to open a file in append mode and
> append on top of RD> the file?
>
> I don't think it is possible. You have to read source file, and after
> print your results to new file (open through >) and append old file
> through >>

It is possible, but very messy.  The above method is the most efficient, 
but does require free disk space equivelent to the the size of the new 
file.  Not usually a problem these days, withthe low cost of HDDs.  

However, if you do have these restrictions it can be done using the 
psudocode below

calculate write_size
seek EOF-buffer_size
read buffer_size
seek EOF-buffer_size+write_size
repeat until at BOF

Actually coding this into perl should be fairly easy, and could even be 
used to insert data mid-file if required.

However, if this is something that you're going to be doing regularly, 
I'd suggest re-evaluating the data format, such as using a database.

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 



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




Re: Append on top (easy sollution)

2004-11-15 Thread Gary Stainburn
On Monday 15 November 2004 3:02 am, K-sPecial wrote:
> Rajesh Dorairajan wrote:
> > Does anyone know of a way to open a file in append mode and append
> > on top of the file?
> >
> > Thanks in Advance,
> >
> > --Rajesh
>
> I don't know why people are having a problem with this sollution,
> simply open in append mode so open doesn't clobber the file, then use
> seek() to move to the beginning of the file. Done :)
>

The problem is that if you do that, you're going to overwrite the 
existing data with every write you do. What is required when appending 
to the front (oxymoron as append means to stick on the end), is that 
the existing data is shuffled down when you write.

To clarify.

if you had 

a
b
c
d

and did as you suggested to write 'f' you would end up with

f
b
c
d

See?

> --K-sPecial
>
> [ http://xzziroz.freeshell.org
>irc://xzziroz.dtdns.net   ]

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 



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




Re: Append on top (easy sollution)

2004-11-15 Thread Jenda Krynicky
From: K-sPecial <[EMAIL PROTECTED]>
> Rajesh Dorairajan wrote:
> > Does anyone know of a way to open a file in append mode and append
> > on top of the file? 
> > 
> > Thanks in Advance,
> > 
> > --Rajesh 
> > 
> 
> I don't know why people are having a problem with this sollution,
> simply open in append mode so open doesn't clobber the file, then use
> seek() to move to the beginning of the file. Done :)

Could be ... because it doesn't work?

Try this:

#!perl
use Fcntl qw(SEEK_SET);
open OUT, '>', 'testAppend.txt' or die "Can't create testAppend.txt: 
$^E\n";
print OUT "Original content\nThis is the old stuff in the file you 
are trying to append to.\n";
close OUT;

print "--original content--\n";
open IN, '<', 'testAppend.txt';
while () {print}
close IN;
print "\n";

open APPEND, '>>', 'testAppend.txt' or die "Can't append to 
testAppend.txt: $^E\n";
seek APPEND, 0, SEEK_SET;
print APPEND "--K-sPecial says this will go on top.\n";
close APPEND;

print "--updated  content--\n";
open IN, '<', 'testAppend.txt';
while () {print}
close IN;
print "\n";
__END__

I get:


--original content--
Original content
This is the old stuff in the file you are trying to append to.

--updated  content--
Original content
This is the old stuff in the file you are trying to append to.
--K-sPecial says this will go on top.


Doesn't look like anything was "appended on top".

Think of a file like it was a sheet of paper. You may add more text 
after the end of the current one easily, you can erase part of the 
text and change it to a different one if the new text is as long as 
the old one or shorter. And if it's shorter you end up with some 
whitespace. But you can't squeeze more text on top or in the middle, 
you'd have to erase everything and write first the new text and then 
the original one.

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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




Re: Accessing elements of an array passed by reference

2004-11-15 Thread Edward Wijaya
On Mon, 15 Nov 2004 16:52:40 +1000, Johnstone, Colin  
<[EMAIL PROTECTED]> wrote:

Gidday all,
I wish to access the elements of an array passed by reference
#get deploy list
my @$deployList = $task->GetVariable('deployList');
foreach( @$deployList ){
  print; #$_ worked automatically
}
alternatively you can assign a variable
after foreach:
foreach my $var ( @$deployList ){
  print "$var\n";
 }
Please read- perldoc perlreftut
 perldoc perlvar
for additional info on those issues.
HoH
Regards,
Edward WIJAYA
SINGAPORE
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]