MLDBM

2002-05-03 Thread Conan Chai

hi all,

i want to use MLDBM to store some data(name with
multiple values), but error occurs. i have installed
these modules, but i'm not sure what i'm missing.
MLDBM
DB_file
Data::Dumper

the codes:
use MLDBM 'DB_File';

tie %data, MLDBM, database, O_CREAT|O_RDWR, 0644
or die can't open/create files:$!\n;

the error:
MLDBM error: Second level tie failed, No such file or
directory

how could there be this error when i want to create
the file? so i delibrately created the file(with 0
bytes) but it still gives the same error.

any pointers? thks!

Conan

=
It Will Come To Us !!!
[EMAIL PROTECTED]

__
Do You Yahoo!?
Yahoo! Kickin' Party - Win a 5-star getaway to exotic 
Bali!brhttp://kickin.yahoo.com.sg

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




Re: map() definition help

2002-05-03 Thread Sudarsan Raghavan

Scott Lutz wrote:

 What is the purpose of the following code?

 @list = keys %{{map{$_,1} @list}};

map {$_, 1} @list  $_ is holds the value of the current element of @list
i.e. being processed
for e.g. if @list contains (abc, def, ghi), a list like (abc, 1, def,
1, ghi, 1) is the output
This list being treated as a hash (the %). The keys returns the keys of the
hash i.e. abc, def, ghi,
except since the keys of the hash need not stored in the same order in which
they are formed, the
resulting @list contains a shuffled form of the original @list.

you can also take a look at perldoc -q shuffle



 I am looking over someone else's code, and I am not familiar with the map()
 function.
 I have looked through the perl docs on www.perldoc.com, but it doesn't quite
 get this deep.

 Any help would be great.

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


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




Re: map() definition help

2002-05-03 Thread John W. Krahn

Scott Lutz wrote:
 
 What is the purpose of the following code?
 
 @list = keys %{{map{$_,1} @list}};

This removes any duplicate elements in @list.

$ perl -le'
@list = qw[a b c d e d c b d];
print @list;
@list = keys %{{map{$_,1} @list}};
print @list;
'
a b c d e d c b d
e a b c d


 I am looking over someone else's code, and I am not familiar with the map()
 function.
 I have looked through the perl docs on www.perldoc.com, but it doesn't quite
 get this deep.

perldoc -f map



John
-- 
use Perl;
program
fulfillment

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




Please help: writing an tiff image

2002-05-03 Thread nandikotkur Giridhar


Hi

I have a tiff header stored in a scalar (that was retrieved from a 
uncompressed tiff by the read statement).
and I have an array (287 by 370) which has numbers from 0-255.
I am trying to write it to a file in an uncompressed tiff format after the 
header, and view the image.

I am going crazy looking for a command that converts these scaled numbers to 
some relevant format compatible with the TIFF format.

I am however able to convert a tiff image to numbers (0-255) character by 
character using the ORD command but the reverse process.. no clue!
please help!



_
Join the world’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


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




Big file...

2002-05-03 Thread Fabrizio Morbini

Hi,
Anyone know how handle big file with Perl (size   2 GB)?

Thank you very much for any help.
Fabrizio


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




Re: Big file...

2002-05-03 Thread Chas Owens

On Fri, 2002-05-03 at 04:22, Fabrizio Morbini wrote:
 Hi,
 Anyone know how handle big file with Perl (size   2 GB)?
 
 Thank you very much for any help.
 Fabrizio
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


sarcasmVery carefully./sarcasm

What exactly do you want to do with this file? 
 
-- 
Today is Pungenday the 50th day of Discord in the YOLD 3168
Pzat!
Today is also Discoflux
Missile Address: 33:48:3.521N  84:23:34.786W


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




Re: Please help: writing an tiff image

2002-05-03 Thread Felix Geerinckx

 I am going crazy looking for a command that converts these scaled
 numbers to some relevant format compatible with the TIFF format.
 
 I am however able to convert a tiff image to numbers (0-255)
 character by character using the ORD command but the reverse
 process.. no clue! please help!

Don't know anything about the TIFF format, but did you try

$result = pack('C*', @scaled_numbers);

to convert the integers to bytes?

-- 
felix


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




$results[$i] fails :o(

2002-05-03 Thread Fritscher Ralf

Hallo folks,

I don't understand the problem in the code snippet below. I am not able to
fetch the value of a specific array element $result[$i], WHY?

:
:
:
# LOGFILE already opened before

my $noofbuilds = 5;
my @results= (0,1,1,1,0,1,1,0);
my $average= 0;
my $sum= 0;

$debug  print LOGFILE '@results'. = @results\n;
# output: 0 1 1 1 0 1 1 0

for( my $i=0 ; ( ( not undef $results[$i] )  ( $i$noofbuilds ) ) ;
$i++ )
{
  $sum += $results[$i];
$debug  print LOGFILE '$i'. = $i\n;
# output : correct $i
  $debug  print LOGFILE '$results[$i] = ' . $results[$i] .\n;
# output : $results[$i]  =  ???
$debug  print LOGFILE '$sum'. = $sum\n;
# output : $sum = 0
}
$average = sprintf (%3.1f, ( $sum / $noofbuilds ) );
$debug  print LOGFILE '$average = $sum / $noofbuilds = ' . $sum \/
$noofbuilds = $average\n;
# output : $average = $sum / $noofbuilds = 0 / 5 = 0   # :o(
:
:
:

Accessing array element via foreach is running, but I want to use the loop
mentioned above.

PLEASE HELP!

 Adios
Ralf

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




Re: $results[$i] fails :o(

2002-05-03 Thread Felix Geerinckx

on Fri, 03 May 2002 09:30:35 GMT, [EMAIL PROTECTED]
(Fritscher Ralf) wrote: 

 ... not undef $results[$i] ...

'undef' is an operator which undefines its argument, and always returns 
the undefined value. The expression 'not undef $results[$i] therefor 
will always be 'true', but in the meantime $results[$i] will become 
undefined.

You probably want

... defined $results[$i] ...

instead.

-- 
felix

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




printing element from record ?

2002-05-03 Thread Martin A. Hansen

hi, im having trouble printing out the key of this record hash:

i wan the result to print:

THIS_HERE

im sure its trivial, but i cant figure it :)

martin


{
  'THIS_HERE' = {
   'ISH' = [
  '3'
],
   'ISHpix' = [],
   'bg' = [
 ''
   ],
   'gelpix' = [],
   'base' = [
   'T'
 ],
   'norm' = [
   ''
 ],
   'gel' = [
  '456'
],
   'drug' = [
   ''
 ],
   'primer' = [
 '2'
   ],
   'mt' = [
 'foo'
   ],
   'organism' = [
   'Human'
 ],
   'band' = [
   '1'
 ],
   'name' = [
   'abc'
 ],
   'date' = [
   '123'
 ],
   'cell' = [
   ''
 ],
   'quant' = [
''
  ],
   'tissue' = [
 'Testis'
   ]
 }
}

i read in the hash using this:



{ #block to control scope
  local ($/) = undef; #make this change local so as not to screw up anything else

  open SOURCE, $hash_file or die Can't open file: $!;
  $hash_ref = eval SOURCE;
  die $@ if $@;
  close SOURCE;
}

so printing should be something ala:

print $hash_ref - { ? };

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




RE: $results[$i] fails :o(

2002-05-03 Thread Fritscher Ralf

Hallo Felix,

thanx a lot :o)

   ... undef != $results[$i] ...

is the correct syntax, it shall prevent accessing unexisting array elements.

Have a nice weekend...
   Ralf



-Original Message-
From: Felix Geerinckx [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 03, 2002 12:04 PM
To: [EMAIL PROTECTED]
Subject: Re: $results[$i] fails :o(


on Fri, 03 May 2002 09:30:35 GMT, [EMAIL PROTECTED]
(Fritscher Ralf) wrote: 

 ... not undef $results[$i] ...

'undef' is an operator which undefines its argument, and always returns 
the undefined value. The expression 'not undef $results[$i] therefor 
will always be 'true', but in the meantime $results[$i] will become 
undefined.

You probably want

... defined $results[$i] ...

instead.

-- 
felix

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

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




MLDBM

2002-05-03 Thread Conan Chai

hi all,

i want to use MLDBM to store some data(name with
multiple values), but error occurs. i have installed
these modules, but i'm not sure what i'm missing.
MLDBM
DB_file
Data::Dumper

the codes:
use MLDBM 'DB_File';

tie %data, MLDBM, database, O_CREAT|O_RDWR, 0644
or die can't open/create files:$!\n;

the error:
MLDBM error: Second level tie failed, No such file or
directory

how could there be this error when i want to create
the file? so i delibrately created the file(with 0
bytes) but it still gives the same error.

any pointers? thks!

Conan

=
It Will Come To Us !!!
[EMAIL PROTECTED]

__
Do You Yahoo!?
Yahoo! Kickin' Party - Win a 5-star getaway to exotic 
Bali!brhttp://kickin.yahoo.com.sg

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




Re: Aerial and Satellite immages

2002-05-03 Thread Tim Musson

Hey LeeRM43,

My MUA believes you used Atlas Mailer 2.0
to write the following on Friday, May 3, 2002 at 7:13:49 AM.
Lac Check out the overhead view of your house at:

Lac terraserver.homeadvisor.msn.com

Lac Do not put WWW in front of the above.

You get a better photo from www.Mapquest.com

Here is my house... 
http://www.mapquest.com/maps/map.adp?zoom=11mapdata=UrVYjtEIiZ%2fALyZ9UY0Fr4CdTTO0Y69gJUoXv6P0t1tUJ8ZUfhtyZtAdRKvNR7B%2b42YgiGmBvvWFDYdULBT6OFv0uSgik4%2f5azjcbXreeALaEoowxOyKkELN5jNH6fp58opibwoxHdKduuouz63QM8EdP8UM4qe6hINrAFW9V0xOub8dRIK5518sfmu%2btSBvp4xK0tuFTgkSN5Oxp3zg%2b10Y9mOrZ%2bCIpbOvq0obHDTZeOEVNvMGWPF9LZp2zkgSR0x3nYN9ztFr8XVxC3U6Lwmd1KO7vTUfQvMYzFk2o1M%3d

-- 
[EMAIL PROTECTED]
MUA = TB! v1.60h (www.RitLabs.com/The_Bat)
Windows 2000 5.0.2195 (Service Pack 2)
It is easier to get forgiveness than to get permission.


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




RE: $results[$i] fails :o(

2002-05-03 Thread Felix Geerinckx

on Fri, 03 May 2002 10:24:19 GMT, [EMAIL PROTECTED]
(Fritscher Ralf) wrote: 

... undef != $results[$i] ...
 
 is the correct syntax, it shall prevent accessing unexisting array
 elements. 
 
No, it is not, as you will notice when you enable warnings,
The correct syntax, as I showed you before, is

...defined($results[$i])...

-- 
felix

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




Perl and Visual Basic

2002-05-03 Thread crogers3

Good day;
I have developed some useful Perl scripts.. Users want a VB front-end 
to run these scripts.
What do I need to do, such that something like this could work (i.e.: 
User presses a command button, which then launches a Perl script- data 
sent to output files, etc..)

Some caveats:
We work in a tightly-controlled environment, which doesn't allow 
downloading and compiling CPAN modules.
We don't have access to TK (by virtue of the item above)

Am I dead in the water? Has anyone else found 'tricks' to work around a 
similar situation?
Thanks in advance for your time.
Carl


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




Re: Perl and Visual Basic

2002-05-03 Thread Ahmed Moustafa

[EMAIL PROTECTED] wrote:
 Good day;

Hello,

 I have developed some useful Perl scripts.. Users want a VB front-end 
 to run these scripts.
 What do I need to do, such that something like this could work (i.e.: 
 User presses a command button, which then launches a Perl script- data 
 sent to output files, etc..)

There is the VB's *Shell* function which let's you call an external 
executable program (including the Perl interperter).

-- 
Ahmed Moustafa
http://pobox.com/~amoustafa


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




RE: Perl and Visual Basic

2002-05-03 Thread Tucker, Ernie

How about Having the VB button link to Perl on your server and run?


Ernest P. Tucker II

  Network Technician

 



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 03, 2002 7:09 AM
To: [EMAIL PROTECTED]
Subject: Perl and Visual Basic


Good day;
I have developed some useful Perl scripts.. Users want a VB front-end 
to run these scripts.
What do I need to do, such that something like this could work (i.e.: 
User presses a command button, which then launches a Perl script- data 
sent to output files, etc..)

Some caveats:
We work in a tightly-controlled environment, which doesn't allow 
downloading and compiling CPAN modules.
We don't have access to TK (by virtue of the item above)

Am I dead in the water? Has anyone else found 'tricks' to work around a 
similar situation?
Thanks in advance for your time.
Carl


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


 The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material from all
computers. 





Bulk mail tests

2002-05-03 Thread Anders Holm

Hi folks!

I'm trying to do a test on one of our servers where I'd like to send one
mail message to upto 1000 recipients.
For this I'd like to use Mail::Bulkmail...

Now, I seems to be messing it up somehow, and am very short on time.. :(
Could someone help me out here??

The usernames I'm sending to is user[1-1000]@mydomain.com...

Here's the quick and dirty code I threw together..

#!/usr/local/bin/perl

use Mail::Bulkmail;

$bulk = Mail::Bulkmail-new(
From = '[EMAIL PROTECTED]',
Smtp = 'smtp.mydomain.com',
Port = '25',
Subject = 'Testing ISS mail service',
Message = 'TEST'
 );

while($rcpt = 1000) {
$bulk-List(user . $rcpt . @mydomain.com);
}
Best Regards

Anders Holm
Critical Path Technical Support Engineer
--
Tel USA/Canada: 1 800 353 8437
Tel Worldwide:  +1 801 736 0806
E-mail: [EMAIL PROTECTED]
Internet:   http://support.cp.net



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




Re: Perl and Visual Basic

2002-05-03 Thread John Brooking

I'm assuming you are using ActivePerl. In
ActiveState's Perl Dev Kit (sold separately, $129),
there is a utility to package an ActivePerl script
into a stand-alone Windows executable. I've only tried
the free 7-day trial version, but it seems to work
pretty well, including wrapping up any extra modules
you are using. If the people that control your
environment are satisfied with this (because it would
avoid having Perl and CPAN modules on the production
box), you could put that EXE in with your VB program
and call it with the VB Shell statement. If
asynchronous execution (call it and forget about it)
is okay, you are done. If you need to monitor it and
know when it is finished, there's some other tricky
VB/Windows API stuff you need to do which I don't
remember well enough to tell you about, and is better
asked on a VB-related list.

- John

--- [EMAIL PROTECTED] wrote:
 Good day;
 I have developed some useful Perl scripts.. Users
 want a VB front-end 
 to run these scripts.
 What do I need to do, such that something like this
 could work (i.e.: 
 User presses a command button, which then launches a
 Perl script- data 
 sent to output files, etc..)
 
 Some caveats:
 We work in a tightly-controlled environment, which
 doesn't allow 
 downloading and compiling CPAN modules.
 We don't have access to TK (by virtue of the item
 above)
 
 Am I dead in the water? Has anyone else found
 'tricks' to work around a 
 similar situation?
 Thanks in advance for your time.
 Carl
 
 
 -- 
 To unsubscribe, e-mail:
 [EMAIL PROTECTED]
 For additional commands, e-mail:
 [EMAIL PROTECTED]
 


__
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com

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




Re: Bulk mail tests

2002-05-03 Thread Felix Geerinckx

on Fri, 03 May 2002 12:21:46 GMT, [EMAIL PROTECTED] (Anders Holm)
wrote: 

 $bulk-List(user . $rcpt . @mydomain.com);

Either
'@mydomain.com'
or
\@mydomain.com

will do.

-- 
felix

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




Re: Aerial and Satellite immages

2002-05-03 Thread Tim Musson

Hey Tim,

My MUA believes you used The Bat! (v1.60h) Personal
to write the following on Friday, May 3, 2002 at 7:37:43 AM.

TM Here is my house...

Sorry, looks like a mail template got away from me...

-- 
[EMAIL PROTECTED]
MUA = TB! v1.60h (www.RitLabs.com/The_Bat)
Windows 2000 5.0.2195 (Service Pack 2)
How do you make Windows faster ? Throw it harder


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




Re: Aerial and Satellite immages

2002-05-03 Thread Tim Musson

Hey John,

My MUA believes you used (X-Mailer not set)
to write the following on Friday, May 3, 2002 at 8:32:28 AM.
JB How did you get the aerial photo? I can't find any links to show
JB ariel photos when I start over with my own location.

at mapquest, bring up your street, the just above the map, is are 2
tabs - Street Map  Aerial Photo.

-- 
[EMAIL PROTECTED]
MUA = TB! v1.60h (www.RitLabs.com/The_Bat)
Windows 2000 5.0.2195 (Service Pack 2)
What else can you do at 3:00 am?


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




Re: MLDBM

2002-05-03 Thread drieux


On Friday, May 3, 2002, at 03:58 , Conan Chai wrote:
[..]

 tie %data, MLDBM, database, O_CREAT|O_RDWR, 0644
 or die can't open/create files:$!\n;

 the error:
 MLDBM error: Second level tie failed, No such file or
 directory
[..]

p0: try one or the other mailing lists.

p1: if you go back and look at

perldoc -f tie

you will notice the illustration code:

tie(%HIST, 'NDBM_File', '/usr/lib/news/history', 1, 0);

and in your case all you have is database - which may
or may not be in the same directory as the code that you
are executing. when it is, then it is findable, when
your code runs by other means - then the file database -
should actually be 'fully qualified' as to where it will
reside on the machine



ciao
drieux

---


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




Re: Big file...

2002-05-03 Thread drieux


On Friday, May 3, 2002, at 01:31 , Chas Owens wrote:

 On Fri, 2002-05-03 at 04:22, Fabrizio Morbini wrote:
 Hi,
 Anyone know how handle big file with Perl (size   2 GB)?
[..]
 sarcasmVery carefully./sarcasm

the specific is that you will need to have your version of
perl built with the USE_LARGE_FILES option set.

when you do the 'perl -V' you will notice at least the line:

Characteristics of this binary (from libperl):
  Compile-time options: USE_LARGE_FILES
  Built under darwin

The problem chas if you have never seen it happen, is that many
of the internal functions will fail in weird and wacky ways.

my $file = '/var/spool/big_file';

if ( -f $file ) {
print found the big file\n;
}else{
print found the big file NOT!\n;
}

if the version of perl that is 'interpretting' that piece of
code is not built with the USE_LARGE_FILE and big_file is
greater than 2Gig - then you will get:

found the big file NOT!

this happens with the distribution of perl that comes from
the vendor of redhat linux 7.2 - I know I had to rebuild the
perl to get around that specific problem. Apple on the otherhand
opted to build their default distribution with the USE_LARGE_FLAG
set... your vendors will vary on this point.

IF one's version of perl is built with the USE_LARGE_FILE flag,
then the next problem is not perl, but your file system - can it
manage the allocation of files greater than 2gig - if it can not
then, well, gosh - how'd you make the file to begin with Especially
if you are on one of the older releases of various OS's where there
was the file system limitation that no file system could be bigger
than 2gigabytes hence one could not write such a file...

ciao
drieux

---


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




Re: developing and testing first CGI/Perl application

2002-05-03 Thread drieux


On Friday, May 3, 2002, at 06:22 , Maureen E Fischer wrote:

 I am about to write my first CGI/Perl application.  I have read Learning
 Perl and I now am reading the Castro Perl and CGI book and the O'Reilly
 CGI book.  I was going to write and test my work using IIS on Windows
 because it seemed easy for me to get started that way, but I have access
 to a Sun machine that runs UNIX.  Since the system will ultimately run
 on Hostway.com (our ISP provider) using an Apache web server on Linux,
 would it be better to just forget about the IIS and develop it right
 away using UNIX or will the differences be minor (between the windows
 application and the ultimate Unix application) and easy to correct.  Any
 advice will be appreciated. Maureen

as you may have noticed a lot of people get bollock'd by the
dos2unix and unix2dos 'end of line' problem.

but as we also noticed if you start with

#!/usr/bin/perl -w
use strict;

you can actually skate around that

Given that you have access to a unix box - in the dark the big
delta's between solaris and linux are not that interesting in
the actual perl coding space - so I would argue - avoid the
IIS/windows problems - and go over to the *nix box and just
get on with perlMongering.

What you will also find is that you can run your

myNewCgi.cgi

from the command line and debug it.. once it stops
complaining at you - then hang it up in a 'safe place'
and call it out from your webPages



ciao
drieux

---


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




Re: developing and testing first CGI/Perl application

2002-05-03 Thread james

drieux,

i've been monitoring this list and couldn't help but notice the volume of
your posts. i have to ask: do you ever sleep?

:) james
- Original Message -
From: drieux [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: May 03, 2002 08:45
Subject: Re: developing and testing first CGI/Perl application



 On Friday, May 3, 2002, at 06:22 , Maureen E Fischer wrote:

  I am about to write my first CGI/Perl application.  I have read Learning
  Perl and I now am reading the Castro Perl and CGI book and the O'Reilly
  CGI book.  I was going to write and test my work using IIS on Windows
  because it seemed easy for me to get started that way, but I have access
  to a Sun machine that runs UNIX.  Since the system will ultimately run
  on Hostway.com (our ISP provider) using an Apache web server on Linux,
  would it be better to just forget about the IIS and develop it right
  away using UNIX or will the differences be minor (between the windows
  application and the ultimate Unix application) and easy to correct.  Any
  advice will be appreciated. Maureen

 as you may have noticed a lot of people get bollock'd by the
 dos2unix and unix2dos 'end of line' problem.

 but as we also noticed if you start with

 #!/usr/bin/perl -w
 use strict;

 you can actually skate around that

 Given that you have access to a unix box - in the dark the big
 delta's between solaris and linux are not that interesting in
 the actual perl coding space - so I would argue - avoid the
 IIS/windows problems - and go over to the *nix box and just
 get on with perlMongering.

 What you will also find is that you can run your

 myNewCgi.cgi

 from the command line and debug it.. once it stops
 complaining at you - then hang it up in a 'safe place'
 and call it out from your webPages



 ciao
 drieux

 ---


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




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




Re: developing and testing first CGI/Perl application

2002-05-03 Thread Tor Hildrum

 From: james [EMAIL PROTECTED]
 Date: Fri, 3 May 2002 08:54:49 -0500
 To: [EMAIL PROTECTED]
 Subject: Re: developing and testing first CGI/Perl application
 
 drieux,
 
 i've been monitoring this list and couldn't help but notice the volume of
 your posts. i have to ask: do you ever sleep?
 
 :) james

From reading his energetic (and very helpful) posts, I would say he is high
on coffee :)

The best of all is that he is as energetic on a couple of other lists I
subscribe to as well. :)

And, if you haven't bookmarked it:
http://www.wetware.com/drieux/CS/lang/Perl/Beginners/

:)

Tor


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




RE: developing and testing first CGI/Perl application

2002-05-03 Thread Nikola Janceski

Sweet link, passing that on to some of my co-workers.

And there go my nipples again. -- Capt. Murphy (Sealab 2021)

http://www.juliao.org/text/tao-of-p.shtml (Tao of programming)

-Nik

 -Original Message-
 From: Tor Hildrum [mailto:[EMAIL PROTECTED]]
 Sent: Friday, May 03, 2002 10:02 AM
 To: Perl
 Subject: Re: developing and testing first CGI/Perl application
 
 
  From: james [EMAIL PROTECTED]
  Date: Fri, 3 May 2002 08:54:49 -0500
  To: [EMAIL PROTECTED]
  Subject: Re: developing and testing first CGI/Perl application
  
  drieux,
  
  i've been monitoring this list and couldn't help but notice 
 the volume of
  your posts. i have to ask: do you ever sleep?
  
  :) james
 
 From reading his energetic (and very helpful) posts, I would 
 say he is high
 on coffee :)
 
 The best of all is that he is as energetic on a couple of 
 other lists I
 subscribe to as well. :)
 
 And, if you haven't bookmarked it:
 http://www.wetware.com/drieux/CS/lang/Perl/Beginners/
 
 :)
 
 Tor
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




VT100 Terminal and modem dialing

2002-05-03 Thread Aaron Petry

I need to connect to a remote computer via a dialup and send some terminal 
commands via a vt100 terminal.  Is there a module to do this, and if so, 
what is it?


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




RE: $results[$i] fails :o(

2002-05-03 Thread Fritscher Ralf

You're right, Felix! Sorry!

Could you explain the difference between these two command lines, please!

Thanx
  Ralf

-Original Message-
From: Felix Geerinckx [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 03, 2002 2:09 PM
To: [EMAIL PROTECTED]
Subject: RE: $results[$i] fails :o(


on Fri, 03 May 2002 10:24:19 GMT, [EMAIL PROTECTED]
(Fritscher Ralf) wrote: 

... undef != $results[$i] ...
 
 is the correct syntax, it shall prevent accessing unexisting array
 elements. 
 
No, it is not, as you will notice when you enable warnings,
The correct syntax, as I showed you before, is

...defined($results[$i])...

-- 
felix

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

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




[ WAY OT ]Re: developing and testing first CGI/Perl application

2002-05-03 Thread drieux


On Friday, May 3, 2002, at 06:54 , james wrote:
[..]
 i've been monitoring this list and couldn't help but notice the volume of
 your posts. i have to ask: do you ever sleep?

when I can. ( no smiley )


 :) james

may I recommend:

http://www.wetware.com/drieux/screeds/LiNox.html

actually you folks are my 'relief valve' - since you are
so much easier to deal with than say doing stuff like:

 Judge Harold Green's 1991 running in Dellums v. Bush

 p57, p58
 War and Responsibility: Constitutional Lessons of Vietname
   and its aftermath
 John Hart Ely
 c. 1993
 ISBN 0-691-025552-5

 cf: 752 F. Supp. 1141 (D.D.C. 1990)

{ for the noviciates - that was the case that established
that we were at war with iraq - and is the case law still
in force, this being the 12th year of the war with iraq -
a point that most american zoned on September 10th, 2001 -
and few have thought much about... }

actually the lexical, syntactical and technical stuff in
perl is a whole lot more realistic as well

now, shall we return to the matters at hand? Since for
me this is a wonderful source of fun and enjoyment as
people posit testable hypothesis - and well, one can test them,
and one can benchmark the contenders...

ciao
drieux

---

ok, so having multiple OS's on the other side of the bulk
head, with a 100bt backboned net in the crip here does allow
me to test variations on a theme..


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




Re: VT100 Terminal and modem dialing

2002-05-03 Thread drieux


On Friday, May 3, 2002, at 07:37 , Aaron Petry wrote:

   I need to connect to a remote computer via a dialup and send some 
 terminal commands via a vt100 terminal.  Is there a module to do this, 
 and if so, what is it?

I'm not too sure that there is one for the dialup side,
but you will probably want to look at

Net::Telnet

once you get the modem connected - since this will give
you most of the interface that you will need to run a simple
telnet session - eg: act like a vt100 terminal

are you setting up a PPP,MLPP type session through the
dial up link? or are you on an OS that is limited to
only a single connection model?


ciao
drieux

---


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




Validating user id password from web page against NT NIS server accounts

2002-05-03 Thread Merritt, Dave

All,

I'm writing a web based app and I want to have a user login page.  I can
create the page just fine and do the all the form stuff just fine.
However, what I'm looking at trying to do is to authenticate the user id 
password against either our NT server accounts or Sun NIS server accounts
depending on the OS the user is browsing from instead of to the web server's
htpasswd file.  I'm only needing to test for a valid user id and password
against the password servers, and am not interested in inheriting or
accessing any permissions, authorizations, etc. from the NT or NIS servers.
I will assign permissions etc. to the user id on the web server.  Are there
modules that will let me do the authenticating of a user id  password
against NT  NIS servers?  If so, what are they?  I took a look at the CPAN
site but couldn't find anything that stood out as being the correct modules.

Hopefully the question makes some sort of sense.  BTW, running Apache,
mod_perl,  perl 5.6.1 on Solaris 2.8 if that makes any difference to the
responses.

Thanks in advance

Dave



fork

2002-05-03 Thread walter valenti

Hi,
if i've got a script like:

for($i=1;$i=5;$i++){
my $pid=fork;
die $!\n unless defined($pid);
unless($pid){
sleep;
}
}
sleep;

The father forks 5 childs that sleeping, and after also the father sleeps.
The question is:

if i send a 'TERM' at the father, i want that the fathet kill the childs 
and aftet it dies... but how do the father to obtain the pid of the 
childs ???'


Thanks

Walter


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




RE: Validating user id password from web page against NT NIS server accounts

2002-05-03 Thread Gordon Cabaniss


There is a perl module called Authen::Smb that might work for you.  
http://freshmeat.net/redir/authensmb/483/url_tgz/Authen-Smb-0.91.tar.gz 

You will need to install the samba package. If you want to use .htaccess files with 
apache to the auth you might check out.

http://modntlm.sourceforge.net/

good luck.


-Original Message-
From: Merritt, Dave [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 03, 2002 10:20 AM
To: '[EMAIL PROTECTED]'
Subject: Validating user id  password from web page against NT  NIS
server accounts


All,

I'm writing a web based app and I want to have a user login page.  I can
create the page just fine and do the all the form stuff just fine.
However, what I'm looking at trying to do is to authenticate the user id 
password against either our NT server accounts or Sun NIS server accounts
depending on the OS the user is browsing from instead of to the web server's
htpasswd file.  I'm only needing to test for a valid user id and password
against the password servers, and am not interested in inheriting or
accessing any permissions, authorizations, etc. from the NT or NIS servers.
I will assign permissions etc. to the user id on the web server.  Are there
modules that will let me do the authenticating of a user id  password
against NT  NIS servers?  If so, what are they?  I took a look at the CPAN
site but couldn't find anything that stood out as being the correct modules.

Hopefully the question makes some sort of sense.  BTW, running Apache,
mod_perl,  perl 5.6.1 on Solaris 2.8 if that makes any difference to the
responses.

Thanks in advance

Dave

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




Re: Validating user id password from web page against NT NIS server accounts

2002-05-03 Thread drieux


On Friday, May 3, 2002, at 08:50 , Gordon Cabaniss wrote:


 There is a perl module called Authen::Smb that might work for you.  http:
 //freshmeat.net/redir/authensmb/483/url_tgz/Authen-Smb-0.91.tar.gz

 You will need to install the samba package. If you want to use .htaccess 
 files with apache to the auth you might check out.

 http://modntlm.sourceforge.net/

 good luck.

[..]
 Hopefully the question makes some sort of sense.  BTW, running Apache,
 mod_perl,  perl 5.6.1 on Solaris 2.8 if that makes any difference to the
 responses.

You will clearly want to do some investigation on the .htaccess side
of how your apache is configured. hence since we authenticate against
a radius server I use things like

### AuthType Basic
### AuthName Wetware Services
### AuthAuthoritative off
### AuthRadiusAuthoritative on
### AuthRadiusActive on
### require valid-user

in the .htaccess - and leave all of the heavy lifting to the
debate between the WebFascists and the RadiusServerFascist as
to how they wish to interoperate with the NIS_Fascists and the
ActiveDirectoryFascists. { if you happen to be all of these
as well as the coderPerson - then do what I do in those cases,
take yourself out for lunch, have a serious discussion about
your policy position, and write it off as a bizniz expense,
but make sure that you retain the 'minority opinion' in case
you need to have leverage to manuever yourself later on during
the basic inter-office politics. }

At which point by the time they get to actually RUNNING my little
cgi - I don't have to worry about it - as the JackBootedThugs have
already done their dancing.

If on the other hand you have to 'key' on the 'user' - pull down:

http://examples.oreilly.com/cgi2/

{ and buy the BOOK - read it }

you will want to play with the dope that comes in:

#!/usr/bin/perl -wT
# Print a formatted list of all the environment variables

use strict;

print Content-type: text/html\n\n;

my $var_name;
foreach $var_name ( sort keys %ENV ) {
print PB$var_name/BBR;
print $ENV{$var_name};
}

so that you understand what is being passed to you in %ENV from
your server { that is in chapter 3 }

ciao
drieux

---

I am not an AI - but you may be a rat in a Turing Test.



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




Re: Parameters

2002-05-03 Thread drieux


On Thursday, May 2, 2002, at 12:32 , Josef E. Galea wrote:

 How can I pass parameters (eg: a file name) to a Perl script


you will ultimately want to deal with

perldoc GetOpt::Long

as the complexity of the command line argument sequence grows.

given something like:

#!/usr/bin/perl -w
 use strict;

 # argvWalker.pl- is for

 my $count=0;
 foreach my $arg (@ARGV) {
 print \t($count) :$arg: \n;
 $count++;
 }

 # end of the world as I knew it [EMAIL PROTECTED] all rights reserved
 # ginned On 3-May-02
 #

you will get output like:

./argv* -a --b c d
 (0) :-a:
 (1) :--b:
 (2) :c:
 (3) :d:

hence you can either walk each file through inside the foreach
loop - and then go on - or - like what ever...

ciao
drieux

---


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




Re: Modules

2002-05-03 Thread drieux


On Thursday, May 2, 2002, at 12:31 , Jackson, Harry wrote:

 I am attempting to write a module and trying to follow the guidelines etc 
 on
 how it should be done.
[..]
I can help as time allows... { just tag it B/C  so I see
that we are taking this 'Back Channel' ... hey old habits. }

for what it is worth:

http://www.wetware.com/drieux/CS/lang/Perl/PM/

is where I hide stuff on that subject..

if you do the

perldoc h2xs

and start that way you will probably get MOST of the stuff
to fire up correctly in the main.

 It all works OK and does what I expect it to do but I want to find out 
 where
 I have not adhered to the rules about modules before I start to write any
 more.


I'm not going to ask, I'm Not going to ask.

fsckIt -

if it works the problem here is What?

Smell the Coffee - If you are Orthodox and have started from
the h2xs - and filled in the POD - then what is the concern???

ciao
drieux

---


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




AutoFlushing for CGI and DB - Re: MySQL hangs.

2002-05-03 Thread drieux


On Thursday, May 2, 2002, at 10:37 , Jonathan E. Paton wrote:

 Don't forget to turn on autoflushing with $|=1, or for long queries
 it will timeout.

Intellectually I agree with this, and I know that a part of
that is to get the 'message back' as quickly - but I have
never really understood why we do this and go through
the whole

print someHtmlStuff
print someMoreHtmlStuff

I know I presented the idea of a 'page concatenation' approach
so as to isolate the i/o onto one event

So I just through I would raise it again...

Especially - given the concern about a long query timing out...

If the puppy times out - what happens??? since that is a
failure on a 'read event' as far as one's script is concerned.
{ and I hope? that the DB side of the game bails the query,
but does it know to roll back the transaction??? }

You know the whole stack of OLTP angst that goes with
developing various forms of distributed networking solutions
for which there is currently the p5ee project...

ciao
drieux

---


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




RE: $results[$i] fails :o(

2002-05-03 Thread Felix Geerinckx

on Fri, 03 May 2002 15:01:17 GMT, Fritscher Ralf wrote:

 Could you explain the difference between these two command lines,
 please! 

Difference:

... undef != $results[$i] ... wrong
... defined($results[$i]) ... right 

Run the following program:

my $x = 0;

if ($x != undef) {
print '$x is defined';
} else {
print '$x is undefined';
}

'!=' is the *numerical* not equal to operator. Therefore, both '$x' and 
'undef' are evaluated in numerical context, both giving zero (0), leading 
to the incorrect result.

-- 
felix

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




RE: Perl and Visual Basic

2002-05-03 Thread DeBaets, Kirk

I am going to go on the same assumption (ActivePerl) and recommend
PerlCtrl from the PDK.  With a couple of minor modifications to the
script you can turn your Perl app into an ActiveX dll that is easy
enough for your VB to use.

-Original Message-
From: John Brooking [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 03, 2002 8:25 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: Perl and Visual Basic


I'm assuming you are using ActivePerl. In
ActiveState's Perl Dev Kit (sold separately, $129),
there is a utility to package an ActivePerl script
into a stand-alone Windows executable. I've only tried
the free 7-day trial version, but it seems to work
pretty well, including wrapping up any extra modules
you are using. If the people that control your
environment are satisfied with this (because it would
avoid having Perl and CPAN modules on the production
box), you could put that EXE in with your VB program
and call it with the VB Shell statement. If
asynchronous execution (call it and forget about it)
is okay, you are done. If you need to monitor it and
know when it is finished, there's some other tricky
VB/Windows API stuff you need to do which I don't
remember well enough to tell you about, and is better
asked on a VB-related list.

- John

--- [EMAIL PROTECTED] wrote:
 Good day;
 I have developed some useful Perl scripts.. Users
 want a VB front-end 
 to run these scripts.
 What do I need to do, such that something like this
 could work (i.e.: 
 User presses a command button, which then launches a
 Perl script- data 
 sent to output files, etc..)
 
 Some caveats:
 We work in a tightly-controlled environment, which
 doesn't allow 
 downloading and compiling CPAN modules.
 We don't have access to TK (by virtue of the item
 above)
 
 Am I dead in the water? Has anyone else found
 'tricks' to work around a 
 similar situation?
 Thanks in advance for your time.
 Carl
 
 
 -- 
 To unsubscribe, e-mail:
 [EMAIL PROTECTED]
 For additional commands, e-mail:
 [EMAIL PROTECTED]
 


__
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com

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




Re: VT100 Terminal and modem dialing

2002-05-03 Thread Aaron Petry

 That's sort of the weirdest part of all of this.  I'm connecting 
to a piece of proprietary hardware that has a modem incorporated into it 
and that I currently use HyperTerminal on a Win32 box, but I really want to 
automate this process.  It would be a single connection, but the computer 
that I want to run this on is on a network.  The piece of proprietary 
hardware is not.
At 08:08 AM 5/3/2002 -0700, you wrote:

On Friday, May 3, 2002, at 07:37 , Aaron Petry wrote:

 I need to connect to a remote computer via a dialup and send 
 some terminal commands via a vt100 terminal.  Is there a module to do 
 this, and if so, what is it?

I'm not too sure that there is one for the dialup side,
but you will probably want to look at

 Net::Telnet

once you get the modem connected - since this will give
you most of the interface that you will need to run a simple
telnet session - eg: act like a vt100 terminal

are you setting up a PPP,MLPP type session through the
dial up link? or are you on an OS that is limited to
only a single connection model?


ciao
drieux

---


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



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




file types

2002-05-03 Thread Jerry Preston

Hi!

I am trying to determine if a is linked or not.  I am using the following:

if( -f $fp/$program ) {
  print 2 programs $program*\n;
  $programs{ program }{ $program } = $fp/$program;
}

and 

if( -l $fp/$program ) {
  print 2 programs $program*\n;
  $programs{ program }{ $program } = $fp/$program;
}

I get the same result for two files!  One is linked and the other is not.

Thanks,

Jerry

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




Re: MLDBM

2002-05-03 Thread Michael Fowler

I removed beginners-cgi from the Cc: list.  Your question has nothing
specifically to do with CGI, and is thus not appropriate on that list. 
Please don't cross-post.


On Fri, May 03, 2002 at 06:58:34PM +0800, Conan Chai wrote:
 use MLDBM 'DB_File';
 
 tie %data, MLDBM, database, O_CREAT|O_RDWR, 0644
 or die can't open/create files:$!\n;
 
 the error:
 MLDBM error: Second level tie failed, No such file or
 directory

Are you certain that's the only error you got?  Did you, by chance, also see
something like:

Argument O_SVWST isn't numeric in subroutine entry at
/usr/lib/perl/5.6.1/DB_File.pm line 263.

What I'm getting at is that you may not have imported the O_CREAT and O_RDWR
constants, so they're being evaluated as strings.  Assuming the code you
showed us is all of the code you're using, this is the case, and you need to
add something like:

use Fcntl qw(O_RDWR O_CREAT);

or

use DB_File qw(O_RDWR O_CREAT);

Depending on whether or not you want to load an extra module for these
constants.


Michael
--
Administrator  www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

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




Re: fork

2002-05-03 Thread Michael Fowler

On Fri, May 03, 2002 at 05:51:42PM +0200, walter valenti wrote:
 for($i=1;$i=5;$i++){
my $pid=fork;
die $!\n unless defined($pid);
unless($pid){
sleep;
}
 }
 sleep;
[snip]
 if i send a 'TERM' at the father, i want that the fathet kill the childs 
 and aftet it dies... but how do the father to obtain the pid of the 
 childs ???'

You have the PID right there, returned by fork().  Store it in an array or
something and use that to send signals to the children.


Michael
--
Administrator  www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

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




Re: file types

2002-05-03 Thread John W. Krahn

Jerry Preston wrote:
 
 Hi!

Hello,

 I am trying to determine if a is linked or not.  I am using the following:

If you have a file and you want to determine if another file is linked
to it then you will have to search through all files on your system to
find it/them.  If you find a symbolic link using -l you can determine
what it links to with the readlink() function.


 if( -f $fp/$program ) {
   print 2 programs $program*\n;
  ^
File globs don't work in strings.

   $programs{ program }{ $program } = $fp/$program;
 }
 
 and
 
 if( -l $fp/$program ) {
   print 2 programs $program*\n;
   $programs{ program }{ $program } = $fp/$program;
 }
 
 I get the same result for two files!  One is linked and the other is not.

Could you please rephrase your problem more clearly.  I don't understand
what you are trying to do here.


John
-- 
use Perl;
program
fulfillment

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




Re: file types

2002-05-03 Thread drieux


On Friday, May 3, 2002, at 11:08 , Jerry Preston wrote:

 Hi!

 I am trying to determine if a is linked or not.  I am using the following:
[..]
 I get the same result for two files!  One is linked and the other is not.

let me offer you a bit of a basic case:

vladimir: 57:] ls -l *dos*
-rwxr-xr-x   1 drieux   house238 May  2 16:59 dos2unix
lrwxrwxrwx   1 drieux   house  8 May  2 16:53 unix2dos - dos2unix
vladimir: 58:]

one is a link the other is a file.

given

### #!/usr/bin/perl -w
### use strict;
###
### my @array = qw /dos2unix unix2dos/;
###
### foreach my $file (@array) {
###
### print \t$file is a file\n
### if ( -f $file ) ;
### print \t$file is a link\n
### if ( -l $file ) ;
### }


we get:

vladimir: 55:] perl testForLinks.pl
 dos2unix is a file
 unix2dos is a file
 unix2dos is a link
vladimir: 56:]


remember that it is true that unix2dos is both a file and link.

let us modify our array to deal with

vladimir: 66:] ls -l lin* no*
lrwxrwxrwx   1 drieux   house  7 May  3 12:28 linkTo - nowhere
vladimir: 67:]

by adding in

my @array = qw /dos2unix unix2dos linkTo/;

and we get the information:

vladimir: 65:] perl *.pl
 dos2unix is a file
 unix2dos is a file
 unix2dos is a link
 linkTo is a link
vladimir: 66:]

notice that the linkTo nowhere is ONLY a link and not a link AND file.

ciao
drieux

---


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




rmtree

2002-05-03 Thread Aman Raheja

I have a directory Abs with a file abc in it.
I am using rmtree to rm this dir as follows

use File::Path;
rmtree(Abs,1,1) or die dir not del;
print done;


The output is

unlink ../htdocs/store/newpages/Abstract/abc


It neither prints the die statement nor the done - ofcourse it doesn't 
actually delete the file and the dir at all.

Do let me know if there's an alternative to deleting directories 
recursively.
HELP will be greatly appreciated.
Thank you
Aman

_
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.


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




Standalone Perl apps in Win32(was RE: Perl and Visual Basic)

2002-05-03 Thread Paul Weissman


So are these the main avenues to go for making standalone Perl apps under
Windows, or are there some other alternatives?

Theres's got to be something else other than the ActivePerl routes... ?

Paul


 -Original Message-
 From: DeBaets, Kirk [mailto:[EMAIL PROTECTED]]
 Sent: Friday, May 03, 2002 10:21 AM
 To: John Brooking; [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: RE: Perl and Visual Basic


 I am going to go on the same assumption (ActivePerl) and recommend
 PerlCtrl from the PDK.  With a couple of minor modifications to the
 script you can turn your Perl app into an ActiveX dll that is easy
 enough for your VB to use.

 -Original Message-
 From: John Brooking [mailto:[EMAIL PROTECTED]]
 Sent: Friday, May 03, 2002 8:25 AM
 To: [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: Re: Perl and Visual Basic


 I'm assuming you are using ActivePerl. In
 ActiveState's Perl Dev Kit (sold separately, $129),
 there is a utility to package an ActivePerl script
 into a stand-alone Windows executable. I've only tried
 the free 7-day trial version, but it seems to work
 pretty well, including wrapping up any extra modules
 you are using. If the people that control your
 environment are satisfied with this (because it would
 avoid having Perl and CPAN modules on the production
 box), you could put that EXE in with your VB program
 and call it with the VB Shell statement. If
 asynchronous execution (call it and forget about it)
 is okay, you are done. If you need to monitor it and
 know when it is finished, there's some other tricky
 VB/Windows API stuff you need to do which I don't
 remember well enough to tell you about, and is better
 asked on a VB-related list.

 - John

 --- [EMAIL PROTECTED] wrote:
  Good day;
  I have developed some useful Perl scripts.. Users
  want a VB front-end
  to run these scripts.
  What do I need to do, such that something like this
  could work (i.e.:
  User presses a command button, which then launches a
  Perl script- data
  sent to output files, etc..)
 
  Some caveats:
  We work in a tightly-controlled environment, which
  doesn't allow
  downloading and compiling CPAN modules.
  We don't have access to TK (by virtue of the item
  above)
 
  Am I dead in the water? Has anyone else found
  'tricks' to work around a
  similar situation?
  Thanks in advance for your time.
  Carl
 
 
  --
  To unsubscribe, e-mail:
  [EMAIL PROTECTED]
  For additional commands, e-mail:
  [EMAIL PROTECTED]
 


 __
 Do You Yahoo!?
 Yahoo! Health - your guide to health and wellness
 http://health.yahoo.com

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



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




RE: what kind of data type?

2002-05-03 Thread Paul Weissman


ok, i guess i'm just confused about all this automatic type stuff in perl.

when you read from a binary file like:

open ( FD, $filename );
binmode ( FD );
read(FD, $buf, 2);

now $buf has 2 bytes of your file.  what kind of data type is this?  why
does:

printf '%x', $buf;

not print out the hex value of the binary data?

i figured out what i needed to about this, but i'm just not fully
understanding why.  i solved my problem by doing:

$un = unpack(H*, $buf);

now i can manipulate the value of $un however i want... is $un now what is
referred to as a 'string literal'?  and what kind of data type is $buf?

thanks,
paul



 -Original Message-
 From: LoBue, Mark [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, May 02, 2002 1:18 PM
 To: [EMAIL PROTECTED]
 Subject: RE: what kind of data type?


 $x = 0xA;
 printf %x\n, $x;

 result: a

 -Mark
 -Original Message-
 From: bob ackerman [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, May 02, 2002 8:55 AM
 To: [EMAIL PROTECTED]
 Subject: Re: what kind of data type?



 On Thursday, May 2, 2002, at 02:45  AM, Paul Weissman wrote:

 
  what i'm trying to do is open a binary file and read from it...
 
  ---\
 
  open ( FD, $filename );
  binmode ( FD );
 
  #read two bytes
  while (read(FD, $buf, 2)) {
   # hopefully print the hex value of two bytes
   print hex($buf);
  }

 i think you are confused about what hex() does.
 it takes an ascii string and interprets it as if the characters
 repesent a
 hex number.
 see perldoc -f hex.
 binary data would need to be handled differently.
 if i assume you want to see a dump to the terminal of  your data,
 you would have to do the opposite of what hex() does. turn a hex number
 into a string.
 program 'hexdump' does this.
 if you still want to do this in perl and are stuck, you could repost your
 problem.

  ---/
 
  and what i'm going for here is to read some binary data in and
 print out
  the
  hexadecimal value of that binary data.
 
  what's happening is very different.  for whatever reason, $buf is not
  being
  treated like an ordinary number... code that does what i want is:
 
  ---\
 
  $x = 0xA;
  print hex($x);
 
  ---/
 
  which prints the value '10'.
 
  what kind of datatype is $buf in the first code snippet?  and can i
  convert
  it so that i can use it like $x in the second code snippet?
 
  i'm using ActivePerl (newest version) on Win2k.
 
  thanks tons!
 
  paul
 
 
  --
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 


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

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



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




Re: file types

2002-05-03 Thread drieux


On Friday, May 3, 2002, at 01:30 , drieux wrote:


 On Friday, May 3, 2002, at 11:08 , Jerry Preston wrote:

 Hi

hello

for those playing the 'play along at home game'

http://www.wetware.com/drieux/CS/lang/Perl/Beginners/linkToNowhere.txt


where I go into a bit more detail about the differences between
symbolic links, hardlinks, files and the differences



ciao
drieux

---


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




RE: Standalone Perl apps in Win32(was RE: Perl and Visual Basic)

2002-05-03 Thread Timothy Johnson


There's Perl2exe, but that's about it.  It's kind of a specialized field...

-Original Message-
From: Paul Weissman [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 03, 2002 2:14 PM
To: [EMAIL PROTECTED]
Subject: Standalone Perl apps in Win32(was RE: Perl and Visual Basic)



So are these the main avenues to go for making standalone Perl apps under
Windows, or are there some other alternatives?

Theres's got to be something else other than the ActivePerl routes... ?

Paul


 -Original Message-
 From: DeBaets, Kirk [mailto:[EMAIL PROTECTED]]
 Sent: Friday, May 03, 2002 10:21 AM
 To: John Brooking; [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: RE: Perl and Visual Basic


 I am going to go on the same assumption (ActivePerl) and recommend
 PerlCtrl from the PDK.  With a couple of minor modifications to the
 script you can turn your Perl app into an ActiveX dll that is easy
 enough for your VB to use.

 -Original Message-
 From: John Brooking [mailto:[EMAIL PROTECTED]]
 Sent: Friday, May 03, 2002 8:25 AM
 To: [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: Re: Perl and Visual Basic


 I'm assuming you are using ActivePerl. In
 ActiveState's Perl Dev Kit (sold separately, $129),
 there is a utility to package an ActivePerl script
 into a stand-alone Windows executable. I've only tried
 the free 7-day trial version, but it seems to work
 pretty well, including wrapping up any extra modules
 you are using. If the people that control your
 environment are satisfied with this (because it would
 avoid having Perl and CPAN modules on the production
 box), you could put that EXE in with your VB program
 and call it with the VB Shell statement. If
 asynchronous execution (call it and forget about it)
 is okay, you are done. If you need to monitor it and
 know when it is finished, there's some other tricky
 VB/Windows API stuff you need to do which I don't
 remember well enough to tell you about, and is better
 asked on a VB-related list.

 - John

 --- [EMAIL PROTECTED] wrote:
  Good day;
  I have developed some useful Perl scripts.. Users
  want a VB front-end
  to run these scripts.
  What do I need to do, such that something like this
  could work (i.e.:
  User presses a command button, which then launches a
  Perl script- data
  sent to output files, etc..)
 
  Some caveats:
  We work in a tightly-controlled environment, which
  doesn't allow
  downloading and compiling CPAN modules.
  We don't have access to TK (by virtue of the item
  above)
 
  Am I dead in the water? Has anyone else found
  'tricks' to work around a
  similar situation?
  Thanks in advance for your time.
  Carl
 
 
  --
  To unsubscribe, e-mail:
  [EMAIL PROTECTED]
  For additional commands, e-mail:
  [EMAIL PROTECTED]
 


 __
 Do You Yahoo!?
 Yahoo! Health - your guide to health and wellness
 http://health.yahoo.com

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



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

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




problem with NET::FTP script

2002-05-03 Thread Pedro A Reche Gallardo


Dear Adam, I have an small perl script (see below) to retrieve a list of
files whose filenames are listed in a file that is the the input of the
program. The program runs as it follows:  getpdb.pl file; and file
just contain the two following entries
2vaa
2vac

Somehow, I only cant get the first file, but not the second. I tried
several things I do not know what I am doing wrong. The script is
included in this e-mail and I will very happy if someone could let me
know what I am doing wrong.
Regards

Pedro
This is the script
#!/usr/bin/perl
use Net::FTP::Common;
my @pdbs = ;

getpdb(@pdbs);

sub getpdb {
my @ent = @_;
print $ent[0]$ent[1];

#my $pdbentry=$_[0];


my $dir = .;
my $ftphost = ftp.rcsb.org;
my $ftpdir = /pub/pdb/data/structures/all/pdb;
my $username = anonymous;
my $password = anonymous;

$ftp = Net::FTP-new($ftphost)  or print Can't connect: $@\n;
$ftp-login($username, $password) or print Couldn't login\n;
$ftp-cwd($ftpdir)or print Couldn't change
directory\n;
$ftp-type(I)   or print Couldn't change to
binary\n;

foreach my $key (@ent){
 chomp($key);
 $key  =~ tr/[A-Z]/[a-z]/;
my $pdbentry = $key;
 my $rcsbfile = pdb . $key . .ent.Z;
 $ftp-get($ftpdir/$rcsbfile, $dir/${pdbentry}.pdb.Z)or
print Can't get $pdbentry\n;
 system(gunzip $dir/${pdbentry}.pdb.Z);
}
}

--
***
PEDRO A. RECHE , pHDTL: 617 632 3824
Dana-Farber Cancer Institute,   FX: 617 632 4569
Harvard Medical School, EM: [EMAIL PROTECTED]
44 Binney Street, D1510A,   EM: [EMAIL PROTECTED]
Boston, MA 02115URL:
http://www.reche.org
***




Re: rmtree

2002-05-03 Thread Paresh Kakrecha

I just ran your code on my machine and it worked for me.
check the write permission on parent directory of Abs

if still not work then use
system(/usr/bin/rm -rf Abs);

-Paresh.
At 03:54 PM 5/3/2002 -0500, Aman Raheja wrote:
I have a directory Abs with a file abc in it.
I am using rmtree to rm this dir as follows

use File::Path;
rmtree(Abs,1,1) or die dir not del;
print done;


The output is

unlink ../htdocs/store/newpages/Abstract/abc


It neither prints the die statement nor the done - ofcourse it doesn't 
actually delete the file and the dir at all.

Do let me know if there's an alternative to deleting directories recursively.
HELP will be greatly appreciated.
Thank you
Aman

_
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.


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



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




RE: file types

2002-05-03 Thread Jerry Preston

I tried the following:

if( ! defined( $x = readlink( $fp/$program ))) {
  print 2 programs $program*'$x'*\n;
  $programs{ program }{ $program } = $fp/$program;
}

and all I get is '';

I know one file's permissions are lwxrwxrwxr and the other is -wxrwxrwxr!

Any ideas?

Thanks,

Jerry

-Original Message-
From: Jerry Preston [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 03, 2002 1:09 PM
To: Beginners Perl
Subject: file types


Hi!

I am trying to determine if a is linked or not.  I am using the following:

if( -f $fp/$program ) {
  print 2 programs $program*\n;
  $programs{ program }{ $program } = $fp/$program;
}

and 

if( -l $fp/$program ) {
  print 2 programs $program*\n;
  $programs{ program }{ $program } = $fp/$program;
}

I get the same result for two files!  One is linked and the other is not.

Thanks,

Jerry

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


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




Re: rmtree

2002-05-03 Thread drieux


On Friday, May 3, 2002, at 02:33 , Paresh Kakrecha wrote:

 I just ran your code on my machine and it worked for me.
 check the write permission on parent directory of Abs

 if still not work then use
 system(/usr/bin/rm -rf Abs);

 -Paresh.
[..]

 use File::Path;
 rmtree(Abs,1,1) or die dir not del;
 print done;
 

 The output is

 unlink ../htdocs/store/newpages/Abstract/abc
 

 It neither prints the die statement nor the done - ofcourse it doesn't 
 actually delete the file and the dir at all.

 Do let me know if there's an alternative to deleting directories 
 recursively.

actually what you have to do is clear all of the files out
of the directory and all of the subdirectories of it before
you can actually remove the directory itself.

the 'unlink' is that has removed that file

I would expect that it is in the process of trying to traverse
a directory

as you will notice in the output at:

http://www.wetware.com/drieux/CS/lang/Perl/Beginners/unlinkRmTree.txt

There is the chance that your OS has 'issues' with how permission
bits are actually being set - and/or that your process has begun
to wander off chasing symbolic links outside of the scope



ciao
drieux

---


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




RE: what kind of data type?

2002-05-03 Thread LoBue, Mark

read loads a scaler string, in this case, a string of 2 characters.
Characters 

You can pick out the individual characters a few ways, like:
@newbuf = split(// , $buf);

Then, convert each character to it's numerical value with ord:
printf  %02X, ord($newbuf[0]);
printf  %02X, ord($newbuf[1]);

or use substr:
printf  %02X %02X\n, ord(substr($buf,0,1)), ord(substr($buf,1,1)) ;

You need ord because 0xA, when being printed, reverts to the action of 0xA
and not the value.  Just like a character value of 52 doesn't print 52
without ord, it prints R (actions defined by ASCII code, in my case).

-Mark

-Original Message-
From: Paul Weissman [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 03, 2002 2:14 PM
To: [EMAIL PROTECTED]
Subject: RE: what kind of data type?



ok, i guess i'm just confused about all this automatic type stuff in perl.

when you read from a binary file like:

open ( FD, $filename );
binmode ( FD );
read(FD, $buf, 2);

now $buf has 2 bytes of your file.  what kind of data type is this?  why
does:

printf '%x', $buf;

not print out the hex value of the binary data?

i figured out what i needed to about this, but i'm just not fully
understanding why.  i solved my problem by doing:

$un = unpack(H*, $buf);

now i can manipulate the value of $un however i want... is $un now what is
referred to as a 'string literal'?  and what kind of data type is $buf?

thanks,
paul



 -Original Message-
 From: LoBue, Mark [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, May 02, 2002 1:18 PM
 To: [EMAIL PROTECTED]
 Subject: RE: what kind of data type?


 $x = 0xA;
 printf %x\n, $x;

 result: a

 -Mark
 -Original Message-
 From: bob ackerman [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, May 02, 2002 8:55 AM
 To: [EMAIL PROTECTED]
 Subject: Re: what kind of data type?



 On Thursday, May 2, 2002, at 02:45  AM, Paul Weissman wrote:

 
  what i'm trying to do is open a binary file and read from it...
 
  ---\
 
  open ( FD, $filename );
  binmode ( FD );
 
  #read two bytes
  while (read(FD, $buf, 2)) {
   # hopefully print the hex value of two bytes
   print hex($buf);
  }

 i think you are confused about what hex() does.
 it takes an ascii string and interprets it as if the characters
 repesent a
 hex number.
 see perldoc -f hex.
 binary data would need to be handled differently.
 if i assume you want to see a dump to the terminal of  your data,
 you would have to do the opposite of what hex() does. turn a hex number
 into a string.
 program 'hexdump' does this.
 if you still want to do this in perl and are stuck, you could repost your
 problem.

  ---/
 
  and what i'm going for here is to read some binary data in and
 print out
  the
  hexadecimal value of that binary data.
 
  what's happening is very different.  for whatever reason, $buf is not
  being
  treated like an ordinary number... code that does what i want is:
 
  ---\
 
  $x = 0xA;
  print hex($x);
 
  ---/
 
  which prints the value '10'.
 
  what kind of datatype is $buf in the first code snippet?  and can i
  convert
  it so that i can use it like $x in the second code snippet?
 
  i'm using ActivePerl (newest version) on Win2k.
 
  thanks tons!
 
  paul
 
 
  --
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 


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

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



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

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




Re: file types

2002-05-03 Thread drieux


On Friday, May 3, 2002, at 02:57 , Jerry Preston wrote:

 I tried the following:

 if( ! defined( $x = readlink( $fp/$program ))) {
   print 2 programs $program*'$x'*\n;
   $programs{ program }{ $program } = $fp/$program;
 }

 and all I get is '';

let's try the 'step back' process

my $x = readlink( $fp/$program );
if ( $x ) {
# we know that $x is now what the Link Points To
} else {
# what ever $fp/$program is, it is not a symbolic link.
}

to illustrate in more depth I have updated:

http://www.wetware.com/drieux/CS/lang/Perl/Beginners/linkToNowhere.txt

ciao
drieux

---


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




@array=FH

2002-05-03 Thread Teresa Raymond

Someone mentioned that sucking a file into an array is not a good 
idea and I read the Perl fact on it but still am not sure why this is 
not a good idea, especially because a lot of code posted uses this 
method.

In addition, if you have the file in an array then you can do foreach:

open(FH, text.fil) || die Can't open text.fil\n;
my @array=FH;
close(FH);

foreach my $i (@array)
{if ($i=~/something/)
  {print $i\n;
  }
}

Would one use while instead and what would the code look like?

open(FH, text.fil) || die Can't open text.fil\n;
while (FH)
{if (what goes here to emulate the above foreach)
  {print ditto\n;
  }
}
close(FH);
-- 
---
-  Teresa Raymond -
-  Mariposa Net   -
-  http://www.mariposanet.com -
---

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




RE: @array=FH

2002-05-03 Thread Wagner-David

If you changed:

foreach my $i (@array)
{if ($i=~/something/)
  {print $i\n;
  }
}
  to
foreach (@array)# defaults to $_
{if ( /something/)
  {print $_\n;
  }
}

Then use while
while (FH)# defaults to $_
{if ( /something/)  
  {print $_\n;
  }
}

Same processing, but one uses array while other uses a file.

Wags ;)
-Original Message-
From: Teresa Raymond [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 03, 2002 09:18
To: Perl Beginners List
Subject: @array=FH


Someone mentioned that sucking a file into an array is not a good 
idea and I read the Perl fact on it but still am not sure why this is 
not a good idea, especially because a lot of code posted uses this 
method.

In addition, if you have the file in an array then you can do foreach:

open(FH, text.fil) || die Can't open text.fil\n;
my @array=FH;
close(FH);

foreach my $i (@array)
{if ($i=~/something/)
  {print $i\n;
  }
}

Would one use while instead and what would the code look like?

open(FH, text.fil) || die Can't open text.fil\n;
while (FH)
{if (what goes here to emulate the above foreach)
  {print ditto\n;
  }
}
close(FH);
-- 
---
-  Teresa Raymond -
-  Mariposa Net   -
-  http://www.mariposanet.com -
---

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

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




RE: @array=FH

2002-05-03 Thread Mark Anderson

It's a matter of memory management.  If you suck in an entire file, you
could run out of memory, making your script run slower.  Also, you have to
do all of the reading before you can start processing the file.

while (FH) {
if (/something/) {
 print $_\n;
}
}

or

while (my $i=FH) {
if ($i=~/something/) {
print $i\n;
}
}

-Original Message-
From: Teresa Raymond [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 03, 2002 9:18 AM
To: Perl Beginners List
Subject: @array=FH


Someone mentioned that sucking a file into an array is not a good
idea and I read the Perl fact on it but still am not sure why this is
not a good idea, especially because a lot of code posted uses this
method.

In addition, if you have the file in an array then you can do foreach:

open(FH, text.fil) || die Can't open text.fil\n;
my @array=FH;
close(FH);

foreach my $i (@array)
{if ($i=~/something/)
  {print $i\n;
  }
}

Would one use while instead and what would the code look like?

open(FH, text.fil) || die Can't open text.fil\n;
while (FH)
{if (what goes here to emulate the above foreach)
  {print ditto\n;
  }
}
close(FH);
--
---
-  Teresa Raymond -
-  Mariposa Net   -
-  http://www.mariposanet.com -
---

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



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




Re: @array=FH

2002-05-03 Thread drieux


On Friday, May 3, 2002, at 09:17 , Teresa Raymond wrote:

 Someone mentioned that sucking a file into an array is not a good idea 
 and I read the Perl fact on it but still am not sure why this is not a 
 good idea, especially because a lot of code posted uses this method.
[..]
{ since wags and mark got the cool stuff, I'll take the left over tech 
stuff.}

the concern is about 'in core memory management' - if the file that
one is slurping in with

my @input_from_file =FH;

is 'not that big to begin with' - then it is max-nix either way.

The problem comes about when suddenly JoeBob who 'has always done that'
gets handed some 2-gig file.. not everyone naturally builds their
machine with over 2gig of memory - so the system tries to do as well
as it can and depending upon OS - this can lead to some interesting
'page faults' and/or swapping cases.

Can you say 'thrashing'?

Hence as a general principle we advocate doing the more 'traditional'
line parsing rules - since this keeps things intrinsically saner - and
in the main generally avoids the need to build your instance of perl
with the USE_LARGE_FILE componentry.

Thus once one has grown accustom to the stock

while(FH) {
next if (/^\s*$/);  #blow off blank lines
chomp;  # remove ONLY the EOL token
my $line = $_ ; # incase we need that whole line later

..

} # end getting in the FH

such animals as

open(TMPFILE, $fileName) ||
 die unable to open tempfile:$fileName \n;

 while ( $len = sysread(  $dtk_sock , $buf, $mtu_size )) {
 unless ( defined $len ) {
 next if $! =~ /^Interrupted/;
 die System read error:$!\n;
 }
 $ReadCount += $len;

 $offset = 0;

 while ($len) {
 $written = syswrite(TMPFILE, $buf, $len, $offset);
 die System write error: $!\n
 unless defined  $written ;
 $len -= $written;
 $offset +=$written;
 $MostWrote +=$written;
 }
 }

do not seem quite as complex and as scary.

We shift from the line oriented 'read' to the sysread for
a given buffer size

Given that the size of the file being 'downloaded' is bigger
than the incore memory this 'no slurpie' approach sorta helps

But to be honest - there are times when that 8-line config file
could just as easily be slurped... but why not do it right the
first time ala:

http://www.wetware.com/drieux/CS/lang/Perl/Beginners/readConfigFile.txt

Your Mileage May Vary,
Void where prohibited by law,
do not bend, fold, spindle or mutilate.


ciao
drieux

---


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




Re: problem with NET::FTP script

2002-05-03 Thread John W. Krahn

Pedro A Reche Gallardo wrote:
 
 Dear Adam, I have an small perl script (see below) to retrieve a list of
 files whose filenames are listed in a file that is the the input of the
 program. The program runs as it follows:  getpdb.pl file; and file
 just contain the two following entries
 2vaa
 2vac
 
 Somehow, I only cant get the first file, but not the second. I tried
 several things I do not know what I am doing wrong. The script is
 included in this e-mail and I will very happy if someone could let me
 know what I am doing wrong.

I had a look at ftp://ftp.rcsb.org/pub/pdb/data/structures/all/pdb and
the file pdb2vaa.ent.Z does exist but the file pdb2vac.ent.Z _does NOT
exist_


 This is the script
 #!/usr/bin/perl

#!/usr/bin/perl -w
use strict;

 use Net::FTP::Common;
 my @pdbs = ;
 
 getpdb(@pdbs);
 
 sub getpdb {
 my @ent = @_;
 print $ent[0]$ent[1];
 
 #my $pdbentry=$_[0];
 
 my $dir = .;
 my $ftphost = ftp.rcsb.org;
 my $ftpdir = /pub/pdb/data/structures/all/pdb;
 my $username = anonymous;
 my $password = anonymous;
 
 $ftp = Net::FTP-new($ftphost)  or print Can't connect: $@\n;
   ^^
You shouldn't quote scalars.

perldoc -q What's wrong with always quoting \$vars\?

 $ftp-login($username, $password) or print Couldn't login\n;
 $ftp-cwd($ftpdir)or print Couldn't change
 directory\n;
 $ftp-type(I)   or print Couldn't change to
 binary\n;
 
 foreach my $key (@ent){
  chomp($key);
  $key  =~ tr/[A-Z]/[a-z]/;

Why are you replacing '[' with '[' and ']' with ']'?  tr/// does not use
regular expressions.

 $key  =~ tr/A-Z/a-z/;

Or even better:

 $key  = lc $key;

Or, since you are not using $key any more.

 my $pdbentry = lc $key;

 my $pdbentry = $key;
  my $rcsbfile = pdb . $key . .ent.Z;
  $ftp-get($ftpdir/$rcsbfile, $dir/${pdbentry}.pdb.Z)or

The current directory $ftpdir was already changed 8 lines ago.

 $ftp-get( $rcsbfile, $dir/$pdbentry.pdb.Z ) or

 print Can't get $pdbentry\n;
  system(gunzip $dir/${pdbentry}.pdb.Z);
 }
 }







John
-- 
use Perl;
program
fulfillment

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




Suid.

2002-05-03 Thread Tor Hildrum

Could someone point me to a page that gives information about all the
pitfalls that are available when running a Perl or CGI script with the
suid bit set?

I tried google.com, but couldn't find anything god.
I found this:
http://www-genome.wi.mit.edu/WWW/faqs/wwwsf5.html

But, it's extremely light on information.

Any help is greatly appreciated.

PS: I've seen all the Do you really need to run your script as suid
warnings. :)

Tor


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




Re: what kind of data type?

2002-05-03 Thread drieux


On Friday, May 3, 2002, at 02:13 , Paul Weissman wrote:
[..]
 when you read from a binary file like:

 open ( FD, $filename );
 binmode ( FD );
 read(FD, $buf, 2);

as you will notice from  perldoc binmode - on most systems this
really is not implemented as doing much of anything... It is
required only on systems where they do not have a real notion
of 'text mode' - as in dull flat ascii.

 now $buf has 2 bytes of your file.  what kind of data type is this?

it is what ever data type was in the file.

[..]

http://www.wetware.com/drieux/CS/lang/Perl/Beginners/readBufFoo.txt

shows me pushing 'hex like' data the old fashion way back into
a file - and then reading it out and reconstructing it

does this help with the question about the fact that binmode()
may not be quite what you want it to be - nor that the 'stuff
in the file' - even if it is in 'ascii' text mode - may
still require a bit of 'resolving' ...


ciao
drieux

---


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




Re: Suid.

2002-05-03 Thread drieux


On Friday, May 3, 2002, at 05:48 , Tor Hildrum wrote:

 Could someone point me to a page that gives information about all the
 pitfalls that are available when running a Perl or CGI script with the
 suid bit set?

there are two important things here

just because you did the chmod 4755 file
doesn't mean much until you do the

chown root:wheel

At which point there is the fun filled and exciting moment
that if you have one of those 'bail to shell' buffer over
flow attack liabilities - then the person on the outside
who has been nailing on your httpd port with their

Net::Telnet

software - just walked in the front door and took over
your system - and is in the process of using it as a
basis for a distributed denial of service attack, which
may leave you fiscally liable for 'loss of services' and/or
other such 'damages' and 'punishments' as the attorney
with the deeper pockets may be able to secure in the judgement.

As the software developer - you may be able to limit some
of that liability - assuming that your employer considers
it worth their time to not merely set you adrift - as they
work out how to cut their losses and point that you were
simply a disgruntled employee and should be held criminal
negligent

does that help?

in general - since this is a 'text file' that is being
'interpreted' - it is easier to get the hack in and
'wonk it' with the resident text editor than it is to
'reconfigure' a binary code as the number of people who
can use text editors - once they have hacked A - are
greater than the folks who can do a full on hexdump and
figure out where to do the diff patch to swap the compiled binary
for a more appropriate piece of bliable code.

If you really need setuid processes - then one of the
principle tricks remains to have them 'spawned' from a
nice harder to hack piece of compiled 'c' code.


Your Mileage may vary -
Void Where Prohibited By Law
Do Not bend, fold, spindel or mutilate.

ciao
drieux

---


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




Re: Suid.

2002-05-03 Thread Tor Hildrum

 
 Could someone point me to a page that gives information about all the
 pitfalls that are available when running a Perl or CGI script with the
 suid bit set?
 

snip - the expected stuff :)

 If you really need setuid processes - then one of the
 principle tricks remains to have them 'spawned' from a
 nice harder to hack piece of compiled 'c' code.

So, basically, call a compiled c-code from my Perl-script, and have the
compiled c-code start the suid process?

[localhost:~/pictures] tor% cc
cc: No input files
[localhost:~/pictures] tor% c++
c++: No input files

Ah :)

Now I only need to learn how to program either C or C++ :)

The WWW security faq had an example, I'll work from that.

Thanks :)

Tor


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




Re: Suid.

2002-05-03 Thread drieux


On Friday, May 3, 2002, at 07:03 , Tor Hildrum wrote:

 Could someone point me to a page that gives information about all the
 pitfalls that are available when running a Perl or CGI script with the
 suid bit set?

 snip - the expected stuff :)

sorry... didn't know that you knew that already. My Bad.

 If you really need setuid processes - then one of the
 principle tricks remains to have them 'spawned' from a
 nice harder to hack piece of compiled 'c' code.

 So, basically, call a compiled c-code from my Perl-script, and have the
 compiled c-code start the suid process?

well it is sorta 'why does this need to run as a specific user'
sort of question??? In the case of most apache driven stuff,
it should generically be running as 'nobody' to begin with.

{ hence the whole CGI thing. which I would be hard pressed
to see why you want that to be anything other than - just
write it, and install it in the cgi-bin du jure. }

The moment that you NEED to have 'root privilege' to do
x-y-z you REALLY need to have a really good reason to do that
and not merely because your code is bodgy and you want to
get around some bollock in your software.

{trust me, I've seen enough of those gags...}

 Now I only need to learn how to program either C or C++ :)

If you know perl, c is not that hard to pick up...
May I offer you as compensation some old crufty c:

http://www.wetware.com/drieux/src/unix/c/setgid_test.txt

this was 'c' code aimed at running what were shell scripts
that managed the init process models for daemon management.

IF you really wind up going that way - send me email B/C...

I hope that helps - its from some old stuff we did back
with Warpspeed Communications Inc. We used the tactic
of having a special daemon - mr_daemon - which ran without
a login shell - this is actually just 'demo junk' code -
{ hence not covered under any NDA. }
since the actual process went on to require more fascism
about where 'runnable code' was actually installed - and
then all this did was do the setgid/setuid - AND DO IT
IN THAT ORDER! In this case the core init script would
be called by root at boot/shutdown times - and we clearly
did not want daemons running as root so you need to
setgid WHILE you are root, before doing the setuid 'down'
to a more practical entity

If you setuid down - you will not have the permissions to
do the setgid side of the game...

so the trick is to make the code - and then make sure
when it gets installed it is OWNED by the UID that
the puppy will do the setuid to

ciao
drieux

---


You can have my root access, after you
rip it from my cold dead hand...


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