Re: behavior of semicolon on return line

2003-10-10 Thread John W. Krahn
[EMAIL PROTECTED] wrote:
> 
> Does the semicolon behave any differently for a return test statement?
> 
> Example,
> 
> sub validate
> { return shift =~ /^[a-zA-Z0-9][\w-]*\.[a-zA-z]+$/ }
> 
> or
> 
> sub validate
> { return shift =~ /^[a-zA-Z0-9][\w-]*\.[a-zA-z]+$/; }


Trailing commas and semicolons are optional.

( 1, 2, 3, 4 ) is the same as ( 1, 2, 3, 4, ) and { statement1;
statement1; statement1 } is the same as { statement1; statement1;
statement1; }



John
-- 
use Perl;
program
fulfillment

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



RE: behavior of semicolon on return line

2003-10-10 Thread Tim Johnson

I don't know, does it?

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Friday, October 10, 2003 7:02 PM
To: [EMAIL PROTECTED]
Subject: behavior of semicolon on return line 


Does the semicolon behave any differently for a return test statement?

Example,

sub validate
{ return shift =~ /^[a-zA-Z0-9][\w-]*\.[a-zA-z]+$/ }

or

sub validate
{ return shift =~ /^[a-zA-Z0-9][\w-]*\.[a-zA-z]+$/; }

thanks


-
eMail solutions by 
http://www.swanmail.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]



behavior of semicolon on return line

2003-10-10 Thread perl
Does the semicolon behave any differently for a return test statement?

Example,

sub validate
{ return shift =~ /^[a-zA-Z0-9][\w-]*\.[a-zA-z]+$/ }

or

sub validate
{ return shift =~ /^[a-zA-Z0-9][\w-]*\.[a-zA-z]+$/; }

thanks


-
eMail solutions by 
http://www.swanmail.com

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



Re: regex require a period

2003-10-10 Thread perl
Great! Final verification question. Atleast for now :)

Do I need to use delimiter for a hyphen?

/^[a-zA-Z0-9][\w-]*\.[a-zA-z]+$/
or
/^[a-zA-Z0-9][\w\-]*\.[a-zA-z]+$/

thanks

> --On Friday, October 10, 2003 18:21 -0700 "[EMAIL PROTECTED]"
> <[EMAIL PROTECTED]> wrote:
>
>> So, would this be it for the optional?
>>
>> /^[a-zA-Z0-9][\w-]*\.[a-zA-z]+$/
>>
>> thanks
>
> Yep, that should work for you.
>
> Daniel T. Staal
>
> (By the way: Don't reply to me *and* the list.  I've set up my email
> client so that replying to me (when I'm sending to this list) sets my
> reply address as the list.  Adding the list again just sends a dupe.
> Some people like off-list replies.  I don't.)
>
> ---
> This email copyright the author.  Unless otherwise noted, you
> are expressly allowed to retransmit, quote, or otherwise use
> the contents for non-commercial purposes.  This copyright will
> expire 5 years after the author's death, or in 30 years,
> whichever is longer, unless such a period is in excess of
> local copyright law.
> ---
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-
eMail solutions by 
http://www.swanmail.com

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



Re: regex require a period

2003-10-10 Thread Daniel Staal
--On Friday, October 10, 2003 18:21 -0700 "[EMAIL PROTECTED]" 
<[EMAIL PROTECTED]> wrote:

So, would this be it for the optional?

/^[a-zA-Z0-9][\w-]*\.[a-zA-z]+$/

thanks
Yep, that should work for you.

Daniel T. Staal

(By the way: Don't reply to me *and* the list.  I've set up my email 
client so that replying to me (when I'm sending to this list) sets my 
reply address as the list.  Adding the list again just sends a dupe. 
Some people like off-list replies.  I don't.)

---
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: regex require a period

2003-10-10 Thread perl
So, would this be it for the optional?

/^[a-zA-Z0-9][\w-]*\.[a-zA-z]+$/

thanks

> --On Friday, October 10, 2003 17:45 -0700 "[EMAIL PROTECTED]"
> <[EMAIL PROTECTED]> wrote:
>
>> start with [a-zA-Z0-9]
>> chars following is [\w-] BUT IS OPTIONAL
>>
>> /^[a-zA-Z0-9][\w-]\.[a-zA-z]+$/
>>
>> I think the regex is not doing the option \w part.
>
> Correct, it isn't.  You haven't asked it to...  To make it optional
> you need to follow the [\w-] with a count which says it is optional.
> The count would be in this form: {$min,$max}, where $min and $max are
> the minimum and maximum counts, respectively.  You can leave out $max
> if there is no maximum count.  (But you still need the comma; without
> it you have an _exact_ count.)  So for zero or more times you need
> the quantifier: {0,}.
>
> There are also three shortcut quantifiers: '*', '+', '?'.  (Without
> the quotes.)  Their meanings are:
> * = {0,}
> + = {1,}
> ? = {0,1}
>
> Note that all the quantifiers are 'greedy'[1]: they match the longest
> string of characters they possibly can.
>
> Ok, now that we've got that over with, why aren't you using the
> 'validate' sub?  It is likely to be faster than the above regrex...
>
> Daniel T. Staal
>
> [1] Well, there is a way around this.  But that's another lesson.
>
> ---
> This email copyright the author.  Unless otherwise noted, you
> are expressly allowed to retransmit, quote, or otherwise use
> the contents for non-commercial purposes.  This copyright will
> expire 5 years after the author's death, or in 30 years,
> whichever is longer, unless such a period is in excess of
> local copyright law.
> ---
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-
eMail solutions by 
http://www.swanmail.com

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



Re: regex require a period

2003-10-10 Thread Daniel Staal
--On Friday, October 10, 2003 17:45 -0700 "[EMAIL PROTECTED]" 
<[EMAIL PROTECTED]> wrote:

start with [a-zA-Z0-9]
chars following is [\w-] BUT IS OPTIONAL
/^[a-zA-Z0-9][\w-]\.[a-zA-z]+$/

I think the regex is not doing the option \w part.
Correct, it isn't.  You haven't asked it to...  To make it optional 
you need to follow the [\w-] with a count which says it is optional. 
The count would be in this form: {$min,$max}, where $min and $max are 
the minimum and maximum counts, respectively.  You can leave out $max 
if there is no maximum count.  (But you still need the comma; without 
it you have an _exact_ count.)  So for zero or more times you need 
the quantifier: {0,}.

There are also three shortcut quantifiers: '*', '+', '?'.  (Without 
the quotes.)  Their meanings are:
* = {0,}
+ = {1,}
? = {0,1}

Note that all the quantifiers are 'greedy'[1]: they match the longest 
string of characters they possibly can.

Ok, now that we've got that over with, why aren't you using the 
'validate' sub?  It is likely to be faster than the above regrex...

Daniel T. Staal

[1] Well, there is a way around this.  But that's another lesson.

---
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: regex require a period

2003-10-10 Thread perl
The regex below is working for after the period. The part in fron is not
working. It is requiring atleast 2 chars before the period which is not my
rule. the rule for the front part:

start with [a-zA-Z0-9]
chars following is [\w-] BUT IS OPTIONAL

/^[a-zA-Z0-9][\w-]\.[a-zA-z]+$/

I think the regex is not doing the option \w part.

Example, a.c is failing. it's suppose to be true.

thanks



> --On Friday, October 10, 2003 16:43 -0700 "[EMAIL PROTECTED]"
> <[EMAIL PROTECTED]> wrote:
>
>> rules:
>> starts with alphanumeric
>> 3 chars long
>
> Note, so we are not confused: you mean _at least_ 3 chars long.  (Not
> _only_ 3 chars long.)
>
>> require ONLY one period
>> require alpha after the period
>
> Ok, what exactly do you mean here?  Is this:
> a. Require _only_ alpha after the period?
> b. Require _the next char_ to be alpha?
>
> Either one is possible from your description, and could be a big
> difference.
>
>> /^[a-zA-Z0-9][\w-].[a-zA-z]/ #but now working
>>
>> sub validate {
>> local $_ = shift;
>> return( length >= 3 and
>> tr/.// == 1 and
>> /^[[:alpha:]]/ and
>>/[a-zA-Z0-9].[a-zA-Z]/ ); #added here still not working
>> }
>
> That last line says: Match one character (alpha or numeric only) then
> any character, then a single alpha character.
>
> If you want the _next_ character to be alpha, the following should
> work:
> /\.[[:alpha:]]/
>
> If you want _only_ (and at least one) alpha after the period, you
> need this:
> /\.[[:alpha:]]+$/
>
> Hope this helps.
>
> Daniel T. Staal
>
> ---
> This email copyright the author.  Unless otherwise noted, you
> are expressly allowed to retransmit, quote, or otherwise use
> the contents for non-commercial purposes.  This copyright will
> expire 5 years after the author's death, or in 30 years,
> whichever is longer, unless such a period is in excess of
> local copyright law.
> ---
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-
eMail solutions by 
http://www.swanmail.com

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



Re: regex require a period

2003-10-10 Thread perl
The regex below is working for after the period. The part in fron is not
working. It is requiring atleast 2 chars before the period which is not my
rule. the rule for the front part:

start with [a-zA-Z0-9]
chars following is [\w-] BUT IS OPTIONAL

/^[a-zA-Z0-9][\w-]\.[a-zA-z]+$/

I think the regex is not doing the option \w part.

thanks

> --On Friday, October 10, 2003 16:43 -0700 "[EMAIL PROTECTED]"
> <[EMAIL PROTECTED]> wrote:
>
>> rules:
>> starts with alphanumeric
>> 3 chars long
>
> Note, so we are not confused: you mean _at least_ 3 chars long.  (Not
> _only_ 3 chars long.)
>
>> require ONLY one period
>> require alpha after the period
>
> Ok, what exactly do you mean here?  Is this:
> a. Require _only_ alpha after the period?
> b. Require _the next char_ to be alpha?
>
> Either one is possible from your description, and could be a big
> difference.
>
>> /^[a-zA-Z0-9][\w-].[a-zA-z]/ #but now working
>>
>> sub validate {
>> local $_ = shift;
>> return( length >= 3 and
>> tr/.// == 1 and
>> /^[[:alpha:]]/ and
>>/[a-zA-Z0-9].[a-zA-Z]/ ); #added here still not working
>> }
>
> That last line says: Match one character (alpha or numeric only) then
> any character, then a single alpha character.
>
> If you want the _next_ character to be alpha, the following should
> work:
> /\.[[:alpha:]]/
>
> If you want _only_ (and at least one) alpha after the period, you
> need this:
> /\.[[:alpha:]]+$/
>
> Hope this helps.
>
> Daniel T. Staal
>
> ---
> This email copyright the author.  Unless otherwise noted, you
> are expressly allowed to retransmit, quote, or otherwise use
> the contents for non-commercial purposes.  This copyright will
> expire 5 years after the author's death, or in 30 years,
> whichever is longer, unless such a period is in excess of
> local copyright law.
> ---
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-
eMail solutions by 
http://www.swanmail.com

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



NET::FTP problem w/CHMOD

2003-10-10 Thread [EMAIL PROTECTED]
Hi

I am trying to use the NET::FTP module to recursively chmod files.
Either of these two ways of telling the server to chmod it seem to work:
$ftp->command("SITE CHMOD 755 $file");
or
$ftp->quot("SITE CHMOD 755 $file");
...but once that runs once, even successfully, $ftp->pwd() returns an 
empty string afterwards, and no files are found if I cwd to valid 
directories.

I know the FTP section is working right, I can watch it run through 
every file and folder in the cgi-bin recursively, *if* I comment out the 
 CHMOD line.

If I leave that line active, it does CHMOD everything in the base dir, 
but can't cwd after the first CHMOD.

 Does anyone have any ideas of why this may be happening?

TIA

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


Re: regex require a period

2003-10-10 Thread Daniel Staal
--On Friday, October 10, 2003 16:43 -0700 "[EMAIL PROTECTED]" 
<[EMAIL PROTECTED]> wrote:

rules:
starts with alphanumeric
3 chars long
Note, so we are not confused: you mean _at least_ 3 chars long.  (Not 
_only_ 3 chars long.)

require ONLY one period
require alpha after the period
Ok, what exactly do you mean here?  Is this:
a. Require _only_ alpha after the period?
b. Require _the next char_ to be alpha?
Either one is possible from your description, and could be a big 
difference.

/^[a-zA-Z0-9][\w-].[a-zA-z]/ #but now working

sub validate {
local $_ = shift;
return( length >= 3 and
tr/.// == 1 and
/^[[:alpha:]]/ and
   /[a-zA-Z0-9].[a-zA-Z]/ ); #added here still not working
}
That last line says: Match one character (alpha or numeric only) then 
any character, then a single alpha character.

If you want the _next_ character to be alpha, the following should 
work:
/\.[[:alpha:]]/

If you want _only_ (and at least one) alpha after the period, you 
need this:
/\.[[:alpha:]]+$/

Hope this helps.

Daniel T. Staal

---
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: how do I pass null arguement?

2003-10-10 Thread Thomas Bätzler
Hi,

[EMAIL PROTECTED] wrote:
> How do I pass a null variable as an argument? Sometime I may want a
> wrapper sub as below:
> 
> Example,
> ...
> sub procName
> { my $fname = $_[0];
>   my $lname = $_[1]];
> }

Alternatively, you could write either

  my $fname = shift;
  my $lname = shift;

or even

  my( $fname, $lname ) = @_;

> 
> my procByLastName{ mySubA(null, "doe"); }
> ...
> 
> This is the error message:
> Bareword "null" not allowed while "strict subs" in use

Perl's notion of NULL would be undef, i.e. not defined.
As such, it's distinct from an empty string or zero as
a numeric value.

The function defined() helps you to test wether a value
is undef or not.

BTW, since you ask about argument passing and undef,
a nice way to handle setting defaults for arguments
is using this syntax:

my $var = shift || "default";

Works great if your expected arguments are always
defined and true. It would set $var to "default"
if you pass in an empty string or the number 0,
though.

HTH,
Thomas

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



Re: Declaring sub at top or bottom matter?

2003-10-10 Thread John W. Krahn
[EMAIL PROTECTED] wrote:
> 
> Does declaring at the top or the bottom matter?

Yes.

But you probably meant defining a sub in which case ... maybe ... but
usually no.

Have you read the perlsub.pod document?


John
-- 
use Perl;
program
fulfillment

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



Re: regex require a period

2003-10-10 Thread perl
rules:
starts with alphanumeric
3 chars long
require ONLY one period
require alpha after the period

/^[a-zA-Z0-9][\w-].[a-zA-z]/ #but now working

sub validate {
local $_ = shift;
return( length >= 3 and
tr/.// == 1 and
/^[[:alpha:]]/ and
   /[a-zA-Z0-9].[a-zA-Z]/ ); #added here still not working
}

expecting results:

a.com - true
1.com - true
a_.com - true
a-.com - true

abc   - false
a.b.c - false
a.1   - false
a.-   - false
a._   - false
_a.c  - false
-a.c  - false

I think this covers it all?
thanks
> On Fri, Oct 10, 2003 at 03:56:43PM -0700, [EMAIL PROTECTED] wrote:
>> Ok - I got it to work by changing the line to length >= 3
>
> Good.
>
>> If I could push the rule a little further, a new rule added
>> is that an alpha char a-Z MUST be after the period.
>
> Well now you have four rules.  Again, I think I'd do this
> in four steps (of which you already have solutions for three).
>
> What have you tried for the new requirement?
>
> --
> Steve
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-
eMail solutions by 
http://www.swanmail.com

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



Re: regex require a period

2003-10-10 Thread Steve Grazzini
On Fri, Oct 10, 2003 at 03:56:43PM -0700, [EMAIL PROTECTED] wrote:
> Ok - I got it to work by changing the line to length >= 3

Good.
 
> If I could push the rule a little further, a new rule added 
> is that an alpha char a-Z MUST be after the period.

Well now you have four rules.  Again, I think I'd do this 
in four steps (of which you already have solutions for three).

What have you tried for the new requirement?

-- 
Steve

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



Re: regex require a period

2003-10-10 Thread perl
Ok - I got it to work by changing the line to length >= 3

If I could push the rule a little further, a new rule added is that an
alpha char a-Z MUST be after the period.

thanks



> On Fri, Oct 10, 2003 at 03:11:52PM -0700, [EMAIL PROTECTED] wrote:
>> This is not working as I expected:
>>
>> if(validate('abc.com'))
>> { print "true"; }
>> else
>> { print "false"; }
>
> It prints "false" (because the length is > 4).
>
>> >   sub validate {
>> > local $_ = shift;
>> > return( length == 4 and
>> > tr/.// == 1 and
>> > /^[[:alpha:]]/ )
>> >   }
>
> What did you expect it to do?
>
> --
> Steve
>



-
eMail solutions by 
http://www.swanmail.com

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



Re: regex require a period

2003-10-10 Thread Steve Grazzini
On Fri, Oct 10, 2003 at 03:11:52PM -0700, [EMAIL PROTECTED] wrote:
> This is not working as I expected:
> 
> if(validate('abc.com'))
> { print "true"; }
> else
> { print "false"; }

It prints "false" (because the length is > 4).

> >   sub validate {
> > local $_ = shift;
> > return( length == 4 and
> > tr/.// == 1 and
> > /^[[:alpha:]]/ )
> >   }

What did you expect it to do?

-- 
Steve

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



Declaring sub at top or bottom matter?

2003-10-10 Thread perl
Does declaring at the top or the bottom matter?

thanks


-
eMail solutions by 
http://www.swanmail.com

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



Re: regex require a period

2003-10-10 Thread perl
> /^[a-zA-Z][\w\-\.]{3,}$/ && /\./

The above matches more than 1 period.

I MUST have 1 and ONLY 1 period. Also, can I
 fit it on one line?

this doesn't work either
 sub isValidDomain
 { return shift =~ /^[a-zA-Z0-9][\w\-\.]{3,}$/ }

thanks

 ---
> How about something like:
>
> /^[a-zA-Z][\w\-\.]{3,}$/ && /\./
>
> On Fri, 2003-10-10 at 16:58, [EMAIL PROTECTED] wrote:
> here's the rules:
> starts with alphanumeric
> 4 chars long
> require one period
>
>> /^[a-zA-Z][\w\-\.]{3,}$/
>>
>> I think my regex is not doing the required period.
>>
>> thanks,
>> -rkl
>>
>>
>> -
>> eMail solutions by
>> http://www.swanmail.com
>
>



 -
 eMail solutions by
 http://www.swanmail.com




-
eMail solutions by 
http://www.swanmail.com

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



RE: how do I pass null arguement?

2003-10-10 Thread perl
Good info.

thanks,
-rkl

> Hi,
>
> [EMAIL PROTECTED] wrote:
>> How do I pass a null variable as an argument? Sometime I may want a
>> wrapper sub as below:
>>
>> Example,
>> ...
>> sub procName
>> { my $fname = $_[0];
>>   my $lname = $_[1]];
>> }
>
> Alternatively, you could write either
>
>   my $fname = shift;
>   my $lname = shift;
>
> or even
>
>   my( $fname, $lname ) = @_;
>
>>
>> my procByLastName{ mySubA(null, "doe"); }
>> ...
>>
>> This is the error message:
>> Bareword "null" not allowed while "strict subs" in use
>
> Perl's notion of NULL would be undef, i.e. not defined.
> As such, it's distinct from an empty string or zero as
> a numeric value.
>
> The function defined() helps you to test wether a value
> is undef or not.
>
> BTW, since you ask about argument passing and undef,
> a nice way to handle setting defaults for arguments
> is using this syntax:
>
> my $var = shift || "default";
>
> Works great if your expected arguments are always
> defined and true. It would set $var to "default"
> if you pass in an empty string or the number 0,
> though.
>
> HTH,
> Thomas
>



-
eMail solutions by 
http://www.swanmail.com

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



Re: regex require a period

2003-10-10 Thread perl
This is not working as I expected:

if(validate('abc.com'))
{ print "true"; }
else
{ print "false"; }

-rkl

> On Fri, Oct 10, 2003 at 12:49:51AM -0700, [EMAIL PROTECTED] wrote:
>> I couldn't get it to work.
>
> Whoops -->
>
>   sub validate {
> local $_ = shift;
> return( length == 4 and
> tr/.// == 1 and
> /^[[:alpha:]]/ )
>   }
>
> --
> Steve
>



-
eMail solutions by 
http://www.swanmail.com

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



Re: Hash Print and Delete

2003-10-10 Thread Wiggins d'Anconia


On Fri, 10 Oct 2003 12:53:48 -0700 (PDT), Jeff Westman <[EMAIL PROTECTED]> wrote:

> Wiggins d'Anconia <[EMAIL PROTECTED]> wrote:
> > 
> > 
> > On Fri, 10 Oct 2003 09:11:28 -0700 (PDT), Jeff Westman <[EMAIL PROTECTED]>
> > wrote:
> > 
> > 
> > > 
> > > I know perl returns the last value (statement?) by default, but doesn't
> > it
> > > make it more readable (or self-documenting) to the next person who may
> > come
> > > along what my intent is?
> > > 
> > 
> > Just so your opinion is backed up, I am very glad you said that and
> > definitely appreciate it :-). But I am one of those "lets be explicit about
> > what I mean" programmers, at least in any thing over 10 lines of code, but
> > then I type faster than average which may be why I was never concerned
> > about a few extra characters here and there, and I have never had to work
> > over a 900, 1200, 2400, baud modem
> > 
> > To put it another way, IMHO, you will *never* be frowned upon for including
> > a 'return' when that is what you mean, but be prepared for a thrashing the
> > first time you leave an open ended function that returns a value that it
> > shouldn't and you break someone else's code because of it.
> 
> Hi Wags,
> 
> Not sure what you mean by 'open ended function'.  Seems to me there would be
> more danger for someone to accidently add code below my last line in my
> function.  Put another way, using a 'return' statement is explicit, whereas
> leaving it as the so-called perl way, leaves it implicit and open to someone
> adding their own code below that -- which would then blow up the expected
> returned value.
> 
> I'm all for making things consise and effecient, but intent and clarity are
> equally important :)

Maybe you misunderstood me, or I was unclear (see happens in e-mails too ;-)) but I 
was actually very much agreeing with you! You have pointed out exactly what I mean by 
an 'open ended function'... With the 'return' in there the exact situation you mention 
is, to me, less likely to happen because as you indicate someone will have to pay 
attention to your previous 'return'. Without the explicit 'close' (read: return) the 
function is 'open ended' such that code can come after it to form a 'new end'.

Always fun when 'diagreeing to agree'  ;-)...

http://danconia.org

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



Re: traversing a variable with regex instead of a file

2003-10-10 Thread John W. Krahn
[Sorry for the line wrapping on my previous post   :-)]


Angie Ahl wrote:
> 
> on 2003-10-10 James Edward Gray II said:
> 
> >Keep your replies on the list, so you can get help from all the people
> >smarter than me.  ;)
> 
> If there are people smarter than you out there I must be an amoeba ;)
> 
> >Okay, why put this inside an if block.  If it doesn't find a match it
> >will fail and do nothing, which is what you want, right?  I don't think
> >you need the if.
> 
> Good point.
> 
> >Why don't we work on your Regular Expression a little and see if we can
> >do it all in one move.  We want to find all occurrences of the keyword,
> >as long as they're not on a line beginning with qz, right?  This seems
> >to do that for me:
> >
> >$content =~ s/^([^\n]*)($kw)/substr($1, 0, 2) ne 'qz' ? "$1\n$2\n" :
> >"$1$2"/mge;
> >
> 
> Ok. I had to stop to pick myself up off the floor then. WOW.
> 
> This has actually made it possible to cut the whole thing down massively.
> 
> here's the code now:

Some thoughts and suggestions if you don't mind.  :-)


> # get line breaks to make 's at the end
> $content =~ s/\n/-qbr-/g;

I will assume that $content contains only printable characters so why replace
one printable character with five printable characters (which might occur in
$content for some reason) when you could replace it with a non-printable character?

$content =~ s/\n/\0/g; OR $content =~ s/\n/\x7F/g; OR $content =~ s/\n/\xFF/g;


> # find markup and add markers so it doesn't get processed by regex,
> # no keyword links to be made inside other tags
> $content =~ s/(\[(img|page|link|mp3)=.*?\])/\nqz$1\n/g;

Your alternation is using capturing parens but you are not using $2 so you
should probably use non-capturing parens.

$content =~ s/(\[(?:img|page|link|mp3)=.*?\])/\nqz$1\n/g;


> # find HTML so it doesn't get processed by regex,
> # no keyword links to be made inside valid HTML
> $content =~ s/(<.*?>)/\nqz$1\n/g;

This may or may not work as intended as regexs aren't really good for
parsing HTML.

http://groups.google.com/groups?as_q=parse+HTML&num=50&as_scoring=r&hl=en&ie=ISO-8859-1&btnG=Google+Search&as_oq=regex+regexp+%22regular+expression%22&as_ugroup=comp.lang.perl.misc


> for my $href ( @Keywords ) {
> 
> # get each keyword and llok for it in content.
> for $kw ( keys %$href ) {

You should make $kw a lexical variable (you are using strict?)

  for my $kw ( keys %$href ) {


> if ($content =~ /\b($kw)\b/g) {

You don't need the if statement as the substitution below will do the right
thing on its own.


> # do the very clever reg with help from and thanks to
> # [EMAIL PROTECTED]
> $content =~ s/^([^\n]*)($kw)/substr($1, 0, 2) ne 'qz' ?
> "$1\nqz[link=\"$href->{$kw}\" title=\"$2\"]\n" : "$1$2"/mge;

.* is the same as [^\n]* if you are not using the /s option.  Your match
above uses word boundaries (\b) around $kw so you should use them here.
You can use negative look-ahead to simplify that a bit.

$content =~ s/^(?!qz)(.*)\b($kw)\b/$1\nqz[link="$href->{$kw}" title="$2"]\n/mg;


> }
> }
> }
> 
> # clean up those line breaks and markers;
> $content =~ s/\n(qz)?//g;
> 
> # put in 's
> $content =~ s/-qbr-/\n/g;
> 
> print $content;
> _
> 
> As you can see I've adapted your regex a little to put in the full markup around
> the keyword.
> 
> The regex itself made perfect sense, it was the
> 
> "" ? "" : "" bit that I've never seen before. That's really useful.
> 
> I assume it means
> 
> "if statement" ? "do if true" : "do if false"

Yes, but it is more like:

"if expression" ? "return if true" : "return if false"


> Please do correct me if I'm wrong. What do you call that? I think I'm going it
> be using that quite a bit ;)

That is called the "Conditional Operator".  You can find it in the perlop.pod document.


> do I even need the if false bit in this case?

In the example provided, yes.

Note that the conditional operator can also be used as an lvalue (you can assign to 
it.)

$x = $y == 41 ? $a : $b;

( $y == 41 ? $a : $b ) = $x;




John
-- 
use Perl;
program
fulfillment

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



Re: traversing a variable with regex instead of a file

2003-10-10 Thread John W. Krahn
Angie Ahl wrote:
> 
> on 2003-10-10 James Edward Gray II said:
> 
> >Keep your replies on the list, so you can get help from all the people
> >smarter than me.  ;)
> 
> If there are people smarter than you out there I must be an amoeba ;)
> 
> >Okay, why put this inside an if block.  If it doesn't find a match it
> >will fail and do nothing, which is what you want, right?  I don't think
> >you need the if.
> 
> Good point.
> 
> >Why don't we work on your Regular Expression a little and see if we can
> >do it all in one move.  We want to find all occurrences of the keyword,
> >as long as they're not on a line beginning with qz, right?  This seems
> >to do that for me:
> >
> >$content =~ s/^([^\n]*)($kw)/substr($1, 0, 2) ne 'qz' ? "$1\n$2\n" :
> >"$1$2"/mge;
> >
> 
> Ok. I had to stop to pick myself up off the floor then. WOW.
> 
> This has actually made it possible to cut the whole thing down massively.
> 
> here's the code now:

Some thoughts and suggestions if you don't mind.  :-)


> # get line breaks to make 's at the end
> $content =~ s/\n/-qbr-/g;

I will assume that $content contains only printable characters so why
replace
one printable character with five printable characters (which might
occur in
$content for some reason) when you could replace it with a non-printable
character?

$content =~ s/\n/\0/g; OR $content =~ s/\n/\x7F/g; OR $content =~
s/\n/\xFF/g;


> # find markup and add markers so it doesn't get processed by regex,
> # no keyword links to be made inside other tags
> $content =~ s/(\[(img|page|link|mp3)=.*?\])/\nqz$1\n/g;

Your alternation is using capturing parens but you are not using $2 so
you
should probably use non-capturing parens.

$content =~ s/(\[(?:img|page|link|mp3)=.*?\])/\nqz$1\n/g;


> # find HTML so it doesn't get processed by regex,
> # no keyword links to be made inside valid HTML
> $content =~ s/(<.*?>)/\nqz$1\n/g;

This may or may not work as intended as regexs aren't really good for
parsing HTML.

http://groups.google.com/groups?as_q=parse+HTML&num=50&as_scoring=r&hl=en&ie=ISO-8859-1&btnG=Google+Search&as_oq=regex+regexp+%22regular+expression%22&as_ugroup=comp.lang.perl.misc


> for my $href ( @Keywords ) {
> 
> # get each keyword and llok for it in content.
> for $kw ( keys %$href ) {

You should make $kw a lexical variable (you are using strict?)

  for my $kw ( keys %$href ) {


> if ($content =~ /\b($kw)\b/g) {

You don't need the if statement as the substitution below will do the
right
thing on its own.


> # do the very clever reg with help from and thanks to
> # [EMAIL PROTECTED]
> $content =~ s/^([^\n]*)($kw)/substr($1, 0, 2) ne 'qz' ?
> "$1\nqz[link=\"$href->{$kw}\" title=\"$2\"]\n" : "$1$2"/mge;

.* is the same as [^\n]* if you are not using the /s option.  Your match
above uses word boundaries (\b) around $kw so you should use them here.
You can use negative look-ahead to simplify that a bit.

$content =~ s/^(?!qz)(.*)\b($kw)\b/$1\nqz[link="$href->{$kw}"
title="$2"]\n/mg;


> }
> }
> }
> 
> # clean up those line breaks and markers;
> $content =~ s/\n(qz)?//g;
> 
> # put in 's
> $content =~ s/-qbr-/\n/g;
> 
> print $content;
> _
> 
> As you can see I've adapted your regex a little to put in the full markup around
> the keyword.
> 
> The regex itself made perfect sense, it was the
> 
> "" ? "" : "" bit that I've never seen before. That's really useful.
> 
> I assume it means
> 
> "if statement" ? "do if true" : "do if false"

Yes, but it is more like:

"if expression" ? "return if true" : "return if false"


> Please do correct me if I'm wrong. What do you call that? I think I'm going it
> be using that quite a bit ;)

That is called the "Conditional Operator".  You can find it in the
perlop.pod document.


> do I even need the if false bit in this case?

In the example provided, yes.

Note that the conditional operator can also be used as an lvalue (you
can assign to it.)

$x = $y == 41 ? $a : $b;

( $y == 41 ? $a : $b ) = $x;



John
-- 
use Perl;
program
fulfillment

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



Re: Hash Print and Delete

2003-10-10 Thread Jeff Westman
Wiggins d'Anconia <[EMAIL PROTECTED]> wrote:
> 
> 
> On Fri, 10 Oct 2003 09:11:28 -0700 (PDT), Jeff Westman <[EMAIL PROTECTED]>
> wrote:
> 
> 
> > 
> > I know perl returns the last value (statement?) by default, but doesn't
> it
> > make it more readable (or self-documenting) to the next person who may
> come
> > along what my intent is?
> > 
> 
> Just so your opinion is backed up, I am very glad you said that and
> definitely appreciate it :-). But I am one of those "lets be explicit about
> what I mean" programmers, at least in any thing over 10 lines of code, but
> then I type faster than average which may be why I was never concerned
> about a few extra characters here and there, and I have never had to work
> over a 900, 1200, 2400, baud modem
> 
> To put it another way, IMHO, you will *never* be frowned upon for including
> a 'return' when that is what you mean, but be prepared for a thrashing the
> first time you leave an open ended function that returns a value that it
> shouldn't and you break someone else's code because of it.

Hi Wags,

Not sure what you mean by 'open ended function'.  Seems to me there would be
more danger for someone to accidently add code below my last line in my
function.  Put another way, using a 'return' statement is explicit, whereas
leaving it as the so-called perl way, leaves it implicit and open to someone
adding their own code below that -- which would then blow up the expected
returned value.

I'm all for making things consise and effecient, but intent and clarity are
equally important :)


-Jeff

__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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



Re: Hash Print and Delete

2003-10-10 Thread Wiggins d'Anconia


On Fri, 10 Oct 2003 09:11:28 -0700 (PDT), Jeff Westman <[EMAIL PROTECTED]> wrote:


> 
> I know perl returns the last value (statement?) by default, but doesn't it
> make it more readable (or self-documenting) to the next person who may come
> along what my intent is?
> 

Just so your opinion is backed up, I am very glad you said that and definitely 
appreciate it :-). But I am one of those "lets be explicit about what I mean" 
programmers, at least in any thing over 10 lines of code, but then I type faster than 
average which may be why I was never concerned about a few extra characters here and 
there, and I have never had to work over a 900, 1200, 2400, baud modem

To put it another way, IMHO, you will *never* be frowned upon for including a 'return' 
when that is what you mean, but be prepared for a thrashing the first time you leave 
an open ended function that returns a value that it shouldn't and you break someone 
else's code because of it.

http://danconia.org

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



Re: 2 newbie questions

2003-10-10 Thread Jeff Westman
Bee <[EMAIL PROTECTED]> wrote:

> hello all, 
> 
> I've just start my learning on perl, and recently still learning some basic
> syntax.
> So I hope my question is still making sense.
> 
> I am now learning about how to write files and wondering is that possible
> to inserting / overwriting bytes in files ( text / binary ). and I am on
> Win32.

Yes -- See "perldoc read" and "perldoc seek".  Basically, you find where in
the file you want to replace text (the offset) then replace from there.

>  Also, I am still learning how to use perldoc, and I found something is
> tutorial...
> so.. would anybody tell how many tutorials inside and what are they ?

There are tons of online tutorials, but you should start with the perl
documentation first.  'perldoc' has several forms, bascically,

   perldoc PACKAGE or DOCUMENTATION   (example above)
   perldoc -q "some search criteria   (q = query)
   perldoc -f "some function" (example: perldoc -f print)

Start with 'perldoc perl'.

Hope that gets you started.

-Jeff


__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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



RE: RE: Beginner Help Please- Oracle How To?

2003-10-10 Thread Tristram Nefzger
http://www.perl.com/CPAN/modules/by-module/DBD/

-Original Message-
From: jeffrey pearson [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 10, 2003 2:21 PM
To: Bob Showalter
Cc: [EMAIL PROTECTED]
Subject: Re: RE: Beginner Help Please- Oracle How To?


My apologies for being vague.

I have the client sw installed. I can connect and work with my databases
via SQLPlus just fine.

The issue Im having is I understand I need DBD::Oracle. I cant find it.
If I go into ppm and do a search Oracle, I get:

1. Class-DBI-Oracle
2. Class-DBI-Oracle
3. DBIx-OracleLogin
4. DBIx-OracleLogin
5. DDL-Oracle



not a DBD::Oracle in sight.

OK. Where do I get this module from?



- Original Message -
From: Bob Showalter <[EMAIL PROTECTED]>
Date: Friday, October 10, 2003 10:53 am
Subject: RE: Beginner Help Please- Oracle How To?

> jeffrey pearson wrote:
> > Im hoping I could get some beginner help please. Im in the middle of

> > writing my first PERL program. My development machine is WinXP. Ive 
> > downloaded, installed and am working with the ActivePERL 5.8. Im 
> > trying to connect and access an oracle database. Ive figured out how

> > and successfully installed the DBI module. What else do I need to 
> > install to connect and do queries against my Oracle database? Where 
> > do I get what I need from?
> 
> You need Oracle client software (from Oracle)
> 
> Then you need DBD::Oracle (use ppm to install it)
> 
> The docs for DBD::Oracle give all the details on connecting to the 
> database.
> 
> --
> 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]



2 newbie questions

2003-10-10 Thread Bee
hello all, 

I've just start my learning on perl, and recently still learning some basic syntax.
So I hope my question is still making sense.

I am now learning about how to write files and wondering is that possible
to inserting / overwriting bytes in files ( text / binary ). and I am on Win32.

Also, I am still learning how to use perldoc, and I found something is tutorial...
so.. would anybody tell how many tutorials inside and what are they ?

thank a lot



Re: RE: Beginner Help Please- Oracle How To?

2003-10-10 Thread jeffrey pearson
My apologies for being vague.

I have the client sw installed. I can connect and work with my databases via SQLPlus 
just fine.

The issue Im having is I understand I need DBD::Oracle. I cant find it. If I go into 
ppm and do a search Oracle, I get:

1. Class-DBI-Oracle
2. Class-DBI-Oracle
3. DBIx-OracleLogin
4. DBIx-OracleLogin
5. DDL-Oracle



not a DBD::Oracle in sight.

OK. Where do I get this module from?



- Original Message -
From: Bob Showalter <[EMAIL PROTECTED]>
Date: Friday, October 10, 2003 10:53 am
Subject: RE: Beginner Help Please- Oracle How To?

> jeffrey pearson wrote:
> > Im hoping I could get some beginner help please. Im in the
> > middle of writing my first PERL program. My development
> > machine is WinXP. Ive downloaded, installed and am working
> > with the ActivePERL 5.8. Im trying to connect and access an
> > oracle database. Ive figured out how and successfully
> > installed the DBI module. What else do I need to install to
> > connect and do queries against my Oracle database? Where do I get
> > what I need from? 
> 
> You need Oracle client software (from Oracle)
> 
> Then you need DBD::Oracle (use ppm to install it)
> 
> The docs for DBD::Oracle give all the details on connecting to the database.
> 
> -- 
> 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: grep argument list too long...how to get around it?

2003-10-10 Thread david
Kevin Old wrote:

> On Fri, 2003-10-10 at 11:46, Steve Grazzini wrote:
>> On Fri, Oct 10, 2003 at 09:35:25AM -0400, Kevin Old wrote:
>> > On Fri, 2003-10-10 at 02:44, Steve Grazzini wrote:
>> > > On Thu, Oct 09, 2003 at 12:21:57PM -0400, Kevin Old wrote:
>> > > > Are you sure about using ls?  We have directory here that has
>> > > > several thousand files in it and when doing an ls
>> > > > *.whatever-extension we always get an "argument list too long".
>> > > >
>> > > > Any idea what the actual file limit is for grep?
>> > > 
>> > > It's a system limit (not specific to grep) based on the size-in-bytes
>> > > of the argument list (not the number of items).
>> > 
>> > So it's related to my ulimit open files?
>> 
>> No.  (It's ARG_MAX...)
> 
> I'm running Mandrake 9.0 and my ARG_MAX is not set, so is it
> "unlimited"?  If not, what is the default?

for a linux box, this number is hidden inside:

[panda]$ grep ARG_MAX /usr/include/linux/limits.h
#define ARG_MAX   131072/* # bytes of args + environ for exec() */
[panda]$

> 
> Is it the same on other *nix systems?
> 

no. it's not always the same for all *nix system. openBSD:

[tiger]# grep ARG_MAX /usr/include/sys/syslimits.h
#define ARG_MAX  (256 * 1024)   /* max bytes for an exec function */
[tiger]#

this is implementation dependent. if you run into this limit, consider using 
xargs if your system has it. man xargs.

david
-- 
$_=q,015001450154015401570040016701570162015401440041,,*,=*|=*_,split+local$";
map{~$_&1&&{$,<<=1,[EMAIL PROTECTED]||3])=>~}}0..s~.~~g-1;*_=*#,

goto=>print+eval

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



Re: traversing a variable with regex instead of a file

2003-10-10 Thread James Edward Gray II
On Friday, October 10, 2003, at 12:46  PM, Rob Dixon wrote:

my @lines = split /(\n)/, $data;
foreach (@lines) { do_something() if /pattern/; }
$data = join '', @lines;
Hi James.

I'm not sure if the group saw all of the dialogue? Later
postings seem to assume an enclosing loop as you wrote
above.
It seems wasteful to split $data like that and process
each record (including the alternate "\n" separators)
when you could probably just process the entire string
using the /m (multi-record) qualifer on the regex
(which is exactly what it was meant for).
That's what we settled on too.  You're right, I should have just wrote 
it that way to begin with.  Thanks for the advice.

James

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


Re: Hash Print and Delete

2003-10-10 Thread Rob Dixon

Jeff Westman wrote:
>
> Rob Dixon <[EMAIL PROTECTED]> wrote:
>
> >  [...snip...]
> > > > >return (exists $myHash{$val1} ) ? $Hash{$val2} : undef;
> > > > Likewise, 'delete' returns either the element deleted or 'undef' if
> > > > it didn't exist.
> >  [...snip...]
> > > I didn't know 'delete' returned the value as well.  Simple and perfect!
> >
> > Having posted that I wondered whether you really meant what you wrote,
> > i.e. that you want to return and delete $Hash{$val2} based on whether
> > or not $myHash{$val1} exists. If that's correct then you still need
> > the conditional expression, but it seemed a little unlikely?
>
> I guess there are other ways to do it and this may be reduntant since if I
> can't delete the hash value, it will return undef anyway.

Be careful here Jeff as I'm not sure I've advised you correctly.

>From what you wrote it looks as though you may need something like:

  my $retval = undef;
  $retval = delete $Hash{$val2} if exists $myHash{$val1};
  return $retval;

but there seems to be an unwritten relationship between

  $myHash{$val1}

and

  $Hash{$val2}

which I found unlikely.

Is this actually the case?

Rob



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



RE: Beginner Help Please- Oracle How To?

2003-10-10 Thread Bob Showalter
jeffrey pearson wrote:
> Im hoping I could get some beginner help please. Im in the
> middle of writing my first PERL program. My development
> machine is WinXP. Ive downloaded, installed and am working
> with the ActivePERL 5.8. Im trying to connect and access an
> oracle database. Ive figured out how and successfully
> installed the DBI module. What else do I need to install to
> connect and do queries against my Oracle database? Where do I get
> what I need from? 

You need Oracle client software (from Oracle)

Then you need DBD::Oracle (use ppm to install it)

The docs for DBD::Oracle give all the details on connecting to the database.

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



Re: Hash Print and Delete

2003-10-10 Thread Jeff Westman
Rob Dixon <[EMAIL PROTECTED]> wrote:

>  [...snip...]
> > > >return (exists $myHash{$val1} ) ? $Hash{$val2} : undef;
> > > Likewise, 'delete' returns either the element deleted or 'undef' if
> > > it didn't exist.
>  [...snip...]
> > I didn't know 'delete' returned the value as well.  Simple and perfect!
> 
> Having posted that I wondered whether you really meant what you wrote,
> i.e. that you want to return and delete $Hash{$val2} based on whether
> or not $myHash{$val1} exists. If that's correct then you still need
> the conditional expression, but it seemed a little unlikely?

I guess there are other ways to do it and this may be reduntant since if I
can't delete the hash value, it will return undef anyway.
 
> > I know perl returns the last value (statement?) by default,
> 
> The returned value is the value of the last executed statement as
> long as that statement was an expression. If not then I'm unclear
> as to the exact behaviour.
>  [...snip...]
> returns the empty string (false, but not 'undef')
> 
> Maybe somebody else knows?
> 
> > but doesn't it make it more readable (or self-documenting) to
> > the next person who may come along what my intent is?
> 
> IMO it would make it more obvious and wouldn't do any harm, but I've
> seen very little code written like that. It depends on whether you
> want your code to be 'familiar' or 'explicit'. Take a look at

Since we use so many different coding languages in our shop, I just want to
make the "obvious" definitive.  Not everyone in this shop uses perl (most use
Java), so I just wanted to be clear in my intention(s) in the code...


-Jeff

__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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



Re: traversing a variable with regex instead of a file

2003-10-10 Thread Rob Dixon
James Edward Gray II wrote:
>
> On Friday, October 10, 2003, at 08:17  AM, angie ahl wrote:
>
> > while ($line = <>) {
> > if ($line =~ /$pattern/o) {
> > # do something
> > }
> > }
> >
> > It's almost exactly what I want to do. I want to see if a line starts
> > with a
> > pattern and if doesn't do something, so I would use unless instead of
> > if.
> >
> > However the file I want to run this on is actually in a variable not a
> > file.
> > Normal line endings of \n.
>
> The answer is in the question.  :)  The first line of your code sample
> reads a line from a file and stores it in the variable $line.  The
> second line in your sample, tests for a pattern in the variable $line.
>
> Or did you mean, how would you go through a variable's content
> line-by-line?  For that, try something like this:
>
> my @lines = split /(\n)/, $data;
> foreach (@lines) { do_something() if /pattern/; }
> $data = join '', @lines;

Hi James.

I'm not sure if the group saw all of the dialogue? Later
postings seem to assume an enclosing loop as you wrote
above.

It seems wasteful to split $data like that and process
each record (including the alternate "\n" separators)
when you could probably just process the entire string
using the /m (multi-record) qualifer on the regex
(which is exactly what it was meant for).

I don't have a clear grasp of the problem and don't
know if this is applicable.

Cheers,

Rob



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



RE: Beginner Help Please- Oracle How To?

2003-10-10 Thread Paul Kraus
perldoc DBI

Or 

http://safari.oreilly.com/JVXSL.asp?x=1&mode=section&sortKey=rank&sortOr
der=desc&view=book&xmlid=1-56592-699-4&open=false&g=&srchText=dbi&code=&
h=&m=&l=1&catid=&s=1&b=1&f=1&t=1&c=1&u=1&r=&o=1&page=0

-Original Message-
From: jeffrey pearson [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 10, 2003 1:36 PM
To: [EMAIL PROTECTED]
Subject: Beginner Help Please- Oracle How To?


Im hoping I could get some beginner help please. Im in the middle of
writing my first PERL program. My development machine is WinXP. Ive
downloaded, installed and am working with the ActivePERL 5.8. Im trying
to connect and access an oracle database. Ive figured out how and
successfully installed the DBI module. What else do I need to install to
connect and do queries against my Oracle database? Where do I get what I
need from?

Help would be greatly and humbly appreciated.

Jeff Pearson


-- 
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]



Beginner Help Please- Oracle How To?

2003-10-10 Thread jeffrey pearson
Im hoping I could get some beginner help please. Im in the middle of writing my first 
PERL program. My development machine is WinXP. Ive downloaded, installed and am 
working with the ActivePERL 5.8. Im trying to connect and access an oracle database. 
Ive figured out how and successfully installed the DBI module. What else do I need to 
install to connect and do queries against my Oracle database? Where do I get what I 
need from?

Help would be greatly and humbly appreciated.

Jeff Pearson


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



Re: Fwd: required help

2003-10-10 Thread Tore Aursand
On Fri, 10 Oct 2003 08:40:17 -0500, James Edward Gray II wrote:
> I want to insert data from sms_log ie 10.100.208.254 server to 
> 10.100.200.47 table ie sms_log1.

Well.  What have you tried so far?  It should be easy as long as you
create two database connections?


-- 
Tore Aursand <[EMAIL PROTECTED]>


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



Re: working on time

2003-10-10 Thread Tore Aursand
On Fri, 10 Oct 2003 12:13:45 -0400, Bill Akins wrote:
> Try this:
> #!/usr/bin/perl -w
>  
> my @now = localtime;
> my $sec = ( $now[0] );
> my $min = ( $now[1] );
> my $hr  = ( $now[2] );
> my $day = ( $now[3] );
> my $mth = ( $now[4] + 1 );
> my $yr  = ( $now[5] + 1900 );
>  
> $day = ($day -1);

No!  Do _not_ try this!  What happens when you're using this code on the
1st of a month?

I recently fallen in love (...) with Time::Piece (and Time::Seconds),
which let me do this in a nifty way;

  #!/usr/bin/perl
  #
  use strict;
  use warnings;
  use Time::Seconds;
  use Time::Piece;

  my $today = localtime;
  my $yesterday = $today - ONE_DAY;
  my $tomorrow  = $today + ONE_DAY;

Install Time::Piece and do a 'perldoc Time::Piece' for more information.


-- 
Tore Aursand <[EMAIL PROTECTED]>


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



RE: working on time

2003-10-10 Thread Bill Akins
I thought of that right after hitting send...
 
This may be better if he wants to do a lot of date manipulation down the road:
 
#!/usr/bin/perl -w
 
use Date::Manip;
 
my ($day, $mnth, $yr);
my $date = DateCalc("today","- 1day");
($yr, $mnth, $day) = ($date =~ /(\d\d\d\d)(\d\d)(\d\d)/);
print "Yesterday was $mnth/$day/$yr\n";



>>> Bob Showalter <[EMAIL PROTECTED]> 10/10/03 12:20PM >>>
Bill Akins wrote:
> ...
> Try this:
> #!/usr/bin/perl -w
> 
> my @now = localtime;
> my $sec = ( $now[0] );
> my $min = ( $now[1] );
> my $hr  = ( $now[2] );
> my $day = ( $now[3] );
> my $mth = ( $now[4] + 1 );
> my $yr  = ( $now[5] + 1900 );
> 
> $day = ($day -1);
> print "Yesterday was $mth/$day/$yr\nor if on the other side
> of the pond, $day/$mth/$yr\n";

What if today is the first of the month?

Better to use something like:

   ($d, $m, $y) = (localtime(time - 86_400))[3..5];
   $m++;
   $y += 1900;

IOW, have the system calculate local time for current epoch - 86,400
seconds (# of seconds in a day).




Re: working on time

2003-10-10 Thread Tore Aursand
On Fri, 10 Oct 2003 14:57:47 +0200,
[EMAIL PROTECTED] wrote:
> i search hiw can i work on time.
> i want to get day number and make -1

Check out the heap of Date-related modules on http://www.cpan.org/.


-- 
Tore Aursand <[EMAIL PROTECTED]>


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



RE: grep argument list too long...how to get around it?

2003-10-10 Thread Alexandru Colea
You can put arguments in a file and then open and parse the file inside
perl.

-Alex C.

-Original Message-
From: Steve Grazzini [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 10, 2003 12:29 PM
To: Kevin Old
Cc: Dan Muey; [EMAIL PROTECTED]
Subject: Re: grep argument list too long...how to get around it?

On Fri, Oct 10, 2003 at 12:37:02PM -0400, Kevin Old wrote:
> On Fri, 2003-10-10 at 11:46, Steve Grazzini wrote:
> > No.  (It's ARG_MAX...)
> 
> I'm running Mandrake 9.0 and my ARG_MAX is not set, so is it
> "unlimited"?  If not, what is the default?

It's not an environment variable.  (Check limits.h.)

And remember, that's not the *number* of files/arguments/whatever.
ARG_MAX is the total *memory* that can be used for a new process's
environment and argument list.

% export FOO=$( perl -le 'print "x" x 2**17' )
% ls
bash: /bin/ls: Argument list too long

-- 
Steve

-- 
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: traversing a variable with regex instead of a file

2003-10-10 Thread James Edward Gray II
On Friday, October 10, 2003, at 10:51  AM, angie ahl wrote:

on 2003-10-10 James Edward Gray II said:

Keep your replies on the list, so you can get help from all the people
smarter than me.  ;)
If there are people smarter than you out there I must be an amoeba ;)
There are some very brilliant people hiding here.  Stick around and 
you'll spot on eventually...

Okay, why put this inside an if block.  If it doesn't find a match it
will fail and do nothing, which is what you want, right?  I don't 
think
you need the if.
Good point.
Thanks, I thought so too, but you forgot to take my advice.  You still 
don't need the if block you have in the code.  :D

$content =~ s/^([^\n]*)($kw)/substr($1, 0, 2) ne 'qz' ? "$1\n$2\n" :
"$1$2"/mge;
Ok. I had to stop to pick myself up off the floor then. WOW.
I love that silly little /e modifier myself.  I use it a lot.  It 
wouldn't surprise me if one of the Regex Gurus could do it even better 
though.  I'm still reading Mastering Regular Expressions myself.  ;)

# get line breaks to make 's at the end
$content =~ s/\n/-qbr-/g;
# find markup and add markers so it doesn't get processed by regex,
# no keyword links to be made inside other tags
$content =~ s/(\[(img|page|link|mp3)=.*?\])/\nqz$1\n/g;
# find HTML so it doesn't get processed by regex,
# no keyword links to be made inside valid HTML
$content =~ s/(<.*?>)/\nqz$1\n/g;
There are some excellent HTML parser modules on the CPAN that could 
possibly help you do this kind of thing, just FYI.

for my $href ( @Keywords ) {

# get each keyword and llok for it in content.
for $kw ( keys %$href ) {
if ($content =~ /\b($kw)\b/g) {
The if above is not needed, as near as I can tell, though you should 
probably add the \b...\b around the $kw in my expression.  There's 
certainly no reason to use a global search above, since you're just 
checking to see if it's present.

# do the very clever reg with help from and thanks to
# [EMAIL PROTECTED]
$content =~ s/^([^\n]*)($kw)/substr($1, 0, 2) ne 'qz' ?
"$1\nqz[link=\"$href->{$kw}\" title=\"$2\"]\n" : "$1$2"/mge;
}
}
}
# clean up those line breaks and markers;
$content =~ s/\n(qz)?//g;
# put in 's
$content =~ s/-qbr-/\n/g;
print $content;
_
As you can see I've adapted your regex a little to put in the full 
markup around
the keyword.
Making changes already.  You're a natural.

The regex itself made perfect sense, it was the

"" ? "" : "" bit that I've never seen before. That's really useful.

I assume it means

"if statement" ? "do if true" : "do if false"
You assume right.  The Ternary Operator (or Conditional Operator) is a 
simple if/else shorthand.  It's not too popular, probably for 
readibility reasons, but I use it a lot in things like Regexes and 
map().  If you want to know more:

perldoc perlop

Then type:

/Conditional Operator

Please do correct me if I'm wrong. What do you call that? I think I'm 
going it
be using that quite a bit ;)

do I even need the if false bit in this case?
Yes, and this is important.  The way I wrote the match, it will find 
ALL $kw occurrences, even the ones on qz lines.  So after we learn 
we're on a qz line, we need to put things back with our replace, so it 
looks like we never messed with it.

I used the /e modifier for the replacement, which allows me to use 
Perl
code in there.  It's pretty simple.  If the line didn't start with a
qz, we do a normal replace.
That's going in my BBEdit gold dust code snippets glossary.
A BBEdit user, and by extension a Mac user too, eh?  That settles it, 
we're going to be great friends you and I.  ;)

Unfortunately, the /e trick doesn't work in BBEdit's Search/Replace 
dialogs, though it has excellent Grep support.

Your right about it being inefficient, of course.  It was easier to
read than my Regex though, eh?  
Are you implying that regex isn't easy to read ;)
Me, I love a little line noise in the morning, but that might be why 
I'm a Super Geek.

The first choice may be slow,
but on modern computers they may both work in the blink of an eye.
Save worrying about speed for when you need to and try and keep your
life as a programmer as easy as possible until then.
Sadly then is now. That's why I joined up to this list today ;)

This code will be run on every single page of a website, in one go. So 
it needs
to be as efficient as physically possible. The site will only be a few 
hundred
pages, and not all pages will always be processed. It's a system that 
makes it's
own links and maintains them, so eveytime a page's keywords change 
this has to
be done to all pages that contain that keyword.
Fair enough.  Just remember that measuring the different between two 
pieces of code that both run in under a second is usually pretty 
pointless.  Start optimizing AFTER you start waiting on executions, not 
before.

I know this is not a task for the beginner, but this is actually 
version 3 of
the code. my old programming language sta

Re: grep argument list too long...how to get around it?

2003-10-10 Thread Steve Grazzini
On Fri, Oct 10, 2003 at 12:37:02PM -0400, Kevin Old wrote:
> On Fri, 2003-10-10 at 11:46, Steve Grazzini wrote:
> > No.  (It's ARG_MAX...)
> 
> I'm running Mandrake 9.0 and my ARG_MAX is not set, so is it
> "unlimited"?  If not, what is the default?

It's not an environment variable.  (Check limits.h.)

And remember, that's not the *number* of files/arguments/whatever.
ARG_MAX is the total *memory* that can be used for a new process's
environment and argument list.

% export FOO=$( perl -le 'print "x" x 2**17' )
% ls
bash: /bin/ls: Argument list too long

-- 
Steve

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



Re: Hash Print and Delete

2003-10-10 Thread Rob Dixon
Jeff Westman wrote:
>
> Rob Dixon <[EMAIL PROTECTED]> wrote:
>
> > Jeff Westman wrote:
> > >
> > > If I have an array and want to take the first element off and return it,
> > I
> > > would do it like this:
> > >
> > >return (@myArray) ? shift(@myArray) : undef;
> > >
> > > How would I do similarly with a hash?  I have something like this:
> > >
> > >
> > >return (exists $myHash{$val1} ) ? $Hash{$val2} : undef;
> > >
> > > But these leaves the value in the hash.  I know I can save the value
> > first,
> > > then DELETE it, and then return it.  But I'd like to do it all in one
> > step.
> >
> > Hi Jeff.
> >
> > The 'shift' built-in returns 'undef' if its operand is an empty array.
> >
> > Likewise, 'delete' returns either the element deleted or 'undef' if
> > it didn't exist.
>
> I didn't know 'delete' returned the value as well.  Simple and perfect!

Having posted that I wondered whether you really meant what you wrote,
i.e. that you want to return and delete $Hash{$val2} based on whether
or not $myHash{$val1} exists. If that's correct then you still need
the conditional expression, but it seemed a little unlikely?

> > It's also usual to omit 'return' on the last line of a subroutine,
> > so you could just write:
> >
> >   shift @myArray;
> >
> > and
> >
> >   delete $myHash{$val1}
> >
> > to do what you want.
>
> I know perl returns the last value (statement?) by default,

The returned value is the value of the last executed statement as
long as that statement was an expression. If not then I'm unclear
as to the exact behaviour.

  sub test {
my $v = 0;
for (1 .. 10) {
  $v++;
}
  }

returns the empty string (false, but not 'undef')

Maybe somebody else knows?

> but doesn't it make it more readable (or self-documenting) to
> the next person who may come along what my intent is?

IMO it would make it more obvious and wouldn't do any harm, but I've
seen very little code written like that. It depends on whether you
want your code to be 'familiar' or 'explicit'. Take a look at

  perldoc perlstyle

for similar stuff.

Cheers,

Rob



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



Re: grep argument list too long...how to get around it?

2003-10-10 Thread Kevin Old
On Fri, 2003-10-10 at 11:46, Steve Grazzini wrote:
> On Fri, Oct 10, 2003 at 09:35:25AM -0400, Kevin Old wrote:
> > On Fri, 2003-10-10 at 02:44, Steve Grazzini wrote:
> > > On Thu, Oct 09, 2003 at 12:21:57PM -0400, Kevin Old wrote:
> > > > Are you sure about using ls?  We have directory here that has several
> > > > thousand files in it and when doing an ls *.whatever-extension we always
> > > > get an "argument list too long".
> > > >
> > > > Any idea what the actual file limit is for grep?
> > > 
> > > It's a system limit (not specific to grep) based on the size-in-bytes
> > > of the argument list (not the number of items).
> > 
> > So it's related to my ulimit open files?
> 
> No.  (It's ARG_MAX...)

I'm running Mandrake 9.0 and my ARG_MAX is not set, so is it
"unlimited"?  If not, what is the default?

Is it the same on other *nix systems?

Thanks,
Kevin

-- 
Kevin Old <[EMAIL PROTECTED]>


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



Re: perl install on redhat 9

2003-10-10 Thread Dan Anderson
> I have installed perl 8

Perl 8?  What cool features does that have?  Can I borrow your time
machine?

>  on redhat 9 and I installed it from source. (not 
> an rpm) however, when I did a redhat up2date, the rpm's were then 
> re-installed.

Hmmm... I don't use RedHat, so I'm not sure how up2date works, but I'd
guess that it may have seen Perl 5.8 as a failed RPM installation or
something.

> I think that the rpm installed perl in /usr/bin
> and the source install put it in /usr/local/bin

Quite possibly.  You only need to know this if you did anything besides
the default ./configure (i.e. purposely installed it in
/var/logs/not_really_a_log/ha/ive/hidden/perl to be silly/)

> can I safely uninstall the perl rpm's without messing up the other 
> installation from source?

It shouldn't hurt your system too much.  I suppose there is a good
chance that uninstalling an RPM will uninstall a dependency that the
source install links to.  Why are you installing a source version
anyways?  You shouldn't mix and match sources and RPMS.  It's bad form
and can lead to problems.

-Dan


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



RE: working on time

2003-10-10 Thread Bob Showalter
Bill Akins wrote:
> ...
> Try this:
> #!/usr/bin/perl -w
> 
> my @now = localtime;
> my $sec = ( $now[0] );
> my $min = ( $now[1] );
> my $hr  = ( $now[2] );
> my $day = ( $now[3] );
> my $mth = ( $now[4] + 1 );
> my $yr  = ( $now[5] + 1900 );
> 
> $day = ($day -1);
> print "Yesterday was $mth/$day/$yr\nor if on the other side
> of the pond, $day/$mth/$yr\n";

What if today is the first of the month?

Better to use something like:

   ($d, $m, $y) = (localtime(time - 86_400))[3..5];
   $m++;
   $y += 1900;

IOW, have the system calculate local time for current epoch - 86,400
seconds (# of seconds in a day).

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



RE: Hash Print and Delete

2003-10-10 Thread Jeff Westman
Paul Kraus <[EMAIL PROTECTED]> wrote:

> Why wouldn't you just return(shift(@myarray)

Yes, this works for a normal(?) array, but I was asking about hashes.

> As far as the hash why are you trying to remove it? I would assume it
> because you don't have a use for it outside of the scope of the
> subroutine. If so why don't you just make the hash scoped to the sub.
> Then you return the value you want and when the sub ends the hash is
> sent to the abyss?

I'm deleting values in an array and a hash.  Any left over values (or keys)
signify an error and incomplete processing.

Thanks

-Jeff

__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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



Re: working on time

2003-10-10 Thread Bill Akins
 
 

Bill Akins
SSS III
Emory Healthcare
(404) 712-2879 - Office
12674 - PIC
[EMAIL PROTECTED]>>> "[EMAIL PROTECTED]" 10/10/03 08:57AM >>> 
>Hi, 

>i search hiw can i work on time. 
>i want to get day number and make -1 


Try this:
#!/usr/bin/perl -w
 
my @now = localtime;
my $sec = ( $now[0] );
my $min = ( $now[1] );
my $hr  = ( $now[2] );
my $day = ( $now[3] );
my $mth = ( $now[4] + 1 );
my $yr  = ( $now[5] + 1900 );
 
$day = ($day -1);
print "Yesterday was $mth/$day/$yr\nor if on the other side of the pond, 
$day/$mth/$yr\n";

 
I hope that helps!



CPAN install failure...

2003-10-10 Thread Rick Bragg
Hi,

I just tried to install HTML::Parser on my Redhat9 system
and I got the following.
Should I just force it? if so how is that done...

Thanks
Rick
sorry for all the output...

-

Running install for module HTML::Parser
Running make for G/GA/GAAS/HTML-Parser-3.31.tar.gz
  Is already unwrapped into directory /root/.cpan/build/HTML-Parser-3.31
  Has already been processed within this session
Running make test
PERL_DL_NONLAZY=1 /usr/local/bin/perl "-MExtUtils::Command::MM" "-e" 
"test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/api_versionok 

t/argspec-badok 

t/argspecok 

t/argspec2...ok 

t/attr-encoded...ok 

t/callback...ok 

t/case-sensitive.ok 

t/cases..ok 

t/commentok 

t/crashmeok 

t/declarationok 

t/defaultok 

t/dtext..ok 

t/entities...ok 3/11Confused test output: test 3 answered after 
test 3
t/entities...ok 4/11Confused test output: test 4 answered after 
test 4
t/entities...ok 5/11Confused test output: test 5 answered after 
test 5
t/entities...ok 6/11Confused test output: test 6 answered after 
test 6
t/entities...ok 7/11Confused test output: test 7 answered after 
test 7
t/entities...NOK 8Confused test output: test 8 answered after 
test 8
t/entities...ok 9/11Confused test output: test 9 answered after 
test 9
t/entities...ok 10/11Confused test output: test 10 answered 
after test 10
t/entities...FAILED tests 2, 9 

Failed 2/11 tests, 81.82% okay
t/entities2..ok 

t/filter-methods.ok 

t/filter.ok 

t/handler-eofok 

t/handlerok 

t/headparser-httpok 

t/headparser.FAILED test 3 

Failed 1/4 tests, 75.00% okay
t/ignore.ok 

t/largetags..ok 

t/linkextor-base.ok 

t/linkextor-rel..ok 

t/magic..ok 

t/marked-sectok 

t/msie-compatok 

t/offset.ok 

t/optionsok 

t/parsefile..ok 

t/parser.ok 

t/plaintext..ok 

t/processok 

t/pullparser.ok 

t/skipped-text...ok 

t/textarea...ok 

t/tokeparser.ok 

t/uentities..skipped
all skipped: no reason given
t/unbroken-text..ok 

t/xml-mode...ok 

Failed TestStat Wstat Total Fail  Failed  List of Failed
---
t/entities.t 112  18.18%  2 9
t/headparser.t41  25.00%  3
1 test skipped.
Failed 2/41 test scripts, 95.12% okay. 3/227 subtests failed, 98.68% okay.
make: *** [test_dynamic] Error 29
  /usr/bin/make test -- NOT OK
Running make install
  make test had returned bad status, won't install without force
-

--
Rick Bragg
Green Mountain Network
http://www.gmnet.net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Hash Print and Delete

2003-10-10 Thread Jeff Westman
Rob Dixon <[EMAIL PROTECTED]> wrote:

> Jeff Westman wrote:
> >
> > If I have an array and want to take the first element off and return it,
> I
> > would do it like this:
> >
> >return (@myArray) ? shift(@myArray) : undef;
> >
> > How would I do similarly with a hash?  I have something like this:
> >
> >
> >return (exists $myHash{$val1} ) ? $Hash{$val2} : undef;
> >
> > But these leaves the value in the hash.  I know I can save the value
> first,
> > then DELETE it, and then return it.  But I'd like to do it all in one
> step.
> 
> Hi Jeff.
> 
> The 'shift' built-in returns 'undef' if its operand is an empty array.
> 
> Likewise, 'delete' returns either the element deleted or 'undef' if
> it didn't exist.

I didn't know 'delete' returned the value as well.  Simple and perfect!

> It's also usual to omit 'return' on the last line of a subroutine,
> so you could just write:
> 
>   shift @myArray;
> 
> and
> 
>   delete $myHash{$val1}
> 
> to do what you want.

I know perl returns the last value (statement?) by default, but doesn't it
make it more readable (or self-documenting) to the next person who may come
along what my intent is?


-Jeff

__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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



Re: grep argument list too long...how to get around it?

2003-10-10 Thread Steve Grazzini
On Fri, Oct 10, 2003 at 09:35:25AM -0400, Kevin Old wrote:
> On Fri, 2003-10-10 at 02:44, Steve Grazzini wrote:
> > On Thu, Oct 09, 2003 at 12:21:57PM -0400, Kevin Old wrote:
> > > Are you sure about using ls?  We have directory here that has several
> > > thousand files in it and when doing an ls *.whatever-extension we always
> > > get an "argument list too long".
> > >
> > > Any idea what the actual file limit is for grep?
> > 
> > It's a system limit (not specific to grep) based on the size-in-bytes
> > of the argument list (not the number of items).
> 
> So it's related to my ulimit open files?

No.  (It's ARG_MAX...)

-- 
Steve

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



Re: Hash Print and Delete

2003-10-10 Thread Rob Dixon
Jeff Westman wrote:
>
> If I have an array and want to take the first element off and return it, I
> would do it like this:
>
>return (@myArray) ? shift(@myArray) : undef;
>
> How would I do similarly with a hash?  I have something like this:
>
>
>return (exists $myHash{$val1} ) ? $Hash{$val2} : undef;
>
> But these leaves the value in the hash.  I know I can save the value first,
> then DELETE it, and then return it.  But I'd like to do it all in one step.

Hi Jeff.

The 'shift' built-in returns 'undef' if its operand is an empty array.

Likewise, 'delete' returns either the element deleted or 'undef' if
it didn't exist.

It's also usual to omit 'return' on the last line of a subroutine,
so you could just write:

  shift @myArray;

and

  delete $myHash{$val1}

to do what you want.

Cheers,

Rob



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



Re: traversing a variable with regex instead of a file

2003-10-10 Thread angie ahl
on 2003-10-10 James Edward Gray II said:

>Keep your replies on the list, so you can get help from all the people 
>smarter than me.  ;)

If there are people smarter than you out there I must be an amoeba ;)

>Okay, why put this inside an if block.  If it doesn't find a match it 
>will fail and do nothing, which is what you want, right?  I don't think 
>you need the if.

Good point.

>Why don't we work on your Regular Expression a little and see if we can 
>do it all in one move.  We want to find all occurrences of the keyword, 
>as long as they're not on a line beginning with qz, right?  This seems 
>to do that for me:
>
>$content =~ s/^([^\n]*)($kw)/substr($1, 0, 2) ne 'qz' ? "$1\n$2\n" : 
>"$1$2"/mge;
>

Ok. I had to stop to pick myself up off the floor then. WOW.

This has actually made it possible to cut the whole thing down massively.

here's the code now:

_ 
# get line breaks to make 's at the end
$content =~ s/\n/-qbr-/g;

# find markup and add markers so it doesn't get processed by regex, 
# no keyword links to be made inside other tags
$content =~ s/(\[(img|page|link|mp3)=.*?\])/\nqz$1\n/g;

# find HTML so it doesn't get processed by regex, 
# no keyword links to be made inside valid HTML
$content =~ s/(<.*?>)/\nqz$1\n/g;

for my $href ( @Keywords ) {

# get each keyword and llok for it in content.
for $kw ( keys %$href ) {
if ($content =~ /\b($kw)\b/g) {

# do the very clever reg with help from and thanks to   
# [EMAIL PROTECTED]
$content =~ s/^([^\n]*)($kw)/substr($1, 0, 2) ne 'qz' ?
"$1\nqz[link=\"$href->{$kw}\" title=\"$2\"]\n" : "$1$2"/mge;
}
}
}

# clean up those line breaks and markers;
$content =~ s/\n(qz)?//g;

# put in 's
$content =~ s/-qbr-/\n/g;

print $content;
_

As you can see I've adapted your regex a little to put in the full markup around
the keyword.

The regex itself made perfect sense, it was the 

"" ? "" : "" bit that I've never seen before. That's really useful.

I assume it means

"if statement" ? "do if true" : "do if false"

Please do correct me if I'm wrong. What do you call that? I think I'm going it
be using that quite a bit ;)

do I even need the if false bit in this case?

>I used the /e modifier for the replacement, which allows me to use Perl 
>code in there.  It's pretty simple.  If the line didn't start with a 
>qz, we do a normal replace.  

That's going in my BBEdit gold dust code snippets glossary.

>Let me know if that will work for you.

It did, perfectly. Thank you soo much,

>Your right about it being inefficient, of course.  It was easier to 
>read than my Regex though, eh?

Are you implying that regex isn't easy to read ;)

>The first choice may be slow, 
>but on modern computers they may both work in the blink of an eye.  
>Save worrying about speed for when you need to and try and keep your 
>life as a programmer as easy as possible until then.

Sadly then is now. That's why I joined up to this list today ;)

This code will be run on every single page of a website, in one go. So it needs
to be as efficient as physically possible. The site will only be a few hundred
pages, and not all pages will always be processed. It's a system that makes it's
own links and maintains them, so eveytime a page's keywords change this has to
be done to all pages that contain that keyword.

I know this is not a task for the beginner, but this is actually version 3 of
the code. my old programming language started to show it's dislike for regex.

>> If you have any suggestions I would be most grateful to hear them.
>
>Those are my best shots.  Hope they help.

They did, thank you so much.

Angie

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



RE: Hash Print and Delete

2003-10-10 Thread Paul Kraus
Opps type return(shift(@myarray))

-Original Message-
From: Paul Kraus [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 10, 2003 11:46 AM
To: 'Jeff Westman'; 'beginners'
Subject: RE: Hash Print and Delete


Why wouldn't you just return(shift(@myarray)

As far as the hash why are you trying to remove it? I would assume it
because you don't have a use for it outside of the scope of the
subroutine. If so why don't you just make the hash scoped to the sub.
Then you return the value you want and when the sub ends the hash is
sent to the abyss?

Not that I am some expert but that's how I would do it. Without seeing
what your trying to accomplish its hard to say.

Paul

-Original Message-
From: Jeff Westman [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 10, 2003 11:40 AM
To: beginners
Subject: Hash Print and Delete


Question:

If I have an array and want to take the first element off and return it,
I would do it like this:

   return (@myArray) ? shift(@myArray) : undef;

How would I do similarly with a hash?  I have something like this:


   return (exists $myHash{$val1} ) ? $Hash{$val2} : undef;

But these leaves the value in the hash.  I know I can save the value
first, then DELETE it, and then return it.  But I'd like to do it all in
one step.

TIA

-Jeff

__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.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]



Re: Hash Print and Delete

2003-10-10 Thread Casey West
It was Friday, October 10, 2003 when Jeff Westman took the soap box, saying:
: Question:
: 
: If I have an array and want to take the first element off and return it, I
: would do it like this:
: 
:return (@myArray) ? shift(@myArray) : undef;
: 
: How would I do similarly with a hash?  I have something like this:
: 
: 
:return (exists $myHash{$val1} ) ? $Hash{$val2} : undef;
: 
: But these leaves the value in the hash.  I know I can save the value first,
: then DELETE it, and then return it.  But I'd like to do it all in one step.

When you call delete(), it deletes the element from the hash *and*
reurns that element's value.  This is very handy.

return (exists $myHash{$val1}) ? delete $myHash{$val2} : undef;

  Casey West

-- 
"Stocks have reached what looks like a permanently high plateau."
 -- Irving Fisher, Professor of Economics, Yale University, 1929.


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



RE: Hash Print and Delete

2003-10-10 Thread Paul Kraus
Why wouldn't you just return(shift(@myarray)

As far as the hash why are you trying to remove it? I would assume it
because you don't have a use for it outside of the scope of the
subroutine. If so why don't you just make the hash scoped to the sub.
Then you return the value you want and when the sub ends the hash is
sent to the abyss?

Not that I am some expert but that's how I would do it. Without seeing
what your trying to accomplish its hard to say.

Paul

-Original Message-
From: Jeff Westman [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 10, 2003 11:40 AM
To: beginners
Subject: Hash Print and Delete


Question:

If I have an array and want to take the first element off and return it,
I would do it like this:

   return (@myArray) ? shift(@myArray) : undef;

How would I do similarly with a hash?  I have something like this:


   return (exists $myHash{$val1} ) ? $Hash{$val2} : undef;

But these leaves the value in the hash.  I know I can save the value
first, then DELETE it, and then return it.  But I'd like to do it all in
one step.

TIA

-Jeff

__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.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]



Error while installing PPM

2003-10-10 Thread ramakrishna
Hi,

I am new to perl.
After installing Perl on Win 2000 Adv server, when i enter into PPM mode and use 
'Search *' for listing the packages it is showing the following error
"ppm> search *
Searching in Active Repositories
Error: No valid repositories: Error: 500 Can't connect to
ppm.ActiveState.com:80 (Bad hostname 'ppm.ActiveState.com') Error: 500
Can't connect to ppm.ActiveState.com:80 (Bad hostname
'ppm.ActiveState.com')
ppm> prop
No query results to describe -- use 'query' to find a package.

I thought the installation of Perl itself installs some default packages. 

Please help me out.

Thanks,
Ramakrishna.


Hash Print and Delete

2003-10-10 Thread Jeff Westman
Question:

If I have an array and want to take the first element off and return it, I
would do it like this:

   return (@myArray) ? shift(@myArray) : undef;

How would I do similarly with a hash?  I have something like this:


   return (exists $myHash{$val1} ) ? $Hash{$val2} : undef;

But these leaves the value in the hash.  I know I can save the value first,
then DELETE it, and then return it.  But I'd like to do it all in one step.

TIA

-Jeff

__
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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



perl install on redhat 9

2003-10-10 Thread Rick Bragg
Hi,

I have installed perl 8 on redhat 9 and I installed it from source. (not 
an rpm) however, when I did a redhat up2date, the rpm's were then 
re-installed.

I think that the rpm installed perl in /usr/bin
and the source install put it in /usr/local/bin
can I safely uninstall the perl rpm's without messing up the other 
installation from source?

Thanks

Rick



--
Rick Bragg
Green Mountain Network
web:   http://www.gmnet.net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: finding a spot in a file

2003-10-10 Thread chad kellerman
John,

   Thanks that was perfect..



Chad


On Fri, 2003-10-10 at 03:11, John W. Krahn wrote:
> Chad Kellerman wrote:
> > 
> > Hello,
> 
> Hello,
> 
> >I am opening up a file (actually a my.conf).  I only want 2 lines in
> > the file.  port and datadir
> > 
> >The problem I am running into is that there is a port = 3324 in both
> > the [client] section and the [mysqld] section.
> > 
> >I want to open the file and go straight to the [mysqld] section and
> > grab the values for port and datadir.
> > 
> >Can anyone point me in the right direction?
> 
> You could use a module like
> http://search.cpan.org/author/WADG/Config-IniFiles-2.38/IniFiles.pm or
> http://search.cpan.org/author/SHERZODR/Config-Simple-4.55/Simple.pm
> 
> Or something like this may work:
> 
> $/ = '[';
> my ( $port, $datadir );
> while (  ) {
> if ( /mysqld]/ ) {
> $port= $1 if /^port\s*=\s*(\d+)/m;
> $datadir = $1 if /^datadir\s*=\s*(.+)/m;
> }
> }
> 
> 
> 
> John
> -- 
> use Perl;
> program
> fulfillment
-- 
Chad Kellerman
Systems Administration / Network Operations Manager
Alabanza Inc.
10 E Baltimore Street
Baltimore, Md 21202
Phone: 410-234-3305
Email: [EMAIL PROTECTED]



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



Re: traversing a variable with regex instead of a file

2003-10-10 Thread James Edward Gray II
Keep your replies on the list, so you can get help from all the people 
smarter than me.  ;)

On Friday, October 10, 2003, at 08:58  AM, angie ahl wrote:

Or did you mean, how would you go through a variable's content
line-by-line?  For that, try something like this:
my @lines = split /(\n)/, $data;
foreach (@lines) { do_something() if /pattern/; }
$data = join '', @lines;
Hope that helps.

James
That's exactly what I meant, sorry didn't realise the email could be 
read 2
different ways ;)
No problem.  We're on the same page now.

So split the var into an array. That makes sense. The only issue I 
will have
with that is the array will need to be remade at the end of each loop 
as the
number of line breaks will change at the the end of each process

here's what I'm actually trying to do.
# get anon hash from keywords array
for my $href ( @Keywords ) {
#get keyword from that hash
for $kw ( keys %$href ) {
# see if keyword is in content.
if ($content =~ /\b($kw)\b/g) {
# do replacement patterns on content

}
}
}
At the bit where it says # do replacement patterns on content I will 
be looking
through $content and doing a substitution

$content =~ s/($kw)/\n$1\n/;
Okay, why put this inside an if block.  If it doesn't find a match it 
will fail and do nothing, which is what you want, right?  I don't think 
you need the if.

so this will actually be adding extra newlines to the content. But I 
do need to
read it a line at a time so that I can check the lines don't start 
with the
letters qz (Don't ask... very long story ;)
Why don't we work on your Regular Expression a little and see if we can 
do it all in one move.  We want to find all occurrences of the keyword, 
as long as they're not on a line beginning with qz, right?  This seems 
to do that for me:

$content =~ s/^([^\n]*)($kw)/substr($1, 0, 2) ne 'qz' ? "$1\n$2\n" : 
"$1$2"/mge;

This searches through the $content for a line containing the keyword.  
It grabs all non-\n characters from the start of the line before the 
keyword and stores that in $1.  Then it stores the keyword in $2.  The 
/m modifier at the end makes ^ match next to \n internally and the /g 
modifier, finds all of the keywords.

I used the /e modifier for the replacement, which allows me to use Perl 
code in there.  It's pretty simple.  If the line didn't start with a 
qz, we do a normal replace.  (Add an lc(...) around that substr() call, 
if you want it to not do QZ lines too.)  If it did start with a qz, we 
replace with what we found, causing no changes.

Let me know if that will work for you.

So my fear is that I will need to recreate that array after each pass 
because
the number of newlines will be growing.

I thought that would be terribly inefficient, I'm used to using 
languages that
choke at the mere suggestion of doing work. I like Perl, it doesn't do 
that.
Your right about it being inefficient, of course.  It was easier to 
read than my Regex though, eh?The first choice may be slow, 
but on modern computers they may both work in the blink of an eye.  
Save worrying about speed for when you need to and try and keep your 
life as a programmer as easy as possible until then.

If you have any suggestions I would be most grateful to hear them.
Those are my best shots.  Hope they help.

James

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


Re: traversing a variable with regex instead of a file

2003-10-10 Thread angie ahl
>Or did you mean, how would you go through a variable's content 
>line-by-line?  For that, try something like this:
>
>my @lines = split /(\n)/, $data;
>foreach (@lines) { do_something() if /pattern/; }
>$data = join '', @lines;
>
>Hope that helps.
>
>James

That's exactly what I meant, sorry didn't realise the email could be read 2
different ways ;)

So split the var into an array. That makes sense. The only issue I will have
with that is the array will need to be remade at the end of each loop as the
number of line breaks will change at the the end of each process

here's what I'm actually trying to do.
# get anon hash from keywords array
for my $href ( @Keywords ) {

#get keyword from that hash
for $kw ( keys %$href ) {

# see if keyword is in content.
if ($content =~ /\b($kw)\b/g) {

# do replacement patterns on content
 
}
}
}

At the bit where it says # do replacement patterns on content I will be looking
through $content and doing a substitution

$content =~ s/($kw)/\n$1\n/;

so this will actually be adding extra newlines to the content. But I do need to
read it a line at a time so that I can check the lines don't start with the
letters qz (Don't ask... very long story ;)

So my fear is that I will need to recreate that array after each pass because
the number of newlines will be growing. 

I thought that would be terribly inefficient, I'm used to using languages that
choke at the mere suggestion of doing work. I like Perl, it doesn't do that.

If you have any suggestions I would be most grateful to hear them.

Thanks

Angie

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



Re: Trouble with subdir search

2003-10-10 Thread Rob Dixon
Daniel Stellwagen wrote:
>
> I found this code in the O'Reilly book "Perl for System Administration":
>
> use Cwd;
> use DirHandle;
>
> scan_dir(".");
> sub scan_dir {
> my ($workdir) = shift;
> my ($startdir) = &cwd;
> chdir ($workdir) or die "$!\n";
> opendir(DIR,".") or die "$!\n";
> my @names = readdir(DIR) or die "!\n";
> closedir(DIR);
> foreach $name (@names) {
> next if ($name eq ".");
> next if ($name eq "..");
> if (-d $name) {
> print "d\n";
> scan_dir($name);
> next;
> } else {
> print "f\n";
> print "Found file: $name\n";
> }
> chdir ($startdir) or die "$!\n";
> }
> }
>
> When I start the script from STARTDIR to scan a win 2000 dir tree with
> the following entries:
>
> STARTDIR\A_DIR\AA_DIR
>
> with files in STARTDIR, A_DIR, AA_DIR
>
> only the STARTDIR and the A_DIR are recognized as dirs but AA_DIR is
> recognizes as a file ?

I don't know the book, but I doubt if the program was published like
this, with no indentation and a bug in it. The line

  chdir ($startdir) or die "$!\n";

should be one block further out, but it would be a problem only if you
have an empty directory: I can't see that it would cause a directory
to be reported as a file. Either AA_DIR actually is a file or there's
something wrong somewhere else. Try the formatted and corrected code
below.

HTH,

Rob



use strict;
use warnings;
use Cwd;
use DirHandle;

scan_dir(".");

sub scan_dir {

  my ($workdir) = shift;
  my ($startdir) = &cwd;

  chdir ($workdir) or die "$!\n";
  opendir(DIR,".") or die "$!\n";
  my @names = readdir(DIR) or die "!\n";
  closedir(DIR);

  foreach my $name (@names) {
next if ($name eq ".");
next if ($name eq "..");
if (-d $name) {
  print "d\n";
  scan_dir($name);
} else {
  print "f\n";
  print "Found file: $name\n";
}
  }

  chdir ($startdir) or die "$!\n";
}




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



Antwort: Fwd: required help ['securiQ.Watchdog': überprüft]

2003-10-10 Thread Manfred . Beilfuss
Hi, short before my weekend just a short example attached, where I use 2
connections to the same database in a sequence, to not mix what happens on
each connection.


If you just alter the connect parms you may connect to different db's and
then submit some insert/update sql's


Hope this helps and have a nice weekend.


best regards


Manfred Beilfuss


(See attached file: grantread.pl)








   
   
James Edward Gray  
   
II   An: [EMAIL PROTECTED] 
  
<[EMAIL PROTECTED]Kopie:   

tions.net>   Thema:  Fwd: required help
   
   
   
10.10.2003 15:40   
   
   
   
   
   




[ forwarded to list by James Gray ]

Begin forwarded message:

> From: vaishali <[EMAIL PROTECTED]>
> Date: Fri Oct 10, 2003  5:06:21  AM US/Central
> To: James Edward Gray II <[EMAIL PROTECTED]>
> Subject: Re: required help
> Reply-To: [EMAIL PROTECTED]
>
> how to define multiple connect statements
>
> Actually I am having one database ie smsd and table sms_log in
> 10.100.208.254.
> I have created one database called smsd and table sms_log1 on
> 10.100.200.47 ie in another machine
>
> I want to insert data from sms_log ie 10.100.208.254 server to
> 10.100.200.47 table ie sms_log1.
>
> how to do this task using perl DBI
>
> fields from sms_log ie 10.100.208.254 are
> sender  char(40)
> receiver char(40)
> sent datetime
>
> fields from sms_log1 ie 10.100.200.47 are
> sender char(40),
> receiver char(40),
> sent datetime,
> dept char(40),
> branch char(40)


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





grantread.pl
Description: Binary data
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Fwd: required help

2003-10-10 Thread James Edward Gray II
[ forwarded to list by James Gray ]

Begin forwarded message:

From: vaishali <[EMAIL PROTECTED]>
Date: Fri Oct 10, 2003  5:06:21  AM US/Central
To: James Edward Gray II <[EMAIL PROTECTED]>
Subject: Re: required help
Reply-To: [EMAIL PROTECTED]
how to define multiple connect statements

Actually I am having one database ie smsd and table sms_log in 
10.100.208.254.
I have created one database called smsd and table sms_log1 on 
10.100.200.47 ie in another machine

I want to insert data from sms_log ie 10.100.208.254 server to 
10.100.200.47 table ie sms_log1.

how to do this task using perl DBI

fields from sms_log ie 10.100.208.254 are
sender  char(40)
receiver char(40)
sent datetime
fields from sms_log1 ie 10.100.200.47 are
sender char(40),
receiver char(40),
sent datetime,
dept char(40),
branch char(40)


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


Re: grep argument list too long...how to get around it?

2003-10-10 Thread Kevin Old
On Fri, 2003-10-10 at 02:44, Steve Grazzini wrote:
> On Thu, Oct 09, 2003 at 12:21:57PM -0400, Kevin Old wrote:
> > Are you sure about using ls?  We have directory here that has several
> > thousand files in it and when doing an ls *.whatever-extension we always
> > get an "argument list too long".
> >
> > Any idea what the actual file limit is for grep?
> 
> It's a system limit (not specific to grep) based on the size-in-bytes
> of the argument list (not the number of items).

So it's related to my ulimit open files?

Currently it's set to 1024.  Does that mean I'm limited to grepping an
argument list that is less than 1024?

Thanks,
Kevin

-- 
Kevin Old <[EMAIL PROTECTED]>


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



Re: traversing a variable with regex instead of a file

2003-10-10 Thread James Edward Gray II
On Friday, October 10, 2003, at 08:17  AM, angie ahl wrote:

while ($line = <>) {
if ($line =~ /$pattern/o) {
# do something
}
}
It's almost exactly what I want to do. I want to see if a line starts 
with a
pattern and if doesn't do something, so I would use unless instead of 
if.

However the file I want to run this on is actually in a variable not a 
file.
Normal line endings of \n.
The answer is in the question.  :)  The first line of your code sample 
reads a line from a file and stores it in the variable $line.  The 
second line in your sample, tests for a pattern in the variable $line.

Or did you mean, how would you go through a variable's content 
line-by-line?  For that, try something like this:

my @lines = split /(\n)/, $data;
foreach (@lines) { do_something() if /pattern/; }
$data = join '', @lines;
Hope that helps.

James

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


traversing a variable with regex instead of a file

2003-10-10 Thread angie ahl
Hi everyone

This is my first posting to the list, although I've been burried knee deep in
perl books for some time and have been doing web development in other languages
for some time.

I'm working with Mod_perl on Apache on Linux.

I have a simple question (I think ;)

I keep seeing pattern matches like this:

while ($line = <>) {
if ($line =~ /$pattern/o) {
# do something
}
} 

It's almost exactly what I want to do. I want to see if a line starts with a
pattern and if doesn't do something, so I would use unless instead of if.

However the file I want to run this on is actually in a variable not a file.
Normal line endings of \n.

how would I do a while on a variable?

Thanks so much, and if I can help anyone I will. I know regex fairly well.

Cheers

Angie

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



working on time

2003-10-10 Thread [EMAIL PROTECTED]
Hi,

i search hiw can i work on time.
i want to get day number and make -1

Regards,

Damien

** L'ADSL A 20 EUR/MOIS** 
Avec Tiscali, l'ADSL est à 20 EUR/mois. Vous pourrez chercher longtemps avant de 
trouver moins cher ! 
Pour profiter de cette offre exceptionnelle, cliquez ici : 
http://register.tiscali.fr/adsl/
Offre soumise à conditions.



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



Trouble with subdir search

2003-10-10 Thread Daniel Stellwagen
Hi Perl Guys,

I found this code in the O'Reilly book "Perl for System Administration":

use Cwd;
use DirHandle;

scan_dir(".");
sub scan_dir {
my ($workdir) = shift;
my ($startdir) = &cwd;
chdir ($workdir) or die "$!\n";
opendir(DIR,".") or die "$!\n";
my @names = readdir(DIR) or die "!\n";
closedir(DIR);  
foreach $name (@names) {
next if ($name eq ".");
next if ($name eq "..");
if (-d $name) {
print "d\n";
scan_dir($name);
next;   
} else {
print "f\n";
print "Found file: $name\n";
}
chdir ($startdir) or die "$!\n";
}
}

When I start the script from STARTDIR to scan a win 2000 dir tree with
the following entries:

STARTDIR\A_DIR\AA_DIR

with files in STARTDIR, A_DIR, AA_DIR 

only the STARTDIR and the A_DIR are recognized as dirs but AA_DIR is
recognizes as a file ?

What do I wrong? (Is this correct english??)



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



Re: Form creation and parsing

2003-10-10 Thread Shaun Fryer
On Thu, Oct 09, 2003 at 04:15:41PM +0200, [EMAIL PROTECTED] wrote:
> Hi, I'm quite new to Perl scripting, so any help could be really most valuable.
> I'm trying to write a Perl script which creates a Form (I know how to create a
> form with HTML or Php), and after the user has compiled the form and pressed the
> submit button, the same script should parse the input and show the user an HTML
> page with the elaboration of the input the user has inserted.
> Thanks to anyone who can help me.

For starters, if you haven't already, read `perldoc CGI`. After that, I'd
recommend two other modules which I've found myself becoming excedingly
attached to, CGI::Session and HTML::Template. They may have a slightly
steep learning curve if you're new to perl, but the time savings should
make it well worth the effort.

-- 
=
 Shaun Fryer
=
 http://sourcery.ca/
 ph: 905-529-0591
=

Science is like sex: occasionally something useful
comes out of it, but that's not why we do it.
-: Richard Feynmann


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



File::Path question

2003-10-10 Thread Chetak Sasalu M

Hi Prasad,

Try this,

use strict;
use warnings;
use File::Path;

my ($val1,$val2,$valxy);
print "enter value for val1 and val2 \n";
chomp($val1 = );
chomp($val2 = );
$valxy = "$val1$val2";
mkpath (["./$valxy"],1);
--
Cheers,
Chetak.
I am a perl newbie .So friends pls *correct* me if there is a better way
to do this or If I am downright wrong ;-)



-Original Message-
From: Prasad Karpur [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 10, 2003 2:42 AM
To: [EMAIL PROTECTED]
Subject: File::Path question


I initially set $value1, $value2 and $value3 to null values $value1 =
""; $value2 = ""; $value3 = "";

I get the values of $value1, $value2 and $value from input

$valuexyz = "$value1$value2$value3";

mkpath(["$TMPDIR/$valuexyz"], 1, 0777);

$valuexyz does not get evaluated. But if i set $value = "a1" and $value2
= 
"b1" and $value3 = "c1", then mkpath works fine. What am i doing wrong?


Thanks

Prasad

_
Instant message in style with MSN Messenger 6.0. Download it now FREE!  
http://msnmessenger-download.com


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


**Disclaimer

Information contained in this E-MAIL being proprietary to Wipro Limited is 
'privileged' and 'confidential' and intended for use only by the individual
 or entity to which it is addressed. You are notified that any use, copying 
or dissemination of the information contained in the E-MAIL in any manner 
whatsoever is strictly prohibited.

***

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



Re: finding a spot in a file

2003-10-10 Thread Rob Dixon
Chad Kellerman wrote:
>
>I am opening up a file (actually a my.conf).  I only want 2
> lines in the file.  port and datadir
>
>The problem I am running into is that there is a
> port = 3324 in both the [client] section and the [mysqld]
> section.
>
>I want to open the file and go straight to the [mysqld]
> section and grab the values for port and datadir.
>
>Can anyone point me in the right direction?

Hi Chad.

Does something like this help? It relies on both values
actually being present in the section.

Cheers,

Rob


use strict;
use warnings;

open CONF, 'my.conf' or die $!;

$_ =  until /\Q[mysqld]/;

my $port;
my $datadir;

while () {

  chomp;

  $port = $_ if /\bport\s*=/;
  $datadir = $_ if /\bdatadir\s*=/;

  last if $port and $datadir;
}



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



Re: File::Path question

2003-10-10 Thread Rob Dixon
Prasad Karpur wrote:
>
> I initially set $value1, $value2 and $value3 to null values
> $value1 = ""; $value2 = ""; $value3 = "";
>
> I get the values of $value1, $value2 and $value from input
>
> $valuexyz = "$value1$value2$value3";

I don't see how you think this will 'get the values ... from input'.
All it does is to join $value1, $value2 and $value3 together into a
single string and assign that string to $valuexyz. Since you've just
said the three strings are empty then $valuexyz will also be empty.

> mkpath(["$TMPDIR/$valuexyz"], 1, 0777);
>
> $valuexyz does not get evaluated. But if i set $value = "a1" and $value2 =
> "b1" and $value3 = "c1", then mkpath works fine. What am i doing wrong?

You need to set up your values properly. I don't know where
you want to pull the data from so I can't help further.

Cheers,

Rob



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



Re: finding a spot in a file

2003-10-10 Thread Tore Aursand
On Thu, 09 Oct 2003 21:12:38 -0400, chad kellerman wrote:
> Can anyone point me in the right direction?

Seems like you're trying to read a configuration file.  There are modules
to do that work for you.  Check out CPAN.


-- 
Tore Aursand <[EMAIL PROTECTED]>


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



RE: grep argument list too long...how to get around it?

2003-10-10 Thread Egleton, Gary
What version of unix are you using?

It was fixed in a patch on HPUX

> -Original Message-
> From: Kevin Old [SMTP:[EMAIL PROTECTED]
> Sent: 09 October 2003 17:22
> To:   Dan Muey
> Cc:   [EMAIL PROTECTED]
> Subject:  RE: grep argument list too long...how to get around it?
> 
> On Thu, 2003-10-09 at 12:13, Dan Muey wrote:
> > > Hello everyone,
> > 
> > Howdy
> > 
> > > 
> > > We use the Barracuda Spam appliance (barracudanetworks.com) 
> > > to filter our spam and their web based interface is written 
> > > in Perl.  They have a form that allows the user to search 
> > > messages for key words.  Evidentally it stores the each 
> > > message in a file in a directory and when trying to search 
> > > several hundred thousand messages for a word the response back
> > > is:
> > > 
> > > egrep: argument list too long
> > > 
> > 
> > If I was trying to grep a zillion files at once and it wouldn't 
> > let me I'd probably grep them one at a time.
> > For instance via the backtivck execution You might have:
> > 
> > my @matchedfiles = qx(cat `ls /files/` |grep $string);
> > # a really bad way to do this but for example's sake...
> > 
> > You could do:
> > 
> > for(`ls /files/`) {
> > if(`cat $_ |grep $string`) { push(@matchedfiles,$_); }
> > }
> 
> Are you sure about using ls?  We have directory here that has several
> thousand files in it and when doing an ls *.whatever-extension we always
> get an "argument list too long".
> 
> Any idea what the actual file limit is for grep?
> 
> > 
> > Then you are only greping one file at a time instead of a list of too
> many.
> > Of course what would be better is to use the readdir() functions to list
> the files 
> > and open() and grep() combo to grep the contents. But the same principle
> applies.
> > 
> > Just make sure the barracuda folks says thanks for fixing their problem
> :)
> 
> Yeah, we're hoping for a few months of service for free.:)
> 
> This was also a personal quest to find the answer for myself.  So either
> way I win.
> 
> Thanks for your help,
> Kevin
> -- 
> Kevin Old <[EMAIL PROTECTED]>
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]



The information contained in or attached to this email is
intended only for the use of the individual or entity to
which it is addressed. If you are not the intended
recipient, or a person responsible for delivering it to the
intended recipient, you are not authorised to and must not
disclose, copy, distribute, or retain this message or any
part of it. It may contain information which is confidential
and/or covered by legal professional or other privilege (or
other rules or laws with similar effect in jurisdictions
outside England and Wales).
The views expressed in this email are not necessarily the
views of Centrica plc, and the company, its directors,
officers or employees make no representation or accept any
liability for its accuracy or completeness unless expressly
stated to the contrary.


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



Re: regex require a period

2003-10-10 Thread Steve Grazzini
On Fri, Oct 10, 2003 at 12:49:51AM -0700, [EMAIL PROTECTED] wrote:
> I couldn't get it to work.

Whoops -->

  sub validate {
local $_ = shift;
return( length == 4 and
tr/.// == 1 and
/^[[:alpha:]]/ )
  }

-- 
Steve

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



Re: regex require a period

2003-10-10 Thread perl
I couldn't get it to work. Will the sub run as is? Is the :alpha: suppose
to be there or replace it?


> On Thu, Oct 09, 2003 at 11:58:31PM -0700, [EMAIL PROTECTED] wrote:
>> here's the rules:
>> starts with alphanumeric
>> 4 chars long
>> require one period
>>
>> /^[a-zA-Z][\w\-\.]{3,}$/
>
> I wouldn't try to do it with one regex.  You can probably come
> up with one, but the next time you have to read this code, you'll
> wish you'd spelled out the three conditions individually.
>
>   sub validate {
> local $_ = shift;
> return length == 4  # 4 chars long
>and tr/.// == 1  # require one period
>and /^[[:alpha:]]/   # starts with a letter
>   }
>
> --
> Steve
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-
eMail solutions by 
http://www.swanmail.com

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



Re: regex require a period

2003-10-10 Thread perl
> /^[a-zA-Z][\w\-\.]{3,}$/ && /\./

Matches more than 1 period. I MUST have 1 and ONLY 1 period. Also, can I
fit it on one line? I couldn't doit.

sub isValidDomain
{ return shift =~ /^[a-zA-Z0-9][\w\-\.]{3,}$/ }


---
> How about something like:
>
> /^[a-zA-Z][\w\-\.]{3,}$/ && /\./
>
> On Fri, 2003-10-10 at 16:58, [EMAIL PROTECTED] wrote:
>> here's the rules:
>> starts with alphanumeric
>> 4 chars long
>> require one period
>>
>> /^[a-zA-Z][\w\-\.]{3,}$/
>>
>> I think my regex is not doing the required period.
>>
>> thanks,
>> -rkl
>>
>>
>> -
>> eMail solutions by
>> http://www.swanmail.com
>
>



-
eMail solutions by 
http://www.swanmail.com

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



Re: regex require a period

2003-10-10 Thread Steve Grazzini
On Thu, Oct 09, 2003 at 11:58:31PM -0700, [EMAIL PROTECTED] wrote:
> here's the rules:
> starts with alphanumeric
> 4 chars long
> require one period
> 
> /^[a-zA-Z][\w\-\.]{3,}$/

I wouldn't try to do it with one regex.  You can probably come
up with one, but the next time you have to read this code, you'll
wish you'd spelled out the three conditions individually.

  sub validate {
local $_ = shift;
return length == 4  # 4 chars long
   and tr/.// == 1  # require one period
   and /^[[:alpha:]]/   # starts with a letter
  }

-- 
Steve

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



Re: regex require a period

2003-10-10 Thread simran
How about something like:

/^[a-zA-Z][\w\-\.]{3,}$/ && /\./

On Fri, 2003-10-10 at 16:58, [EMAIL PROTECTED] wrote:
> here's the rules:
> starts with alphanumeric
> 4 chars long
> require one period
> 
> /^[a-zA-Z][\w\-\.]{3,}$/
> 
> I think my regex is not doing the required period.
> 
> thanks,
> -rkl
> 
> 
> -
> eMail solutions by 
> http://www.swanmail.com


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



Re: finding a spot in a file

2003-10-10 Thread John W. Krahn
Chad Kellerman wrote:
> 
> Hello,

Hello,

>I am opening up a file (actually a my.conf).  I only want 2 lines in
> the file.  port and datadir
> 
>The problem I am running into is that there is a port = 3324 in both
> the [client] section and the [mysqld] section.
> 
>I want to open the file and go straight to the [mysqld] section and
> grab the values for port and datadir.
> 
>Can anyone point me in the right direction?

You could use a module like
http://search.cpan.org/author/WADG/Config-IniFiles-2.38/IniFiles.pm or
http://search.cpan.org/author/SHERZODR/Config-Simple-4.55/Simple.pm

Or something like this may work:

$/ = '[';
my ( $port, $datadir );
while (  ) {
if ( /mysqld]/ ) {
$port= $1 if /^port\s*=\s*(\d+)/m;
$datadir = $1 if /^datadir\s*=\s*(.+)/m;
}
}



John
-- 
use Perl;
program
fulfillment

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



Re: grep argument list too long...how to get around it?

2003-10-10 Thread Steve Grazzini
On Thu, Oct 09, 2003 at 12:21:57PM -0400, Kevin Old wrote:
> Are you sure about using ls?  We have directory here that has several
> thousand files in it and when doing an ls *.whatever-extension we always
> get an "argument list too long".
>
> Any idea what the actual file limit is for grep?

It's a system limit (not specific to grep) based on the size-in-bytes
of the argument list (not the number of items).

-- 
Steve

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