Re: htaccess question

2005-08-18 Thread Bill Stephenson

On Aug 17, 2005, at 11:03 AM, zentara wrote:

On Mon, 15 Aug 2005 16:29:54 -0500, [EMAIL PROTECTED] (Bill 
Stephenson)

wrote:


On Aug 12, 2005, at 2:06 AM, David Dorward wrote:


If a directory is password protected with .htaccess

...

or do you always get the popup box?



Here's what's in the .htaccess file
===
AuthUserFile /home/users/members/.htpasswd
AuthGroupFile /dev/null
AuthType Basic
AuthName Members

LIMIT GET POST
require valid-user
/LIMIT
===

How do I point this at a  perl cgi script to process the logon?


If I'm understanding your question correctly...

The server is going to automatically process the login with a popup,
beyond the control of any cgi script. So you are NOT going to bypass 
the

server's auth mechanism, and replace it with a Perl script.


Ok, I thought maybe the AuthType might have a way to use a perl 
script to process logons, but it really doesn't matter now, the client 
has decided not to try and fight this issue (big sigh of relief), which 
I tried to point out was actually an interface issue, and go with what 
works. But if it was possible it would be interesting to play with ;)


The client wanted to use htaccess authentication to process the 
user/pass from an html form. I made a script to put the user/pass in 
the URL of a redirect command in the html output to the browser. This 
worked great for me, I use mozilla based browsers on a mac, Internet 
Explorer did not work for the client on his windows box. He finally 
opted for a link to the password protected directory.


Thanks again for the help,

--
Bill Stephenson


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Regex Problem.

2005-08-18 Thread Sara
I am at a loss here to generate REGEX for my problem.

I have an input query coming to my cgi script, containg a word (with or without 
spaces e.g. blood Globin Test etc).
What I am trying to do is to split this word (maximum of 3 characters) and find 
the BEST possible matching words within mySQL database. For example if the word 
is blood

I want to get results using regex: 

for blood: check(blo) then check(loo)  check(ood)
for Globin Test: check(Glo) then check(lob)  check(obi) check(bin) 
check(Tes) check(est)

TIA.

Sara.

sub check {
my $check = $dbh - prepare(SELECT * FROM medical WHERE def LIKE '%$query%' );
$check-execute();
while (my @row = $check - fetchrow_array()) {
print blah blah blah\n;
}
}


Re: Regex Problem.

2005-08-18 Thread Wiggins d'Anconia
Sara wrote:
 I am at a loss here to generate REGEX for my problem.
 
 I have an input query coming to my cgi script, containg a word (with or 
 without spaces e.g. blood Globin Test etc).
 What I am trying to do is to split this word (maximum of 3 characters) and 
 find the BEST possible matching words within mySQL database. For example if 
 the word is blood
 
 I want to get results using regex: 
 
 for blood: check(blo) then check(loo)  check(ood)
 for Globin Test: check(Glo) then check(lob)  check(obi) check(bin) 
 check(Tes) check(est)
 
 TIA.


Sounds like you need a split then a substr rather than a regex,
though I suppose it would work if you really wanted one, I wouldn't.

perldoc -f split
perldoc -f substr

It will also be faster to combine everything into one select rather than
for each possible token, but at the least if you are going to do
multiple selects use 'prepare' with placeholders and only prepare the
query once.

So,

-- UNTESTED --

my @tokens = split ' ', $entry;
my @words;
foreach my $token (@tokens) {
  push @words, substr $token, 0, 3;
  push @words, substr $token, -3, 3;
}

(or you can put the following into the above foreach however you would like)

my $where = '';
my @bind;
foreach my $word (@words) {
  $where .= ' OR ' if $where ne '';
  $where .= (def LIKE ?);
  push @bind, %$word%;
}

my $sth = $dbh-prepare(SELECT * FROM medical WHERE $where);
$sth-execute(@bind);

while (my @row = $sth-fetchrow_array) {
  print join ' ', @row;
  print \n;
}

This also prevents SQL injection by quoting the query words properly.

 Sara.


http://danconia.org

 sub check {
 my $check = $dbh - prepare(SELECT * FROM medical WHERE def LIKE '%$query%' 
 );
 $check-execute();
 while (my @row = $check - fetchrow_array()) {
 print blah blah blah\n;
 }
 }
 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Regex Problem.

2005-08-18 Thread Sara

That's worked like a charm, You ALL are great.

Thanks everyone for help.

Sara.


- Original Message - 
From: [EMAIL PROTECTED]

To: 'Sara' [EMAIL PROTECTED]
Sent: Thursday, August 18, 2005 10:50 PM
Subject: RE: Regex Problem.



Hi Sara,

what is about somthing like
$string = 'blood';
for($i=0; $i=length($string)-3;$i++) {

check(substr($string,$i,3));
}



Mit freundlichen GrĂ¼ssen
   Ihr echtwahr.Webmaster


http://www.echtwahr.de
http://www.echtwahr.com

-Original Message-
From: Sara [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 18, 2005 5:48 PM
To: beginners-cgi@perl.org
Subject: Regex Problem.

I am at a loss here to generate REGEX for my problem.

I have an input query coming to my cgi script, containg a word (with or
without spaces e.g. blood Globin Test etc).
What I am trying to do is to split this word (maximum of 3 characters) 
and

find the BEST possible matching words within mySQL database. For example
if the word is blood

I want to get results using regex:

for blood: check(blo) then check(loo)  check(ood)
for Globin Test: check(Glo) then check(lob)  check(obi)
check(bin) check(Tes) check(est)

TIA.

Sara.

sub check {
my $check = $dbh - prepare(SELECT * FROM medical WHERE def LIKE
'%$query%' );
$check-execute();
while (my @row = $check - fetchrow_array()) {
print blah blah blah\n;
}
}







--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: parsing columns

2005-08-18 Thread Marcello

Manav Mathur ha scritto:

Hi all,
I have a text file with columns, where the columns may not be aligned,
and not all lines may have data in all columns:

header1 header2 header3header4

l1dat1l1dat2l1dat3  l1dat4
l2dat1l2dat4
l3veryveryveryverylongdat1 l3dat2

As you can see, line1 has all data, line2 is missing clomuns 2 and 3,
line 3 is a mess :)

Any thoughts on parsing such a table?
Please don't offer solutions suggesting to change the way the text
file is written, I have no control over that...

Regards,
--
Offer Kaye



How do you logically determine that l2dat4 in line 2 is column 4 and not
column 2??

Manav





Just a thought: because l2dat4 starting column is greater than column 4 
header starting column ?


Marcello

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: regex - no field seperator

2005-08-18 Thread John Doe
Keenan, Greg John (Greg)** CTR ** am Donnerstag, 18. August 2005 05.34:
 Hi,

 I have the following data that I'm trying to parse into an array.  There
 are 19 fields but with hosts 5  6 fields 6  7 do not have any space
 between them.  This is how I get it from the OS and have no control over
 it.

 The maximum length for field 6 is 7 chars and field 7 is 6 chars.

 200508171648 host1.dom.com 0 0 14 2166 623 8 4 12 0 0 0 35 131 14 0 0 100
 200508171648 host2.dom.com 0 0 0 265 7563 5 3 8 0 0 0 34 66 7 0 0 100
 200508171648 host3.dom.com 0 0 0 461 8112 4 0 6 0 0 0 53 84 9 0 0 100
 200508171648 host4.dom.com 0 0 0 46 9468 5 3 9 0 0 0 39 75 8 0 2 98
 200508171648 host5.dom.com 0 1 0 7008342480 3 0 0 0 0 0 0 41 8 0 2 98
 200508171648 host6.dom.com 0 1 0 8936445548 3 0 0 0 0 0 0 14 5 0 0 100

 I have tried the following, and several other combos, with no luck.  It
 matches the first 4 lines but fails for the last 2 because they appear to
 have only 18 fields I assume.
 @oput = /(\d+) (.+\..+\..+) (\d+) (\d+) (\d+) (\d{2,7}) (\d{2,6}) (\d+)
 (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+)/;

The (\d{2,7}) (\d{2,6}) part, containing a space, won't mach concatenated 
fields 6  7.

 Can someone point me in the right direction please?

The biggest problem might be that you don't know where to split e.g. 
8936445548 in the last line into two numbers, if you know field 6 is between 
2 and 7, and field 7 between 2 and 6 digits long.

The rest of the problem as I understand it is that the layout of fields 6   7 
(2166 623 in the 1st, 8936445548 in the last line) are not perceptible 
locally, but only by looking at the whole line. (I think this is an error of 
the app producing the lines).

So, you have to take in account the whole line to extract fields 6  7.

There is for sure a way to do that in a single regex.
Also, consider the use of split in records with field separators (basically, 
here it may be missing at one place).

One basic idea to parse the lines could be:

1. split the line on space into an array.
2. Count the number of entries
3.a) 19 entries: fields 6  7 contained separately
3.b) 18 entries: fields 6  7 concatenated, handle separately
4. Handle the host field(s) and adjust the array according to the number of 
entries.


 Thanks Greg.

joe

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




splitting data stream

2005-08-18 Thread Octavian Rasnita
Hi,

I want to use regular expressions (or other techniques) to split a data
stream which has the following format:

size_of_next_bodybodysize_of_next_bodybody...

The size_of_next_body is a 4 digit number and tells the size of the next
body it should get.

Thank you very much.

Teddy


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




passing variables from perl to the system

2005-08-18 Thread Eliyah Kilada

Hi,
Do anyone know how to pass the perl variables to the system in order to 
be used later?!


I though of passing them as enviromental variables using
system (export, sys_var_name,= $perl_var_name );

but it doesn't work -:(

Any help is highly appreciated!

Best Regards,
Eliyah




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: splitting data stream

2005-08-18 Thread Moon, John
From: Octavian Rasnita [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 18, 2005 8:04 AM
To: beginners perl
Subject: splitting data stream

Hi,

I want to use regular expressions (or other techniques) to split a data
stream which has the following format:

size_of_next_bodybodysize_of_next_bodybody...

The size_of_next_body is a 4 digit number and tells the size of the next
body it should get.

Thank you very much.

Teddy


It's not clear from your note exactly what the data stream looks like... 
Is it delimited between fields? Are the fields in a record and is the
record delimited? Can you dump some of the data and include it in a post?

But given the above...

perl -e'
$a=q{0010testtest1X0005testX0001A0003BBX0006CX};
while (length($a)) {
$size=substr($a,0,4);
$body[$i]=substr($a,4,$size);
$a=substr($a,4+$size);
$i++
}
print $_\n foreach (@body);
'

DEV,SUN2
testtest1X
testX
A
BBX
CX
DEV,SUN2
jwm

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: passing variables from perl to the system

2005-08-18 Thread Xavier Noria

On Aug 18, 2005, at 13:38, Eliyah Kilada wrote:

Do anyone know how to pass the perl variables to the system in  
order to be used later?!


Perl offers built-in support for environment variables via the %ENV  
hash:


% cat foo.pl
$ENV{FOO} = foo;
system q(echo $FOO);
% perl foo.pl
foo

%ENV is documented in perlvar.

See also the Env standard module, which is specially handy for PATH- 
like variables.


-- fxn

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: passing variables from perl to the system

2005-08-18 Thread Jeff 'japhy' Pinyan

On Aug 18, Eliyah Kilada said:

Do anyone know how to pass the perl variables to the system in order to be 
used later?!


A process cannot modify its parent's environment.  You can set environment 
variables to be used during the Perl program that are visible to the Perl 
program's child processes, through the %ENV hash.  But you cannot change 
your parent's environment.


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

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: splitting data stream

2005-08-18 Thread Jeff 'japhy' Pinyan

On Aug 18, Octavian Rasnita said:


I want to use regular expressions (or other techniques) to split a data
stream which has the following format:

size_of_next_bodybodysize_of_next_bodybody...

The size_of_next_body is a 4 digit number and tells the size of the next
body it should get.


You can roll your own with substr() and what-not, or you can use the 
unpack() function to do it for you:


  my @chunks = unpack (A4/A)*, $buffer;

The A4/A means read four characters and get that many characters; the 
(...)* around that means do this repeatedly.


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

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Memory Testing

2005-08-18 Thread mgoland
Hi All,
   I am in need to do some memory stress testing. Is there a way to use C style 
malloc or calloc, to allocate blocks at a time ??

Thanks in advance,
Mark G.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Finding matches and use of __END__ in a one-liner

2005-08-18 Thread KEVIN ZEMBOWER
John, thank you so much for both your suggestions. Even though Manav's 
suggestions work, I learned a little more perl looking up the parts I didn't 
understand in your suggestions. With just a slight modification, both of these 
worked:

perl -l -0777ne'print /L:(.+)\s/, q/@/, /H:(.+)\s/' `find -name config`
perl -l -0777ne'$_ = join q/@/, /L:(.+)\s/, /H:(.+)\s/ and print'  `find -name 
config`

I had to remove the ^ anchor, because, when treating the whole file as a string 
(-l -0777), 'L:' and 'H:' are no longer at the beginning of the string. I also 
thought that I had to put in the '\s' space delimiter, but just now running 
them without the two occurrences of '\s' doesn't make any difference. Hmm, more 
to study...

Thank you again for your suggestion, and for teaching me more perl.

-Kevin Zembower

 John W. Krahn [EMAIL PROTECTED] 08/17/05 08:10PM 
John W. Krahn wrote:
 KEVIN ZEMBOWER wrote:
I have a series of EZMLM configuration files  in the ~alias directory that 
look like this:
main:/var/qmail/alias# cat cire/config 
F:-aBCdEFGHiJKlmnOpQrStuVWXYZ
X:
D:/var/qmail/alias/cire
T:/var/qmail/alias/.qmail-cire
L:cire
H:infoforhealthx.org
C:
0:
3:
4:
5:
6:
7:
8:
9:
main:/var/qmail/alias# 

I want to find them all and output the L: (list name) and H: (host name) 
information like this for the
above example:
[EMAIL PROTECTED] 

I've tried this unsuccessfully:
main:/var/qmail/alias# for x in `find -name config`; do { perl -ne 
($name)=/L:(.*)$/; ($add)=/H:(.*)$/;
__END__ { print [EMAIL PROTECTED]; } $x; } done
main:/var/qmail/alias# 

Any suggestions on the mistakes I've made?
 
 
 perl -l -0777ne'print /^L:(.+)/, q/@/, /^H:(.+)/' `find -name config`

This may work a bit better:


perl -l -0777ne'$_ = join q/@/, /^L:(.+)/, /^H:(.+)/ and print' \
 `find -name config`


:-)

John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED] 
For additional commands, e-mail: [EMAIL PROTECTED] 
http://learn.perl.org/ http://learn.perl.org/first-response


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: parsing columns

2005-08-18 Thread Wiggins d'Anconia
Marcello wrote:
 Manav Mathur ha scritto:
 
 Hi all,
 I have a text file with columns, where the columns may not be aligned,
 and not all lines may have data in all columns:

 header1 header2 header3header4
 
 l1dat1l1dat2l1dat3  l1dat4
 l2dat1l2dat4
 l3veryveryveryverylongdat1 l3dat2

 As you can see, line1 has all data, line2 is missing clomuns 2 and 3,
 line 3 is a mess :)

 Any thoughts on parsing such a table?
 Please don't offer solutions suggesting to change the way the text
 file is written, I have no control over that...

 Regards,
 -- 
 Offer Kaye



 How do you logically determine that l2dat4 in line 2 is column 4 and
 not
 column 2??

 Manav



 
 Just a thought: because l2dat4 starting column is greater than column 4
 header starting column ?
 
 Marcello
 

That still falls apart on line 3, because l3dat2 which is actually
column 2 starts after header3's initial position.

Though in that case I guess you might be able to determine that it is
column two because there aren't two spaces, but that is still using the
assumption that there *must* be at least one space character delimiting
columns.

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: regex - no field seperator

2005-08-18 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Keenan, Greg John (Greg)** CTR ** wrote:
 Hi,
 
 I have the following data that I'm trying to parse into an array. 
 There are 19 fields but with hosts 5  6 fields 6  7 do not have any
 space between them.  This is how I get it from the OS and have no
 control over it. 
 
 The maximum length for field 6 is 7 chars and field 7 is 6 chars.
 
 200508171648 host1.dom.com 0 0 14 2166 623 8 4 12 0 0 0 35 131 14 0 0 100
 200508171648 host2.dom.com 0 0 0 265 7563 5 3 8 0 0 0 34 66 7 0 0 100
 200508171648 host3.dom.com 0 0 0 461 8112 4 0 6 0 0 0 53 84 9 0 0 100
 200508171648 host4.dom.com 0 0 0 46 9468 5 3 9 0 0 0 39 75 8 0 2 98
 200508171648 host5.dom.com 0 1 0 7008342480 3 0 0 0 0 0 0 41 8 0 2 98
 200508171648 host6.dom.com 0 1 0 8936445548 3 0 0 0 0 0 0 14 5 0 0 100 
 
 I have tried the following, and several other combos, with no luck. 
 It matches the first 4 lines but fails for the last 2 because they
 appear to have only 18 fields I assume.
 @oput = /(\d+) (.+\..+\..+) (\d+) (\d+) (\d+) (\d{2,7}) (\d{2,6})
 (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+)
 (\d+)/; 
 
You are working much too hard to capture the data. Use split like:

@oput = split (/\s+/,$_);
You say it is a total of 13 characters, but in this case you have 10 
characters. How do you identify which field is full? Once you do that then the 
ability to get it can be done. But you have to first identify how to know out 
say in this case the 10 chaacters what the proper split is?

Wags ;)
 Can someone point me in the right direction please?
 
 Thanks Greg.



***
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
***


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: regex - no field seperator

2005-08-18 Thread Bryan R Harris

 I have the following data that I'm trying to parse into an array.
 There are 19 fields but with hosts 5  6 fields 6  7 do not have any
 space between them.  This is how I get it from the OS and have no
 control over it.
 
 The maximum length for field 6 is 7 chars and field 7 is 6 chars.
 
 200508171648 host1.dom.com 0 0 14 2166 623 8 4 12 0 0 0 35 131 14 0 0 100
 200508171648 host2.dom.com 0 0 0 265 7563 5 3 8 0 0 0 34 66 7 0 0 100
 200508171648 host3.dom.com 0 0 0 461 8112 4 0 6 0 0 0 53 84 9 0 0 100
 200508171648 host4.dom.com 0 0 0 46 9468 5 3 9 0 0 0 39 75 8 0 2 98
 200508171648 host5.dom.com 0 1 0 7008342480 3 0 0 0 0 0 0 41 8 0 2 98
 200508171648 host6.dom.com 0 1 0 8936445548 3 0 0 0 0 0 0 14 5 0 0 100
 
 I have tried the following, and several other combos, with no luck.
 It matches the first 4 lines but fails for the last 2 because they
 appear to have only 18 fields I assume.
 @oput = /(\d+) (.+\..+\..+) (\d+) (\d+) (\d+) (\d{2,7}) (\d{2,6})
 (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+)
 (\d+)/; 
 
 You are working much too hard to capture the data. Use split like:
 
 @oput = split (/\s+/,$_);


@oput = split;

...works too.  By default, split operates on $_, and splits on whitespace,
discarding any initial whitespace.

I owe dinner to whoever originally made that decision.

- B




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Finding matches and use of __END__ in a one-liner

2005-08-18 Thread John W. Krahn
KEVIN ZEMBOWER wrote:
 John, thank you so much for both your suggestions. Even though Manav's 
 suggestions
 work, I learned a little more perl looking up the parts I didn't understand 
 in your
 suggestions. With just a slight modification, both of these worked:
 
 perl -l -0777ne'print /L:(.+)\s/, q/@/, /H:(.+)\s/' `find -name config`
 perl -l -0777ne'$_ = join q/@/, /L:(.+)\s/, /H:(.+)\s/ and print'  `find 
 -name config`
 
 I had to remove the ^ anchor, because, when treating the whole file as a 
 string
 (-l -0777), 'L:' and 'H:' are no longer at the beginning of the string.

Sorry about that, I didn't test it enough.  :-)

You can use the ^ anchor if if you also use the /m option

perl -l -0777ne'$_ = join q/@/, /^L:(.+)/m, /^H:(.+)/m and print' \
 `find -name config`



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Memory Testing

2005-08-18 Thread Chris Devers
On Thu, 18 Aug 2005 [EMAIL PROTECTED] wrote:

I am in need to do some memory stress testing. Is there a way to 
 use C style malloc or calloc, to allocate blocks at a time ??

Not that I can think of, though there may be something under the B::* 
module namespace that does that.

Alternatively, if you already know how you'd go about this problem in C, 
then you may be able to use the Inline::C module to embed snippets of C 
code directly into your Perl script. 

That may be a reasonable compromise...



-- 
Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: parsing columns

2005-08-18 Thread Offer Kaye
On 8/18/05, Wiggins d'Anconia wrote:
 
 Though in that case I guess you might be able to determine that it is
 column two because there aren't two spaces, 

Alas, were it that simple... :( An extra space will not be included,
even if the l3dat2 would actually have been l3dat3...

 but that is still using the
 assumption that there *must* be at least one space character delimiting
 columns.

1. There *must* be at least one space character between columns.
2. Data is guaranteed not to include a whitespace.

Regards,
-- 
Offer Kaye

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Use of uninitialized value in string at ... ??

2005-08-18 Thread Michael Gale

Hello,

   I got the following function online but and receiving the error and 
do not know why ?
Use of uninitialized value in string at ./sat-main.pl line 211, STDIN 
line 1


Here is the code:

my $input;

$input = user_func(Enter command );

sub user_func {
   my $user_input;
   my ($promptString,$defaultValue) = @_;

   if ($defaultValue) {
   print $promptString, [, $defaultValue, ]: ;
   } else {
   print $promptString, : ;
   }

   $| = 1;   # force a flush after our print
   $user_input = STDIN ;   # get the input from STDIN (presumably the 
keyboard)


   chomp ($user_input);
 
   if ($defaultValue) { ## Line 211 ??
   return $user_input ? $user_input : $defaultValue;# return $_ 
if it has a value

   } else {
   return $user_input;
   }
} ## End of prompt_user

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Use of uninitialized value in string at ... ??

2005-08-18 Thread Manav Mathur


 Hello,

 I got the following function online but and receiving the error and
 do not know why ?
 Use of uninitialized value in string at ./sat-main.pl line 211, STDIN
 line 1

 Here is the code:

 my $input;

 $input = user_func(Enter command );

 sub user_func {
 my $user_input;
 my ($promptString,$defaultValue) = @_;

 if ($defaultValue) {
 print $promptString, [, $defaultValue, ]: ;
 } else {
 print $promptString, : ;
 }

 $| = 1;   # force a flush after our print
 $user_input = STDIN ;   # get the input from STDIN (presumably the
 keyboard)

 chomp ($user_input);

 if ($defaultValue) { ## Line 211 ??
 return $user_input ? $user_input : $defaultValue;# return $_
 if it has a value
 } else {
 return $user_input;
 }
 } ## End of prompt_user

 --


$default_value is undefined as you are passing only one argument to your sub
user_func(). The argument is being consumed by $promptString.

A better check instead of
 if ($defaultValue)
would be
 if (defined $defaultValue)



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: regex - no field seperator

2005-08-18 Thread Keenan, Greg John (Greg)** CTR **
-Original Message-
From: Wagner, David --- Senior Programmer Analyst --- WGO
[mailto:[EMAIL PROTECTED] 
Sent: Friday, 19 August 2005 3:21 AM
To: Keenan, Greg John (Greg)** CTR **; beginners@perl.org
Subject: RE: regex - no field seperator

Keenan, Greg John (Greg)** CTR ** wrote:
 Hi,
 
 I have the following data that I'm trying to parse into an array. 
 There are 19 fields but with hosts 5  6 fields 6  7 do not have any 
 space between them.  This is how I get it from the OS and have no 
 control over it.
 
 The maximum length for field 6 is 7 chars and field 7 is 6 chars.
 
 200508171648 host1.dom.com 0 0 14 2166 623 8 4 12 0 0 0 35 131 14 0 0 
 100
 200508171648 host2.dom.com 0 0 0 265 7563 5 3 8 0 0 0 34 66 7 0 0 100
 200508171648 host3.dom.com 0 0 0 461 8112 4 0 6 0 0 0 53 84 9 0 0 100
 200508171648 host4.dom.com 0 0 0 46 9468 5 3 9 0 0 0 39 75 8 0 2 98
 200508171648 host5.dom.com 0 1 0 7008342480 3 0 0 0 0 0 0 41 8 0 2 98
 200508171648 host6.dom.com 0 1 0 8936445548 3 0 0 0 0 0 0 14 5 0 0 100
 
 I have tried the following, and several other combos, with no luck. 
 It matches the first 4 lines but fails for the last 2 because they 
 appear to have only 18 fields I assume.
 @oput = /(\d+) (.+\..+\..+) (\d+) (\d+) (\d+) (\d{2,7}) (\d{2,6})
 (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) 
 (\d+)/;
 
   You are working much too hard to capture the data. Use split like:

   @oput = split (/\s+/,$_);
You say it is a total of 13 characters, but in this case you have 10
characters. How do you identify which field is full? Once you do that
then the ability to get it can be done. But you have to first
identify how to know out say in this case the 10 chaacters what
the proper split is?

Fields 6  7 could be a minimum of 2 chars or 7  6 chars respectively but
the only time fields 6  7 merge is if field 7 has reached its maximum
length of 6 chars.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: regex - no field seperator

2005-08-18 Thread Keenan, Greg John (Greg)** CTR **
 -Original Message-
From: John W. Krahn [mailto:[EMAIL PROTECTED] 
Sent: Friday, 19 August 2005 10:26 AM
To: Perl Beginners
Subject: Re: regex - no field seperator

Keenan, Greg John (Greg)** CTR ** wrote:
From: Wagner, David --- Senior Programmer Analyst --- WGO

Keenan, Greg John (Greg)** CTR ** wrote:

I have the following data that I'm trying to parse into an array. 
There are 19 fields but with hosts 5  6 fields 6  7 do not have any 
space between them.  This is how I get it from the OS and have no 
control over it.

The maximum length for field 6 is 7 chars and field 7 is 6 chars.

200508171648 host1.dom.com 0 0 14 2166 623 8 4 12 0 0 0 35 131 14 0 0 
100
200508171648 host2.dom.com 0 0 0 265 7563 5 3 8 0 0 0 34 66 7 0 0 100
200508171648 host3.dom.com 0 0 0 461 8112 4 0 6 0 0 0 53 84 9 0 0 100
200508171648 host4.dom.com 0 0 0 46 9468 5 3 9 0 0 0 39 75 8 0 2 98
200508171648 host5.dom.com 0 1 0 7008342480 3 0 0 0 0 0 0 41 8 0 2 98
200508171648 host6.dom.com 0 1 0 8936445548 3 0 0 0 0 0 0 14 5 0 0 
100

I have tried the following, and several other combos, with no luck. 
It matches the first 4 lines but fails for the last 2 because they 
appear to have only 18 fields I assume.
@oput = /(\d+) (.+\..+\..+) (\d+) (\d+) (\d+) (\d{2,7}) (\d{2,6})
(\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) 
(\d+)/;

  You are working much too hard to capture the data. Use split like:

  @oput = split (/\s+/,$_);
You say it is a total of 13 characters, but in this case you have 10 
characters. How do you identify which field is full? Once you do that 
then the ability to get it can be done. But you have to first 
identify how to know out say in this case the 10 chaacters what the 
proper split is?
 
 Fields 6  7 could be a minimum of 2 chars or 7  6 chars respectively 
 but the only time fields 6  7 merge is if field 7 has reached its 
 maximum length of 6 chars.

Well then, that should be easy enough.  :-)


while ( FILE ) {

my @oput = split;

if ( @oput == 18 ) {
splice @oput, 5, 1, $oput[ 5 ] =~ /(.+)(.{6})/;
}
elsif ( @oput != 19 ) {
warn Error in $file line $. - wrong number of input fields.\n;
next;
}

do_something_with( @oput );
}


Thanks to David  John for their excellent solutions.  I've learnt a little
bit more about perl  regexs over the last few days.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




copy and run a program on remote windows

2005-08-18 Thread Ken Perl
I want to implement a module in perl to do the same thing as the tool
PsExec (http://www.sysinternals.com/Utilities/PsExec.html) does, which
is used to copy and run a program on remote windows, a very cool tool!

So, I want to know if anyone has done this before. 
and If I do the implement from scratch, what modules should I use, or
any comments are welcome.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response