Re: Is there a way to get a PID from a process name?

2004-05-12 Thread Ramprasad A Padmanabhan
On Thu, 2004-05-13 at 07:03, Michael Terry wrote:
> Hi,
> 
> I've got this shell script:
> 
> #!/bin/sh
> ps axc|awk "{if (\$5==\"$1\") print \$1}";
> 
> ... which gets a PID if you feed it the process' name. Is there a way 
> to translate this into Perl using a standard Perl distribution? I mean, 
> without calling 'ps'; I've learned enough Perl now to be able to do 
> that, but I'd like to see if there's a cleaner way. I don't know, maybe 
> process names aren't something other operating systems have, so Perl 
> doesn't have anything for them--I'm on Mac OS X.
> 
> I checked everything that was indexed in Programming Perl that looked 
> likely, but obviously I didn't find anything.


I done think perl will behave  any differently on MAC as compared to
*nix
just try $PID=$$;
that should work

( BTW even in shell $$ is the pid , no need to do any jugglery with ps )

Bye
Ram




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




Perl::Optomizer

2004-05-12 Thread JupiterHost.Net
Hello list,

Perl::Tidy is very excellent for making source look nice.
I was wondering if anyone knew of anything that is the same type of idea 
but it optomizes your Perl code to run a bit faster:
 for instance:
   $newvariable = "$howdy";
 should be:
   $newvariable = $howdy;
and
  $stuff = "hello";
 shoudl be:
  $stuff = 'hello';
etc

 $str = CGI::header() . "hello" . $v;

woudl become
 $str = CGI::header(),"hello", $v;
that sort of thing...

TIA

Lee.M - JupiterHost.Net

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



RE: How to find files in subdirectory

2004-05-12 Thread Tim Johnson

Check the documentation for the File::Find module.  It comes standard
with most Perl distributions. 

-Original Message-
From: LK Tee [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 12, 2004 6:52 PM
To: '[EMAIL PROTECTED]'
Subject: How to find files in subdirectory

Hi, I'm perls beginner now, I have a problem when create a script find
all file in subdirectory that have the same filename. How I write the
script using perl and return the result like below:

 

File1: ~/A/File~/A/AA/file1   ~/A/C/CC/CCC/file

 

Kuan.



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




How to find files in subdirectory

2004-05-12 Thread LK Tee
Hi, I'm perls beginner now, I have a problem when create a script find all
file in subdirectory that have the same filename. How I write the script
using perl and return the result like below:

 

File1: ~/A/File~/A/AA/file1   ~/A/C/CC/CCC/file

 

Kuan.



RE : DBD for SQL Server?

2004-05-12 Thread Jose Nyimi


> -Message d'origine-
> De : Richard Crawford [mailto:[EMAIL PROTECTED]
> Envoyé : mercredi 12 mai 2004 22:17
> À : NYIMI Jose (BMB)
> Cc : Alok Bhatt; [EMAIL PROTECTED]
> Objet : Re: DBD for SQL Server?
> 
> NYIMI Jose (BMB) wrote:
> 
> >
> >>-Original Message-
> >>From: Alok Bhatt [mailto:[EMAIL PROTECTED]
> >>Sent: Wednesday, May 12, 2004 11:49 AM
> >>To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> >>Subject: Re: DBD for SQL Server?
> >>
> >>
> >>
> >>--- Richard Crawford <[EMAIL PROTECTED]>
> >>wrote:
> >>
> >>>Is there a DBD for SQL Server so that I can connect
> >>>to our SQL Server
> >>>2000 database with DBI?  I've hunted all over CPAN
> >>>but I can't seem to
> >>>find one.
> >>
> >>Windows uses the Open Database Connectivity (ODBC)
> >>Model. You can connect to an MS-SQL server using
> >>Win32::ODBC, available at
> >
> >
> > Then you will no longer be using DBI API (what OP wanted) !
> >
> > The advantage of DBD::ODBC (or DBD::ADO )
> > Is the portability of your code since you
> > Will be using the same api syntax regarless the
> > The database driver (DBD) you are dealing with behind DBI.
> >
> > The connection is always
> > my $dbh=DBI->connect(...);
> >
> > Not a new api like:
> > $Data = new Win32::ODBC(...);
> > Which obviously will not work if you need
> > To use your same code on a database running on unix box.
> >
> > HTH,
> >
> > José.
> 
> I've learned that in order to use DBD::ODBC I will still need to
install
> an ODBC driver on the machine (which is actually running Solaris 9).
> Not a problem, if I can find one.

http://www.unixodbc.org/

José.



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




Is there a way to get a PID from a process name?

2004-05-12 Thread Michael Terry
Hi,

I've got this shell script:

#!/bin/sh
ps axc|awk "{if (\$5==\"$1\") print \$1}";
... which gets a PID if you feed it the process' name. Is there a way 
to translate this into Perl using a standard Perl distribution? I mean, 
without calling 'ps'; I've learned enough Perl now to be able to do 
that, but I'd like to see if there's a cleaner way. I don't know, maybe 
process names aren't something other operating systems have, so Perl 
doesn't have anything for them--I'm on Mac OS X.

I checked everything that was indexed in Programming Perl that looked 
likely, but obviously I didn't find anything.

Michael

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



simulating bash

2004-05-12 Thread Andrew Gaffney
As part of a program I'm writing, I need to read some variables from a bash 
script and do some bash-style interpolation. My current code:

sub get_depend {
  my $ebuildfname = shift;
  my $ebuildcontents;
  my %ebuildvars;
  my $pkgname = $ebuildfname;
  $pkgname =~ s|/usr/portage/||;
  $pkgname =~ s|(.+)/.+/(.+).ebuild|$1/$2|;
  my $pkg = parse_package_name($pkgname);
  $pkg->{version} =~ s/^-//;
  $ebuildvars{PV} = "$pkg->{version}";
  open EBUILD, "< $ebuildfname" or die "Couldn't open '$ebuildfname'\n";
  while() {
$ebuildcontents .= $_;
  }
  close EBUILD;
  while($ebuildcontents =~ /\b([-A-Z0-9_]+)=\"(.*?)\"{1}?/sgc) {
$ebuildvars{$1} = $2;
  }
  foreach(keys %ebuildvars) {
$ebuildvars{$_} =~ s/\$\{?([-A-Z0-9_]+)\}?/$ebuildvars{$1}/gs;
  }
  my $depend = $ebuildvars{'DEPEND'} || '';
  $depend =~ s/(\s+|\n+)/ /gs;
  return $depend;
}
This works to do one-pass interpolation, but it doesn't get all the variables 
(for example: VAR1="something $VAR2" VAR2="test $VAR3" VAR3="anything $VAR4" 
would give me VAR1="something test $VAR3" VAR2="test $VAR3" VAR3="anything 
$VAR4"). How can I make this work without actually calling bash?

--
Andrew Gaffney
Network Administrator
Skyline Aeronautics, LLC.
636-357-1548
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: WWW::Mechanize question / array values

2004-05-12 Thread JupiterHost.Net
Next and hopefully last question for now on a more general subject: Why do
array members take the form of 'ARRAY(0x90df74)' rather than the actual
content fed to an array or variable?
Whatever variable looks like that when printed if an array reference.

for(@links) {
 print @{$_};
}
see
 perldoc perlref
HTH

Lee.M - JupiterHost.Net

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



Re: dependency tree

2004-05-12 Thread Jeff 'japhy' Pinyan
On May 12, Andrew Gaffney said:

>> This sounds like postorder tree traversal to me:
>
>I've seen that term before when looking into this, but I don't know what
>it means.

I'd suggest bookmarking the wikipedia, it has a lot of encyclopedia-style
definitions (read, long texts and examples) of computer terminology:

  http://en.wikipedia.org/wiki/Pre-order_traversal

is a page about binary trees and talks about pre-, in-, and post-order
traversal.

(Wikipedia.org is not strictly computer stuff, but it's got a boat-load of
computer stuff.)

See also the Free On-Line Dictionary of Computing (FOLDOC) -- it's often
less verbose (or more terse, depending on what vocabulary you like to use)
but it's helpful nonetheless:

  http://wombat.doc.ic.ac.uk/foldoc/foldoc.cgi?traversal

>>   postorder(\%tree, 'package1');
>>
>>   sub postorder {
>> my ($tree, $pkg, $seen) = @_;
>> return if $seen->{$pkg}++;  # to stop from traversing a node twice
>>
>> postorder($tree, $_, $seen) for @{ $tree->{$pkg} };
>> print "$pkg\n";
>>   }
>
>Is $seen another hash that should be passed as a reference to postorder() ?

You don't need to send it in your outermost call to it.  That's the
beauty of Perl.  The first time the function is called (assuming you DON'T
pass it a third argument) $seen is undef.  When we say $seen->{$pkg}++,
Perl automatically makes $seen a hash reference.  Then, for all the
recursive calls in the function itself, you see that we DO pass $seen.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
CPAN ID: PINYAN[Need a programmer?  If you like my work, let me know.]
 what does y/// stand for?   why, yansliterate of course.


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




Re: form based htaccess logins

2004-05-12 Thread Kevin Old
On Wed, 2004-05-12 at 17:34, [EMAIL PROTECTED] wrote:
> Hello.
> 
> I'm looking for a script, and definitly willing to roll my own, that
> interacts with htaccess.  It is quite simple to validate user input against
> the .htpasswd file and authenticate them into a given directory.  But i
> need Apache to accept the user as a valid user, and not repompt with the
> basic HTTP Password challange.
> 
> This used to be very simple, yet not all that secure, just using
> JavaScript, but since the February patch to IE 6 it failes with that
> browser, which unfortunately is a good amount of user traffic ...why when
> theres FireFox? ;)
> 
> This is all so users can login to their respective folders using a form in
> lieu of the browser-based loginand i'd rather do it a completely
> different way( or just have them use htaccess), but alas, its not up to
> me...
> 
> Any ideas/input would be appreciated.  I did find a lot of info googling,
> most of it pre 2000...but i'm off to do more
> 
> Confirmation that this is bad idea, is fine as well

Jeff,

I can suggest a mod_perl solutioncheckout these modules on CPAN:

Apache:AuthCookie
Apache::AuthCookieDBI
Apache::AuthDBI

One of these should do it and should be easy to use.  Just read the POD
that comes with each.

HTH,
Kevin
-- 
Kevin Old <[EMAIL PROTECTED]>


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




Resources for VB.NET integration

2004-05-12 Thread John Goodleaf
I'm now working in an environment in which I'll have to deploy
VB.NET apps (don't blame me). Anyway, I have some perl stuff I'd
like not to reinvent in VB, dealing with database reporting. Are
there any good resources that will show me how I might deploy a
VB-based form that actually runs a Perl program rather than a VB
program? I've just downloaded trials of ActiveState's PerlNet but I
haven't the time to read everything. I'm hoping you all can help me
triage.

Thanks,
John

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




Re: WWW::Mechanize question / array values

2004-05-12 Thread Ben Miller
On 5/12/04 1:26 PM, Paul Johnson wrote:

> On Wed, May 12, 2004 at 12:59:44PM -0500, Ben Miller wrote:
> 
>> my @links = $mech->find_all_links(tag = "a", text_regex => qr/\bWORD\b/i );
> 
> ... tag => "a", ...
> 
> I suspect.


Thank you to Paul and to Lee for their quick and efficient answer. That was
exactly the problem.

Next and hopefully last question for now on a more general subject: Why do
array members take the form of 'ARRAY(0x90df74)' rather than the actual
content fed to an array or variable?


Thanks,
Ben


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




Re: dependency tree

2004-05-12 Thread Andrew Gaffney
Jeff 'japhy' Pinyan wrote:
On May 12, Andrew Gaffney said:


my %tree = { package1 => [ package2, package3, package4 ],
package2 => [ package7 ],
package3 => [ package5 ],
package4 => [ package7, package6],
package5 => [ ],
package6 => [ ],
package7 => [ ] };


You have curly braces { ... } where you want parentheses ( ... ).
Whoops. I'm usually use hash references instead of actual hashes.

Now, I want to walk the tree starting with a known "package1" and build an
ordered list of packages to install. For example:
package7
package2
package5
package3
(no package7 here because it is already in the list)
package6
package4
package1
This sounds like postorder tree traversal to me:
I've seen that term before when looking into this, but I don't know what it means.

  // pseudocode
  postorder (tree) {
if tree is null: return
for node in tree.nodes: postorder(node)
print tree
  }
With your hash, in perl, this would look like:

  postorder(\%tree, 'package1');

  sub postorder {
my ($tree, $pkg, $seen) = @_;
return if $seen->{$pkg}++;  # to stop from traversing a node twice
postorder($tree, $_, $seen) for @{ $tree->{$pkg} };
print "$pkg\n";
  }
This gives the expected output.
Is $seen another hash that should be passed as a reference to postorder() ?

I also want to be able to track what package is a dependency of what
(which key a certain value is under) with my tree structure. What is the
easiest way to do this? Is there a better way to do this?
You'd need another structure somewhere.  Starting with this:

  my %tree = (
package1 => [ qw( package2 package3 package4 ) ],
package2 => [ qw( package7 ) ],
package3 => [ qw( package5 ) ],
package4 => [ qw( package7 package6 ) ],
package5 => [ ],
package6 => [ ],
package7 => [ ],
  );
You could then do:

  my %parents_of;

  for my $p (keys %tree) {
push @{ $parents_of{$_} }, $p for @{ $tree{$p} };
  }
If you can't understand that code, let me unroll it a bit for you:

  for my $parent (keys %tree) {
for my $kid (@{ $tree{$parent} }) {
  push @{ $parents_of{$kid} }, $parent;
}
  }
Now you have another hash of arrays that is basically the inverse of
%tree:
  %parents_of = (
package4 => [ 'package1' ],
package5 => [ 'package3' ],
package6 => [ 'package4' ],
package7 => [ 'package4', 'package2' ],
package2 => [ 'package1' ],
package3 => [ 'package1' ],
  );
Nice. Thank you. I'll give this a try.

--
Andrew Gaffney
Network Administrator
Skyline Aeronautics, LLC.
636-357-1548
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



dependency tree

2004-05-12 Thread Andrew Gaffney
In a program I'm working on, I build a hash "tree" of sorts that contains 
package dependencies. Each key contains an array with the first level 
dependencies of the key. Each one of those dependencies have their own key with 
their first level dependencies in the hash. For example:

my %tree = { package1 => [ package2, package3, package4 ],
 package2 => [ package7 ],
 package3 => [ package5 ],
 package4 => [ package7, package6],
 package5 => [ ],
 package6 => [ ],
 package7 => [ ] };
Now, I want to walk the tree starting with a known "package1" and build an 
ordered list of packages to install. For example:

package7
package2
package5
package3
(no package7 here because it is already in the list)
package6
package4
package1
I also want to be able to track what package is a dependency of what (which key 
a certain value is under) with my tree structure. What is the easiest way to do 
this? Is there a better way to do this?

--
Andrew Gaffney
Network Administrator
Skyline Aeronautics, LLC.
636-357-1548
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



form based htaccess logins

2004-05-12 Thread jeffrey_n_Dyke
Hello.

I'm looking for a script, and definitly willing to roll my own, that
interacts with htaccess.  It is quite simple to validate user input against
the .htpasswd file and authenticate them into a given directory.  But i
need Apache to accept the user as a valid user, and not repompt with the
basic HTTP Password challange.

This used to be very simple, yet not all that secure, just using
JavaScript, but since the February patch to IE 6 it failes with that
browser, which unfortunately is a good amount of user traffic ...why when
theres FireFox? ;)

This is all so users can login to their respective folders using a form in
lieu of the browser-based loginand i'd rather do it a completely
different way( or just have them use htaccess), but alas, its not up to
me...

Any ideas/input would be appreciated.  I did find a lot of info googling,
most of it pre 2000...but i'm off to do more

Confirmation that this is bad idea, is fine as well

TIA,
Jeff



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




Re: return array/hash ref from function

2004-05-12 Thread Andrew Gaffney
Andrew Gaffney wrote:
Wiggins d Anconia wrote:

Wiggins d Anconia wrote:



my %masks;
my %use;
my @pkglist;
my %pkgdeps;


Why are these declared with a global scope?  If they must be then
something is wrong with your subs.  Move these to after your sub
listing, if your program still works then they are fine as globals,
otherwise you have broken encapsulation and that leads to more complex
code.  It also means you are not letting 'strict' help you in the 
manner
it was designed to.


Nope, I need %masks, %use, and %pkgdeps to be global because multiple 
subroutines will need access to them.


And that is the exact reason not to do it.  The code is becoming
spaghetti code because of this very reason, and generally indicates a
design issue.  Step back and take a look at your data, then come up with
the routines (aka this is where OOP comes in).  If you allow your subs
to break encapsulation like this then tracking down the kind of bug you
mention gets progressively more difficult, and becomes a maintenance
nightmare in the future, as well as a testing nightmare.  It also may
mean you will get less help from the list ;-), which is why we stress
'strict' so much, otherwise it becomes a risk to soak up our time as
well as your own.


How could I redesign it that these global configuration values are 
accessible to the functions that need them but aren't actually global?

[snip subs]


init();

my $original = build_deptree($ARGV[0]);
use Data::Dumper;
print Dumper(%pkgdeps);


Based on this snippet you should have need for only one global,
$original.  Everything else should be lexical non-file scoped. Remember
that subs should take values and return values, your init() does 
neither
which means its contents can be moved into main, or into build_deptree,
or you need to be passing it something.


This program is far from complete. There will be many more functions
that will need access to those global variables. I put those 
configuration
subroutine calls into init() because it cleans up the main code a bit.


See above, I know that, but that doesn't mean it is the best way :-).

Try moving all of your subs into a library and keeping your main
separate, use 'strict' in both files, make every variable 'my'd, when
that works I suspect your problems will be solved. 


This still holds.


I'll have to figure out how to redesign the configuration variables 
before I can do this.
Well, no need for the moment. After uncommenting 'use warnings' and going 
through the output and fixing each warning, it works. I changed way too many 
things to say which one in particular worked.

--
Andrew Gaffney
Network Administrator
Skyline Aeronautics, LLC.
636-357-1548
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: DBD for SQL Server?

2004-05-12 Thread Kevin Old
On Tue, 2004-05-11 at 18:40, Richard Crawford wrote:
> Is there a DBD for SQL Server so that I can connect to our SQL Server 
> 2000 database with DBI?  I've hunted all over CPAN but I can't seem to 
> find one.

Richard,

I'm running a mod_perl site connected to a SQL Server 2000 backend via
DBD::ODBC with a driver from OpenlinkSW.

Go to http://www.openlinksw.com.  They will let you download a full
working driver, but it has a 30 license.  If you need more than 30 days
you'll have to redownload the driver and it'll email you another 30 day
license.  It took us about 6 months of "testing" before we bought the
driver for about $600, buti it was well worth it.

They'll also give you the iODBC SDK (driver manager) and phone support
even if you're evaluating.  Lot's of praise on the phone support as they
worked with me for 5 days and had a developer helping me as I was having
trouble getting it interfaced with mod_perl for some weird reason.  Long
story short mod_perl was only seeing unixODBC (another driver manager)
and so I had use unixODBC instead of iODBC.  No biggie, it was tracking
this down that was the problem.

Hope this helps,
Kevin
-- 
Kevin Old <[EMAIL PROTECTED]>


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




Re: return array/hash ref from function

2004-05-12 Thread Andrew Gaffney
Wiggins d Anconia wrote:
Wiggins d Anconia wrote:


my %masks;
my %use;
my @pkglist;
my %pkgdeps;
Why are these declared with a global scope?  If they must be then
something is wrong with your subs.  Move these to after your sub
listing, if your program still works then they are fine as globals,
otherwise you have broken encapsulation and that leads to more complex
code.  It also means you are not letting 'strict' help you in the manner
it was designed to.
Nope, I need %masks, %use, and %pkgdeps to be global because multiple 
subroutines will need access to them.
And that is the exact reason not to do it.  The code is becoming
spaghetti code because of this very reason, and generally indicates a
design issue.  Step back and take a look at your data, then come up with
the routines (aka this is where OOP comes in).  If you allow your subs
to break encapsulation like this then tracking down the kind of bug you
mention gets progressively more difficult, and becomes a maintenance
nightmare in the future, as well as a testing nightmare.  It also may
mean you will get less help from the list ;-), which is why we stress
'strict' so much, otherwise it becomes a risk to soak up our time as
well as your own.
How could I redesign it that these global configuration values are accessible to 
the functions that need them but aren't actually global?

[snip subs]


init();

my $original = build_deptree($ARGV[0]);
use Data::Dumper;
print Dumper(%pkgdeps);
Based on this snippet you should have need for only one global,
$original.  Everything else should be lexical non-file scoped. Remember
that subs should take values and return values, your init() does neither
which means its contents can be moved into main, or into build_deptree,
or you need to be passing it something.
This program is far from complete. There will be many more functions
that will need access to those global variables. I put those configuration
subroutine calls into init() because it cleans up the main code a bit.
See above, I know that, but that doesn't mean it is the best way :-).

Try moving all of your subs into a library and keeping your main
separate, use 'strict' in both files, make every variable 'my'd, when
that works I suspect your problems will be solved. 
This still holds.
I'll have to figure out how to redesign the configuration variables before I can 
do this.

--
Andrew Gaffney
Network Administrator
Skyline Aeronautics, LLC.
636-357-1548
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: DBD for SQL Server?

2004-05-12 Thread Richard Crawford
NYIMI Jose (BMB) wrote:


-Original Message-
From: Alok Bhatt [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 12, 2004 11:49 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: DBD for SQL Server?



--- Richard Crawford <[EMAIL PROTECTED]>
wrote:
Is there a DBD for SQL Server so that I can connect
to our SQL Server
2000 database with DBI?  I've hunted all over CPAN
but I can't seem to 
find one.
Windows uses the Open Database Connectivity (ODBC)
Model. You can connect to an MS-SQL server using
Win32::ODBC, available at 


Then you will no longer be using DBI API (what OP wanted) !

The advantage of DBD::ODBC (or DBD::ADO )
Is the portability of your code since you
Will be using the same api syntax regarless the
The database driver (DBD) you are dealing with behind DBI.
The connection is always
my $dbh=DBI->connect(...);
Not a new api like:
$Data = new Win32::ODBC(...);
Which obviously will not work if you need
To use your same code on a database running on unix box.
HTH,

José.
I've learned that in order to use DBD::ODBC I will still need to install 
an ODBC driver on the machine (which is actually running Solaris 9). 
Not a problem, if I can find one.

--
Richard S. Crawford
Programmer III,
UC Davis Extension Distance Learning Group (http://unexdlc.ucdavis.edu)
(916)327-7793 / [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: return array/hash ref from function

2004-05-12 Thread Wiggins d Anconia
> Wiggins d Anconia wrote:

> >>
> >>my %masks;
> >>my %use;
> >>my @pkglist;
> >>my %pkgdeps;
> > 
> > Why are these declared with a global scope?  If they must be then
> > something is wrong with your subs.  Move these to after your sub
> > listing, if your program still works then they are fine as globals,
> > otherwise you have broken encapsulation and that leads to more complex
> > code.  It also means you are not letting 'strict' help you in the manner
> > it was designed to.
> 
> Nope, I need %masks, %use, and %pkgdeps to be global because multiple 
> subroutines will need access to them.
>

And that is the exact reason not to do it.  The code is becoming
spaghetti code because of this very reason, and generally indicates a
design issue.  Step back and take a look at your data, then come up with
the routines (aka this is where OOP comes in).  If you allow your subs
to break encapsulation like this then tracking down the kind of bug you
mention gets progressively more difficult, and becomes a maintenance
nightmare in the future, as well as a testing nightmare.  It also may
mean you will get less help from the list ;-), which is why we stress
'strict' so much, otherwise it becomes a risk to soak up our time as
well as your own.
 
> > [snip subs]
> > 
> >>init();
> >>
> >>my $original = build_deptree($ARGV[0]);
> >>use Data::Dumper;
> >>print Dumper(%pkgdeps);
> > 
> > Based on this snippet you should have need for only one global,
> > $original.  Everything else should be lexical non-file scoped. Remember
> > that subs should take values and return values, your init() does neither
> > which means its contents can be moved into main, or into build_deptree,
> >  or you need to be passing it something.
> 
> This program is far from complete. There will be many more functions
that will 
> need access to those global variables. I put those configuration
subroutine 
> calls into init() because it cleans up the main code a bit.
> 

See above, I know that, but that doesn't mean it is the best way :-).


> > Try moving all of your subs into a library and keeping your main
> > separate, use 'strict' in both files, make every variable 'my'd, when
> > that works I suspect your problems will be solved. 
> 

This still holds.

http://danconia.org


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




Re: return array/hash ref from function

2004-05-12 Thread Andrew Gaffney
Wiggins d Anconia wrote:
Charles K. Clarkson wrote:

Andrew Gaffney <[EMAIL PROTECTED]> wrote:
: 
: I think that 'my' is bad because I have something similar to:
: 
: my %tree;
: 
: sub return_an_arrayref() {
:my @array = ('thing1', 'thing2', 'thing3');
:return [EMAIL PROTECTED];
: }
: 
: sub build_tree() {
:foreach(@thing) {
:  $tree{$_} = return_an_arrayref();
:}
: }
: 
: use Data::Dumper;
: print Dumper(%tree);
: 
: The output shows a bunch of empty arrays or arrays with
: all undef elements under each key in %tree. I know
: return_an_arrayref() is returning data because I can
: print all the elements out in build_tree().

Remember Finagle's Third Law:

"In any collection of data, the figure most obviously
 correct, beyond all need of checking, is the mistake."
   Your results indicate that return_an_arrayref() does
sometimes return a reference to an empty array. Show us
unedited code for more help.
Alright, you asked for it. In order to run this program, you will need
to be 

running Gentoo Linux as this program uses the Portage tree and
Portage's config 

files.

Ok, slow down killer :-).  

#!/usr/bin/perl

use strict;
#use warnings;
#use Getopt::Long;

my %masks;
my %use;
my @pkglist;
my %pkgdeps;
Why are these declared with a global scope?  If they must be then
something is wrong with your subs.  Move these to after your sub
listing, if your program still works then they are fine as globals,
otherwise you have broken encapsulation and that leads to more complex
code.  It also means you are not letting 'strict' help you in the manner
it was designed to.
Nope, I need %masks, %use, and %pkgdeps to be global because multiple 
subroutines will need access to them.

[snip subs]

init();

my $original = build_deptree($ARGV[0]);
use Data::Dumper;
print Dumper(%pkgdeps);
Based on this snippet you should have need for only one global,
$original.  Everything else should be lexical non-file scoped. Remember
that subs should take values and return values, your init() does neither
which means its contents can be moved into main, or into build_deptree,
 or you need to be passing it something.
This program is far from complete. There will be many more functions that will 
need access to those global variables. I put those configuration subroutine 
calls into init() because it cleans up the main code a bit.

Try moving all of your subs into a library and keeping your main
separate, use 'strict' in both files, make every variable 'my'd, when
that works I suspect your problems will be solved. 
--
Andrew Gaffney
Network Administrator
Skyline Aeronautics, LLC.
636-357-1548
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: return array/hash ref from function

2004-05-12 Thread Wiggins d Anconia
[snip]

> 
> It was more pseudocode than anything. I can't seem to duplicate the
problem with 
> test code. One thing I forgot to mention is that these functions are
called 
> recursively as far as 15 levels deep. Would that cause issues when
returning a 
> ref to a 'my'ed array from a function?
> 

Shouldn't, in fact it should be helping to prevent that type of problem,
but you have to make sure you are truly passing and returning, not just
setting values in globals see my other email.

http://danconia.org


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




Re: return array/hash ref from function

2004-05-12 Thread Wiggins d Anconia
> Charles K. Clarkson wrote:
> > Andrew Gaffney <[EMAIL PROTECTED]> wrote:
> > : 
> > : I think that 'my' is bad because I have something similar to:
> > : 
> > : my %tree;
> > : 
> > : sub return_an_arrayref() {
> > :my @array = ('thing1', 'thing2', 'thing3');
> > :return [EMAIL PROTECTED];
> > : }
> > : 
> > : sub build_tree() {
> > :foreach(@thing) {
> > :  $tree{$_} = return_an_arrayref();
> > :}
> > : }
> > : 
> > : use Data::Dumper;
> > : print Dumper(%tree);
> > : 
> > : The output shows a bunch of empty arrays or arrays with
> > : all undef elements under each key in %tree. I know
> > : return_an_arrayref() is returning data because I can
> > : print all the elements out in build_tree().
> > 
> > Remember Finagle's Third Law:
> > 
> >  "In any collection of data, the figure most obviously
> >   correct, beyond all need of checking, is the mistake."
> > 
> > 
> > Your results indicate that return_an_arrayref() does
> > sometimes return a reference to an empty array. Show us
> > unedited code for more help.
> 
> Alright, you asked for it. In order to run this program, you will need
to be 
> running Gentoo Linux as this program uses the Portage tree and
Portage's config 
> files.
>

Ok, slow down killer :-).  
 
> #!/usr/bin/perl
> 
> use strict;
> #use warnings;
> 
> #use Getopt::Long;
> 
> my %masks;
> my %use;
> my @pkglist;
> my %pkgdeps;
> 

Why are these declared with a global scope?  If they must be then
something is wrong with your subs.  Move these to after your sub
listing, if your program still works then they are fine as globals,
otherwise you have broken encapsulation and that leads to more complex
code.  It also means you are not letting 'strict' help you in the manner
it was designed to.

[snip subs]

> 
> init();
> 
> my $original = build_deptree($ARGV[0]);
> use Data::Dumper;
> print Dumper(%pkgdeps);
> 

Based on this snippet you should have need for only one global,
$original.  Everything else should be lexical non-file scoped. Remember
that subs should take values and return values, your init() does neither
which means its contents can be moved into main, or into build_deptree,
 or you need to be passing it something.

Try moving all of your subs into a library and keeping your main
separate, use 'strict' in both files, make every variable 'my'd, when
that works I suspect your problems will be solved. 

http://danconia.org

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




Re: return array/hash ref from function

2004-05-12 Thread Andrew Gaffney
Wiggins d Anconia wrote:
Wiggins d Anconia wrote:

I have a number of functions in a program I'm writing that return a
reference to 


an array or hash. In the functions, I declare the variable to return
with 'my' 


which I'm finding out is bad. Should I declare variables to return
from a 

function with 'our'? Do I need to make sure I don't have conflicting
variable 


names from other functions? What pitfalls do I need to know about when
doing this?

Need to address why you think creating them with 'my' is bad when
returning them first, it isn't (as long as you are truly returning
them).  Use 'my' until you know you don't :-).
See if this helps:

http://perl.plover.com/FAQs/Namespaces.html

It is *well* worth the read...
I think that 'my' is bad because I have something similar to:

my %tree;

sub return_an_arrayref() {
  my @array = ('thing1', 'thing2', 'thing3');
  return [EMAIL PROTECTED];
}
sub build_tree() {
  foreach(@thing) {
$tree{$_} = return_an_arrayref();
  }
}
use Data::Dumper;
print Dumper(%tree);
The output shows a bunch of empty arrays or arrays with all undef
elements under 

each key in %tree. I know return_an_arrayref() is returning data
because I can 

print all the elements out in build_tree().



Ah, turn on strict and warnings. See if that helps, if not come back
:-).  This is why these two pragma are so critical.
For me your code will not run.
It was more pseudocode than anything. I can't seem to duplicate the problem with 
test code. One thing I forgot to mention is that these functions are called 
recursively as far as 15 levels deep. Would that cause issues when returning a 
ref to a 'my'ed array from a function?

--
Andrew Gaffney
Network Administrator
Skyline Aeronautics, LLC.
636-357-1548
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: return array/hash ref from function

2004-05-12 Thread Andrew Gaffney
Charles K. Clarkson wrote:
Andrew Gaffney <[EMAIL PROTECTED]> wrote:
: 
: I think that 'my' is bad because I have something similar to:
: 
: my %tree;
: 
: sub return_an_arrayref() {
:my @array = ('thing1', 'thing2', 'thing3');
:return [EMAIL PROTECTED];
: }
: 
: sub build_tree() {
:foreach(@thing) {
:  $tree{$_} = return_an_arrayref();
:}
: }
: 
: use Data::Dumper;
: print Dumper(%tree);
: 
: The output shows a bunch of empty arrays or arrays with
: all undef elements under each key in %tree. I know
: return_an_arrayref() is returning data because I can
: print all the elements out in build_tree().

Remember Finagle's Third Law:

 "In any collection of data, the figure most obviously
  correct, beyond all need of checking, is the mistake."
Your results indicate that return_an_arrayref() does
sometimes return a reference to an empty array. Show us
unedited code for more help.
Alright, you asked for it. In order to run this program, you will need to be 
running Gentoo Linux as this program uses the Portage tree and Portage's config 
files.

#!/usr/bin/perl

use strict;
#use warnings;
#use Getopt::Long;

my %masks;
my %use;
my @pkglist;
my %pkgdeps;
sub get_masks {
  my @maskfiles = ("/usr/portage/profiles/package.mask", 
"/etc/portage/package.mask");

  foreach my $maskfile (@maskfiles) {
open MASKS, "< $maskfile" or next;
while() {
  chomp;
  next if($_ eq '' || /^#/);
  my $list = expand_package_list($_, 1);
  foreach my $pkg (@$list) {
$masks{$pkg} = 1;
  }
}
close MASKS;
  }
}
sub get_unmasks {
  my @maskfiles = ("/etc/portage/package.unmask");
  foreach my $maskfile (@maskfiles) {
open UNMASKS, "< $maskfile" or next;
while() {
  chomp;
  next if($_ eq '' || /^#/);
  my $list = expand_package_list($_, 1);
  foreach my $pkg (@$list) {
delete $masks{$pkg} if(exists $masks{$pkg});
  }
}
close UNMASKS;
  }
}

sub process_use_flags {
  my $useflags = shift;
  $useflags =~ s/(\\|\n)/ /sg;
  $useflags =~ s/\s+/ /g;
  my @useflags = split /\s+/, $useflags;
  foreach(@useflags) {
if($_ eq '-*') {
  foreach(keys %use) {
delete $use{$_};
  }
} elsif(/^-(.+)$/) {
  delete $use{$1} if(exists $use{$1});
} else {
  $use{$_} = 1;
}
  }
}
sub get_make_config {
  my @makeconfs = ("/etc/make.profile/make.defaults", "/etc/make.conf");
  my $makecontents;
  foreach my $makeconf (@makeconfs) {
open MAKECONF, "< $makeconf" or next;
while() {
  $makecontents .= $_;
}
close MAKECONF;
$makecontents =~ /\s+USE=\"(.+?)\"{1}?/s;
my $useflags = $1;
process_use_flags($useflags);
  }
}
sub get_env_config {
  my $useflags = $ENV{USE};
  process_use_flags($useflags) if($useflags ne '');
}
sub enable_autouse {
  open USE, "< /etc/make.profile/use.defaults" or die "Can't open use.defaults\n";
  foreach() {
next if(/^(#.+)?$/);
/^(.+)\s+(.+)$/;
foreach(split /\s+/, $2) {
  my ($useflag, $pkgname) = ($1, $2);
  process_use_flags($useflag) if(check_package_installed($pkgname));
}
  }
}
sub init {
  get_masks();
  get_unmasks();
  get_make_config();
  get_env_config();
  enable_autouse();
  print join(', ', sort keys %use) . "\n";
}
sub get_depend {
  my $ebuildfname = shift;
  my $ebuildcontents;
  my %ebuildvars;
  my $pkgname = $ebuildfname;
  $pkgname =~ s|/usr/portage/||;
  $pkgname =~ s|(.+)/.+/(.+).ebuild|$1/$2|;
  my $pkg = parse_package_name($pkgname);
  $pkg->{version} =~ s/^-//;
  $ebuildvars{PV} = "$pkg->{version}";
  open EBUILD, "< $ebuildfname" or die "Couldn't open '$ebuildfname' to get 
DEPEND\n";
  while() {
$ebuildcontents .= $_;
  }
  close EBUILD;
  while($ebuildcontents =~ /\b([-A-Z0-9_]+)=\"(.*?)\"{1}?/sgc) {
$ebuildvars{$1} = $2;
  }
  foreach(keys %ebuildvars) {
$ebuildvars{$_} =~ s/\$\{?([-A-Z0-9_]+)\}?/$ebuildvars{$1}/gs;
  }

  my $depend = $ebuildvars{'DEPEND'};
  $depend =~ s/(\s+|\n+)/ /gs;
  return $depend;
}
sub check_package_installed {
  my $pkgname = shift;
  my $pkg = parse_package_name($pkgname);
  if($pkg->{version} eq '') {
opendir PKGDIR, "/var/db/pkg/$pkg->{category}" or die "Can't open directory 
'/var/db/pkg/$pkg->{category}'\n";
my @pkgs = grep { /^$pkg->{name}-/ } readdir(PKGDIR);
close PKGDIR;
push @pkgs, '';
return 1 if($#pkgs);
  } else {
my $pkgdir = 
"/var/db/pkg/$pkg->{category}/$pkg->{name}$pkg->{version}$pkg->{suffix}$pkg->{revision}";
return 1 if(-d $pkgdir);
  }

  return 0;
}
sub expand_depend {
  my $depstring = shift;
  my @deplist;
  my $paren = 0;
  my @skipuseflag = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  $depstring =~ s/\s*\(\s*/ ( /g;
  $depstring =~ s/\s*\)\s*/ ) /g;
  my @depparts = split /\s+/, $depstring;
  for my $lv (0..$#depparts) {
#print "$lv - $depparts[$lv] - skipuseflag[$paren] = $skipuseflag[$paren]\n";
if($depparts[$lv] eq '(') {
  $paren++;
#  print "Found '(', skipuseflag[$paren] = $skipuseflag[$paren], paren =

RE: return array/hash ref from function

2004-05-12 Thread Charles K. Clarkson
Andrew Gaffney <[EMAIL PROTECTED]> wrote:
: 
: I think that 'my' is bad because I have something similar to:
: 
: my %tree;
: 
: sub return_an_arrayref() {
:my @array = ('thing1', 'thing2', 'thing3');
:return [EMAIL PROTECTED];
: }
: 
: sub build_tree() {
:foreach(@thing) {
:  $tree{$_} = return_an_arrayref();
:}
: }
: 
: use Data::Dumper;
: print Dumper(%tree);
: 
: The output shows a bunch of empty arrays or arrays with
: all undef elements under each key in %tree. I know
: return_an_arrayref() is returning data because I can
: print all the elements out in build_tree().

Remember Finagle's Third Law:

 "In any collection of data, the figure most obviously
  correct, beyond all need of checking, is the mistake."


Your results indicate that return_an_arrayref() does
sometimes return a reference to an empty array. Show us
unedited code for more help.


HTH,

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





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




Re: return array/hash ref from function

2004-05-12 Thread Wiggins d Anconia
> Wiggins d Anconia wrote:
> >>I have a number of functions in a program I'm writing that return a
> > 
> > reference to 
> > 
> >>an array or hash. In the functions, I declare the variable to return
> > 
> > with 'my' 
> > 
> >>which I'm finding out is bad. Should I declare variables to return
from a 
> >>function with 'our'? Do I need to make sure I don't have conflicting
> > 
> > variable 
> > 
> >>names from other functions? What pitfalls do I need to know about when
> > 
> > doing this?
> > 
> > 
> > Need to address why you think creating them with 'my' is bad when
> > returning them first, it isn't (as long as you are truly returning
> > them).  Use 'my' until you know you don't :-).
> > 
> > See if this helps:
> > 
> > http://perl.plover.com/FAQs/Namespaces.html
> > 
> > It is *well* worth the read...
> 
> I think that 'my' is bad because I have something similar to:
> 
> my %tree;
> 
> sub return_an_arrayref() {
>my @array = ('thing1', 'thing2', 'thing3');
>return [EMAIL PROTECTED];
> }
> 
> sub build_tree() {
>foreach(@thing) {
>  $tree{$_} = return_an_arrayref();
>}
> }
> 
> use Data::Dumper;
> print Dumper(%tree);
> 
> The output shows a bunch of empty arrays or arrays with all undef
elements under 
> each key in %tree. I know return_an_arrayref() is returning data
because I can 
> print all the elements out in build_tree().
> 

Ah, turn on strict and warnings. See if that helps, if not come back
:-).  This is why these two pragma are so critical.

For me your code will not run.

http://danconia.org


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




Re: return array/hash ref from function

2004-05-12 Thread Andrew Gaffney
Wiggins d Anconia wrote:
I have a number of functions in a program I'm writing that return a
reference to 

an array or hash. In the functions, I declare the variable to return
with 'my' 

which I'm finding out is bad. Should I declare variables to return from a 
function with 'our'? Do I need to make sure I don't have conflicting
variable 

names from other functions? What pitfalls do I need to know about when
doing this?

Need to address why you think creating them with 'my' is bad when
returning them first, it isn't (as long as you are truly returning
them).  Use 'my' until you know you don't :-).
See if this helps:

http://perl.plover.com/FAQs/Namespaces.html

It is *well* worth the read...
I think that 'my' is bad because I have something similar to:

my %tree;

sub return_an_arrayref() {
  my @array = ('thing1', 'thing2', 'thing3');
  return [EMAIL PROTECTED];
}
sub build_tree() {
  foreach(@thing) {
$tree{$_} = return_an_arrayref();
  }
}
use Data::Dumper;
print Dumper(%tree);
The output shows a bunch of empty arrays or arrays with all undef elements under 
each key in %tree. I know return_an_arrayref() is returning data because I can 
print all the elements out in build_tree().

--
Andrew Gaffney
Network Administrator
Skyline Aeronautics, LLC.
636-357-1548
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: return array/hash ref from function

2004-05-12 Thread Wiggins d Anconia
> I have a number of functions in a program I'm writing that return a
reference to 
> an array or hash. In the functions, I declare the variable to return
with 'my' 
> which I'm finding out is bad. Should I declare variables to return from a 
> function with 'our'? Do I need to make sure I don't have conflicting
variable 
> names from other functions? What pitfalls do I need to know about when
doing this?
> 

Need to address why you think creating them with 'my' is bad when
returning them first, it isn't (as long as you are truly returning
them).  Use 'my' until you know you don't :-).

See if this helps:

http://perl.plover.com/FAQs/Namespaces.html

It is *well* worth the read...

http://danconia.org

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




return array/hash ref from function

2004-05-12 Thread Andrew Gaffney
I have a number of functions in a program I'm writing that return a reference to 
an array or hash. In the functions, I declare the variable to return with 'my' 
which I'm finding out is bad. Should I declare variables to return from a 
function with 'our'? Do I need to make sure I don't have conflicting variable 
names from other functions? What pitfalls do I need to know about when doing this?

--
Andrew Gaffney
Network Administrator
Skyline Aeronautics, LLC.
636-357-1548
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Text::KwikiFormatish on Win32 system

2004-05-12 Thread Hoenie Luk
Text::KwikiFormatish seems like a great module to format Wiki text into HTML.

However, when I install it and run it on my Windows XP system, I got tons 
of "Unrecognized escape \p ..." errors. Then the output has a lot of 
extraneous   anchored links where there should not be any.

Does anybody know how to make this module works on Win32?

Thanks.

.Hoenie

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



Re: Multi library

2004-05-12 Thread Wiggins d Anconia
Please bottom post

> my openconf function contains:
> 
> sub openconf {
>my $pkg = shift;
>my $self = bless([EMAIL PROTECTED],$pkg);
>open(...
>
>return($self);
> }
> 
> I have "my @config;" set at the beggining of the module
> 

As Lee pointed out it would be easier to help if we could see some real
code. 

However your last sentence is likely the first problem, you are making
@config lexical and file scoped, which means there is only one, so you
are in effect creating a singleton to access into.  Each time you call
your constructor you are really just reblessing a reference to the same
variable. I suspect you are just appending all of the values from one
config onto the other, that or you are clobbering all of them each time
you read the file, either way you are only going to end up with one set
of config values, which doesn't appear to be what you want.

I would suggest moving the my @config into the scope of the constructor,
(yet another case of the declare your variables when you use them rather
than at the top syndrome).  Of course since this is a config object that
appears to be accessible by key name rather than numerical index you
probably want to switch @config to %config, but that is a design
decision

You may want to read through the OOP documentation provided with the
perldocs, specifically,

perldoc perlboot

Like I said, don't rewrite the wheel

http://danconia.org

> -
> This mail is from: <[EMAIL PROTECTED]>
> -
> 
> On Wed, 12 May 2004, Wiggins d Anconia wrote:
> 
> > > Hi,
> > > I'm trying to create library that can open many config files. For
> > > examlpe, I have cfg1.conf and cfg2.conf. My lib is getting information
> > > from those files and store it into an array. If I do:
> > >
> > > my $cfg1 = My::Lib->openconf("cfg1.conf");
> > > my $cfg2 = My::Lib->openconf("cfg2.conf");
> > >
> > > print $cfg1->param("someparam");
> > > print $cfg2->param("someparam");
> > >
> > > it prints two times the param from second conf file. Any ideas or
I wasn't
> > > clear enough ?:")
> > > Btw sorry for my bad english
> > >
> >
> > We will probably need to see your My::Lib, specifically the 'openconf'
> > and 'param' methods to help...
> >
> > Consider using a configuration implementation from CPAN (there are lots)
> > instead of growing your own.
> >
> > http://danconia.org
> >
> 
> 



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




re: Win32::Process

2004-05-12 Thread William Black
I have the following code that starts two different processes/perl scripts.  
The code correctly calls and processes the perl scripts, but never seems to 
return back to the calling script for further processing.  Does anyone have 
any clue why this might happen?

#Create dal process

if ($OK == 0){

 Win32::Process::Create($processobj0,"c:\\Perl\\bin\\perl.exe",

"perl dal.pl",1,CREATE_NEW_CONSOLE,".")|| 
&Warn("Error Creating Dal Process. Exiting");

}



#open dal process

if ($OK == 0){

 Win32::Process::Open($processobj0,my $pid0,1);

}



#Create stl process

if ($OK == 0){

 Win32::Process::Create($processobj1,"c:\\Perl\\bin\\perl.exe",

"perl stl.pl",1,CREATE_NEW_CONSOLE,".")|| 
&Warn("Error Creating Dal Process. Exiting");

}



#open dal process

if ($OK == 0){

 Win32::Process::Open($processobj1,$pid1,1);

}





#Wait for stl download to complete

while (!-e "stl.done") {};

print "stl.done finished\n";



#kill stl process

Win32::Process::KillProcess($pid1,$exitcode);





#Wait for dal download to complete

while (!-e "dal.done") {};

print "dal.done finished\n";



#kill dal process

Win32::Process::KillProcess($pid0,$exitcode);

William Black

_
Express yourself with the new version of MSN Messenger! Download today - 
it's FREE! http://messenger.msn.com/go/onm00200471ave/direct/01/

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



Re: Multi library

2004-05-12 Thread JupiterHost.Net


[EMAIL PROTECTED] wrote:

my openconf function contains:

sub openconf {
   my $pkg = shift;
   my $self = bless([EMAIL PROTECTED],$pkg);
   open(...
   


I don;'t think
open(...

will work :)

Wy not share the whole code and also param() or how can we help :)

   return($self);
}
Lee.M - JupiterHost.Net

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



Re: WWW::Mechanize question

2004-05-12 Thread JupiterHost.Net


Ben Miller wrote:

Hi,
Hello,

I'm reading/scraping hyperlinks from a specific web page using the following
while incorporating the WWW::Mechanize module:
my @links = $mech->find_all_links(tag = "a", text_regex => qr/\bWORD\b/i );
try tag => 'a' you are trying to assign a value of a to tag the way it 
is now :)



When I run the program, I get an error: 'Can't modify constant item in
scalar assignment at get.pl line 27, near ""a","'.
I'm not modifying anything or at least not trying to . Is the problem that I
haven't defined 'tag'?
Thanks from a PERL newbie,
Ben
np :)

Lee.M - JupiterHost.Net

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



WWW::Mechanize question

2004-05-12 Thread Ben Miller
Hi,

I'm reading/scraping hyperlinks from a specific web page using the following
while incorporating the WWW::Mechanize module:

my @links = $mech->find_all_links(tag = "a", text_regex => qr/\bWORD\b/i );


When I run the program, I get an error: 'Can't modify constant item in
scalar assignment at get.pl line 27, near ""a","'.

I'm not modifying anything or at least not trying to . Is the problem that I
haven't defined 'tag'?

Thanks from a PERL newbie,
Ben


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




GD module and LD_LIBRARY_PATH problem

2004-05-12 Thread Halkyard, Jim

Hi all,

I have a problem with the GD module on Solaris 5.8 using Perl 5.6.1. I have installed 
Perl to /usr/local/bin/perl and /usr/app/perl is a symlink to fit in with certain 
conventions round here.

When compiling the GD module it asked me where libgd was installed, and I told it - 
/usr/local/lib. But now I have the problem below where libpng12.so.0 is not found 
unless the LD_LIBRARY_PATH variable is set. libpng.so.0 is is /usr/local/lib with 
libgd so I am not sure why it is not found.


$
$ ./test.pl
Can't load '/usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris/auto/GD/GD.so'
for module GD: ld.so.1: /usr/app/perl: fatal: libpng12.so.0: open failed: No
such file or directory at
/usr/local/lib/perl5/5.6.1/sun4-solaris/DynaLoader.pm line 206.
 at ./test.pl line 3
Compilation failed in require at ./test.pl line 3.
BEGIN failed--compilation aborted at ./test.pl line 3.
$
$ export LD_LIBRARY_PATH=/usr/local/lib
$
$ ./test.pl
$
$ cat ./test.pl
#!/usr/app/perl

use GD;



Does anyone have any ideas or hints for me on how I can avoid having to set 
LD_LIBRARY_PATH before running any script that uses GD?

TIA,

Cheers,

Jim


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




Re: Multi library

2004-05-12 Thread max4o
my openconf function contains:

sub openconf {
   my $pkg = shift;
   my $self = bless([EMAIL PROTECTED],$pkg);
   open(...
   
   return($self);
}

I have "my @config;" set at the beggining of the module

-
This mail is from: <[EMAIL PROTECTED]>
-

On Wed, 12 May 2004, Wiggins d Anconia wrote:

> > Hi,
> > I'm trying to create library that can open many config files. For
> > examlpe, I have cfg1.conf and cfg2.conf. My lib is getting information
> > from those files and store it into an array. If I do:
> >
> > my $cfg1 = My::Lib->openconf("cfg1.conf");
> > my $cfg2 = My::Lib->openconf("cfg2.conf");
> >
> > print $cfg1->param("someparam");
> > print $cfg2->param("someparam");
> >
> > it prints two times the param from second conf file. Any ideas or I wasn't
> > clear enough ?:")
> > Btw sorry for my bad english
> >
>
> We will probably need to see your My::Lib, specifically the 'openconf'
> and 'param' methods to help...
>
> Consider using a configuration implementation from CPAN (there are lots)
> instead of growing your own.
>
> http://danconia.org
>

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




Re: Multi library

2004-05-12 Thread Wiggins d Anconia
> Hi,
> I'm trying to create library that can open many config files. For
> examlpe, I have cfg1.conf and cfg2.conf. My lib is getting information
> from those files and store it into an array. If I do:
> 
> my $cfg1 = My::Lib->openconf("cfg1.conf");
> my $cfg2 = My::Lib->openconf("cfg2.conf");
> 
> print $cfg1->param("someparam");
> print $cfg2->param("someparam");
> 
> it prints two times the param from second conf file. Any ideas or I wasn't
> clear enough ?:")
> Btw sorry for my bad english
> 

We will probably need to see your My::Lib, specifically the 'openconf'
and 'param' methods to help... 

Consider using a configuration implementation from CPAN (there are lots)
instead of growing your own.

http://danconia.org

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




Re: Net::Telnet executing commands on remote shell after executing su

2004-05-12 Thread Wiggins d Anconia
> Hi, 
> 
>   I am using Net::Telnet and getting a new shell on a remote machine
> all my commands work fine
> Now suppose I become root using "su" and "pass" I am not able to
> execute commands on this root shell
> Can anyone show me How  I can do this
> 

I believe you are going to need to use the read/wait_for idiom inside of
a loop simulating the command/output environment for the su subshell.

>From the Net::Telnet docs,

"Consider using a combination of print() and waitfor() as an alternative
to this method when it doesn't do what you want, e.g. the command you
send prompts for input."

Essentially once you have su'd you are going to be sent the su prompt,
wait for that, then do 'print' to send a command, then wait for the
prompt again, etc.

I *believe* (aka I haven't done it before) that this will work. Check
the Net::Telnet docs for much more information on this.  You might also
consider skipping the 'su' stuff altogether and see if sudo can be used
as an alternative.  Then you can have access to specific commands,
without a password if desired.

HTH,

http://danconia.org

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




Multi library

2004-05-12 Thread max4o
Hi,
I'm trying to create library that can open many config files. For
examlpe, I have cfg1.conf and cfg2.conf. My lib is getting information
from those files and store it into an array. If I do:

my $cfg1 = My::Lib->openconf("cfg1.conf");
my $cfg2 = My::Lib->openconf("cfg2.conf");

print $cfg1->param("someparam");
print $cfg2->param("someparam");

it prints two times the param from second conf file. Any ideas or I wasn't
clear enough ?:")
Btw sorry for my bad english

-
This mail is from: <[EMAIL PROTECTED]>
-

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




RE: DBD for SQL Server?

2004-05-12 Thread NYIMI Jose (BMB)


> -Original Message-
> From: Alok Bhatt [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, May 12, 2004 11:49 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: DBD for SQL Server?
> 
> 
> 
> --- Richard Crawford <[EMAIL PROTECTED]>
> wrote:
> > Is there a DBD for SQL Server so that I can connect
> > to our SQL Server
> > 2000 database with DBI?  I've hunted all over CPAN
> > but I can't seem to 
> > find one.
> Windows uses the Open Database Connectivity (ODBC)
> Model. You can connect to an MS-SQL server using
> Win32::ODBC, available at 

Then you will no longer be using DBI API (what OP wanted) !

The advantage of DBD::ODBC (or DBD::ADO )
Is the portability of your code since you
Will be using the same api syntax regarless the
The database driver (DBD) you are dealing with behind DBI.

The connection is always
my $dbh=DBI->connect(...);

Not a new api like:
$Data = new Win32::ODBC(...);
Which obviously will not work if you need
To use your same code on a database running on unix box.

HTH,

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: DBD for SQL Server?

2004-05-12 Thread Alok Bhatt

--- Richard Crawford <[EMAIL PROTECTED]>
wrote:
> Is there a DBD for SQL Server so that I can connect
> to our SQL Server 
> 2000 database with DBI?  I've hunted all over CPAN
> but I can't seem to 
> find one.
Windows uses the Open Database Connectivity (ODBC)
Model. You can connect to an MS-SQL server using
Win32::ODBC, available at
http://search.cpan.org/~gsar/libwin32-0.191/ODBC/ODBC.pm

More info - perldoc Win32::ODBC


HTH,
Alok





__
Do you Yahoo!?
Yahoo! Movies - Buy advance tickets for 'Shrek 2'
http://movies.yahoo.com/showtimes/movie?mid=1808405861 

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




Re: File Find

2004-05-12 Thread Ramprasad A Padmanabhan
On Wed, 2004-05-12 at 02:18, Joseph Ruffino wrote:
> Hi,
> 
> I have a question that maybe someone can help me with.  I am 
> writing/creating a file on a unix server, and I check to see if the file 
> exists before I create it.  If it does create a new file, I want to send 
> the previous file via e-mail to a specific person.
> 
> I currently have it working for the previous day, I use the date for the 
> filename.  But, what if the day before is not the previous file?  I want 
> to code something that will either, check the date on the file, or find 
> the previous file, whether it be the day before, i.e. 051104.txt to 
> 051204.txt or some day distant, i.e. 050804.txt to 051204.txt.
> 
> I hope I am explaining myself correctly, feel free to ask as many 
> questions you can if i have explained myself well enough.

So I assume you know the name of the file. You can use modules like
File::Find
But sometimes it is must better to use system commands like 
$file=`find $srcdir -name $filename -print`

( Of course I assume you are using a unix like machine )

Bye
Ram



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




Re: Symbolic references

2004-05-12 Thread Rob Dixon
Jan Eden wrote:
>
> Hi all,
>
> there must be a better way to do this. My task is to create a multiple choice
> test in HTML. First, I print the question (frage):
> 
> my $query = "SELECT frage_id, frage_text, antwort_text_1, antwort_text_2,
> antwort_text_3, antwort_text_4, antwort_text_5 FROM fragen";
> my $sth = $dbh->prepare($query);
> $sth->execute();
> print qq{ enctype="application/x-www-form-urlencoded"
> accept-charset="utf-8">};
> my $counter;
> while (my ($frage_id, $frage_text, $antwort_text_1, $antwort_text_2,
> $antwort_text_3, $antwort_text_4, $antwort_text_5)
> = $sth->fetchrow_array) {
> $counter++;
> print qq{
> 
> 
> Frage $counter:
> 
> 
> $frage_text
> 
> };
> -
>
> Next, the possible answers should be printed Now instead of calling each
> answer's variable explicitly, I'd like to use a loop.
>
> -
> foreach my $count (1..5) {
> $antwort = "antwort_text_$count";
> print qq{
> 
> 
> 
> 
> ${"$antwort"}
> 
> 
> };
> }
> }
> print qq{
> };
> $sth->finish();
> -

Hi Jan.

> $antwort is declared as an our variable and it holds the string
> "antwort_text_1", "antwort_text_2" etc., but the dereferencing never works. An
> empty string is printed. The string "1_antwort_1" as the name of an input
> field is generated correctly, of course.

$antwort doesn't need to be a global variable, but $antwort_text_1 .. 5 do,
as symbolic references don't work on lexical variables.

  $count = 1;
  $antwort = "antwort_text_$count";
  print ${$antwort};

prints $main::antwort_text_1 (or whatever the current package is).

perldoc perlref says:

Only package variables (globals, even if localized) are visible to
symbolic references. Lexical variables (declared with my()) aren't in a
symbol table, and thus are invisible to this mechanism.

> But even if I got the dereferencing to work, this solution looks suboptimal.
> Could anyone suggest a way to loop through the different answers without using
> /no strict "refs"/, i.e. without making use of symbolic references at all?

How about this:

  while (my ($frage_id, $frage_text, @antwort) = $sth->fetchrow_array) {

$counter++;

print qq{
  
 Frage $counter: 
 $frage_text 
  
};

my $count;
foreach my $antwort (@antwort) {

  $count++;

  print qq{


   $antwort 

  };
}
  }

HTH,

Rob

(BTW Jan I know I owe you an email. I'm getting to it!)



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




RE: DBD for SQL Server?

2004-05-12 Thread NYIMI Jose (BMB)
> -Original Message-
> From: Richard Crawford [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, May 12, 2004 12:40 AM
> To: [EMAIL PROTECTED]
> Subject: DBD for SQL Server?
> 
> 
> Is there a DBD for SQL Server so that I can connect to our SQL Server 
> 2000 database with DBI?  I've hunted all over CPAN but I 
> can't seem to 
> find one.
> 

I would try DBD::ODBC

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]
 




File Find

2004-05-12 Thread Joseph Ruffino
Hi,

I have a question that maybe someone can help me with.  I am 
writing/creating a file on a unix server, and I check to see if the file 
exists before I create it.  If it does create a new file, I want to send 
the previous file via e-mail to a specific person.

I currently have it working for the previous day, I use the date for the 
filename.  But, what if the day before is not the previous file?  I want 
to code something that will either, check the date on the file, or find 
the previous file, whether it be the day before, i.e. 051104.txt to 
051204.txt or some day distant, i.e. 050804.txt to 051204.txt.

I hope I am explaining myself correctly, feel free to ask as many 
questions you can if i have explained myself well enough.

--
Joseph A. Ruffino
Automated Systems Assistant
270 N. Grove Ave
Elgin, Il 60120
Phone: (847) 742-2411 ext 5986
Fax: (847) 742-0485


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



Weird SMTP filtering/blocking problem

2004-05-12 Thread David Garamond
I run a homegrown SMTP daemon written in Perl, on Redhat 7.3.

Lately, emails sent from some clients are received in duplicates. The
clients either run Communigate Pro, or IPlanet, MDaemon, all running
some versions of Windows.
The emails duplicate because the client sends it multiple times. The
cause is when it finishes sending DATA (with "."), my program replies
with the "250" response but the client didn't receive it. After long
waiting, it would disconnect and later try sending again, several
times.
Emails from other senders, like yahoogroups, hotmail, etc. do not
experience this problem.
After some more testing, a filtering seems to be the cause of the
problem.
If I print

 "250 QUEUED - 123"

or (somewhat mimicking qmail)

 "250 QUEUED(250) - 1084263071 qp 4221"

then everything works, but if I send:

 "250 QUEUED(250) - 8c3d931926ca4e8a9dfea84f06dbdc1a"

then the client won't receive the above 250 response line. The 32
hexacharacter part is a GUID which I produce randomly using 16 bytes
retrieved every time from /dev/urandom. Now why would a proxy or a
firewall regard a random 32 hexadecimal character as suspicious and
block/filter it? Is this a known problem?
I couldn't find any other cause (like line-ending differences,
buffering issues) aside from this particular thing that seems to cause
the problem.
Any insight would be appreciated.

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