Regular expression question...

2006-02-11 Thread Ley, Chung
Hi,

What is the regular expression to look for "%" unless that the "\" is right 
before that?

So, if I have something like this:
"\%abc%", I like to get the 2nd "%" and not the first

Thanks...

--Chung








Re: pseudohash

2006-02-11 Thread James Marks


On Feb 11, 2006, at 12:16 PM, Owen wrote:


James Marks wrote:

On Feb 11, 2006, at 12:04 AM, Owen Cook wrote:


Maybe have a read of perlref, try 
http://perldoc.perl.org/perlref.html



To my amusement, when I followed your suggestion, I got:

-- Perl 5.8.6 documentation --
Home > Search results
Search results

No matches found for your query "pseudohash"

:)



Well this is what I get? See Item 5 under description



-- Perl 5.8.8 documentation --
Home > Language reference > perlref
perlref


Oh. Duh. I missed the word on the page your link produces and went 
straight to the search field which, it turns out, fails to find the 
word. (And, after all that, I wasn't really interested in pseudohashes. 
I just followed the link out of curiousity. It's your turn to be 
amused...)


:)


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




Re: pseudohash

2006-02-11 Thread Sky Blueshoes

Alan wrote:


On Saturday 11 February 2006 10:10, James Marks wrote:
 


On Feb 11, 2006, at 12:04 AM, Owen Cook wrote:
   


On Sat, 11 Feb 2006, Beast wrote:
 


Could someone explain what is pseudohash means?
   


Maybe have a read of perlref, try http://perldoc.perl.org/perlref.html
Owen
 


To my amusement, when I followed your suggestion, I got:

-- Perl 5.8.6 documentation --
Home > Search results
Search results

No matches found for your query "pseudohash"
   



http://www.google.com/search?q=site%3Aperldoc.perl.org+pseudohash&start=0&ie=utf-8&oe=utf-8&client=firefox-a&rls=org.mozilla:en-US:official

Google turned up some hits though I not have time to peruse any of the hits.

 

A pseudo-hash is an array where the first element contains a hash, in 
essence hashing the array:

ex:  @struct = [{foo => 1, bar => 2}, "FOO", "BAR"];

   $struct->{foo};  # same as $struct->[1], i.e. "FOO"
   $struct->{bar};  # same as $struct->[2], i.e. "BAR"

read your perldocs! ;)




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




Re: pseudohash

2006-02-11 Thread Alan
On Saturday 11 February 2006 10:10, James Marks wrote:
> On Feb 11, 2006, at 12:04 AM, Owen Cook wrote:
> > On Sat, 11 Feb 2006, Beast wrote:
> >> Could someone explain what is pseudohash means?
> >
> > Maybe have a read of perlref, try http://perldoc.perl.org/perlref.html
> > Owen
>
> To my amusement, when I followed your suggestion, I got:
>
> -- Perl 5.8.6 documentation --
> Home > Search results
> Search results
>
> No matches found for your query "pseudohash"

http://www.google.com/search?q=site%3Aperldoc.perl.org+pseudohash&start=0&ie=utf-8&oe=utf-8&client=firefox-a&rls=org.mozilla:en-US:official

Google turned up some hits though I not have time to peruse any of the hits.

-- 
Alan.

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




Re: Suggest a mod_perl book for apache2

2006-02-11 Thread Todd W

"Brian" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi all. Can someone suggest a good book for learning mod_perl with
> apache2. After a little reading I get the impression the two
> implementations of mod_perl are very different. In searching amazon
> it seems just about every book is written for mod_perl on apache1.3.
>
> Thanks,
> Brian

As far as differences, yes the API could probably be described as radically
different in some ways.

Allison R. and Stas B. are probably working on the book at this moment.

It should be out very soon now:

http://www.gossamer-threads.com/lists/modperl/modperl/86016?search_string=book;#86016

Also, I'm sure you are aware but in my opinion http://perl.apache.org/ is
one of the best documentation systems I've ever used.

trwww.



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




Re: Checking a list for a value

2006-02-11 Thread John W. Krahn
David Gilden wrote:
> I would like to loop through 'all' acceptable values in an array (my white 
> list)
> then assign a pass or fail value.
> 
> In the following code does not accomplish this, it needs to go through the 
> entire list 
> before assigning a value.
> 
> 
> #!/usr/bin/perl 
> 
> $valToTest = "ac";
> 
> @myGoodList = ("10_rater","36_600","ac","cr914","ec12","fairwind");
> $testOk = -1;
> 
> foreach my $cat  (@myGoodList){
> if ($cat =~ /$valToTest/) {
> $testOk = 1; 
> next;
> } else {
> $testOk = -1;
> # value not in list
> last;
> }
> }
> 
> print "$testOk\n";
> 
> 
> I am going to guess that the foreach is not the right way to address this 
> problem.
> 
> Thanks for any insight into this problem,

Your logic says to exit the loop on the first array element that DOES NOT
contain the string in $valToTest.  You probably want:

my $testOk = -1;

foreach my $cat ( @myGoodList ) {
if ( $cat =~ /$valToTest/ ) {
$testOk = 1;
last;
}
}


However, if you don't mind looping through ALL the elements of the array you
could do it like this:

my $testOk = grep( /$valToTest/, @myGoodList ) ? 1 : -1;

Although the foreach loop is more efficient as it exits the loop when a match
is found.


If you are looking for an exact match then you should use 'eq' instead of the
match operator:

if ( $cat eq $valToTest ) {



John
-- 
use Perl;
program
fulfillment

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




Re: Checking a list for a value

2006-02-11 Thread John Doe
David Gilden am Samstag, 11. Februar 2006 21.54:
> I would like to loop through 'all' acceptable values in an array (my white
> list) then assign a pass or fail value.
>
> In the following code does not accomplish this, it needs to go through the
> entire list before assigning a value.
>
>
> #!/usr/bin/perl
>
> $valToTest = "ac";
>
> @myGoodList = ("10_rater","36_600","ac","cr914","ec12","fairwind");
> $testOk = -1;
>
> foreach my $cat  (@myGoodList){
> if ($cat =~ /$valToTest/) {
> $testOk = 1;
> next;
> } else {
> $testOk = -1;
> # value not in list
> last;
> }
> }
>
> print "$testOk\n";
>
>
> I am going to guess that the foreach is not the right way to address this
> problem.

I think your quess is ok - IF you test for equalty, not matching.

Just use a hash; then you don't have to inspect every value, but can just test 
for existence. Something like

#!/usr/bin/perl
use strict;   # don't forget
use warnings; # those two

my $testval='ac'; # no need for double quotes

my %good=map {$_=>1}
 qw/10_rater 36_600 ac cr914 ec12 fairwind/;

my $ok=exists $good{$testval} ? 1 : 0;
# or simply: my $ok=exists $good{$testval}

print 'Test result: ', $ok;


hth,
joe

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




Re: text file to xml to database

2006-02-11 Thread John Doe
I BioKid am Samstag, 11. Februar 2006 20.39:
> Dear All,

Hi again

> We have a text based database, now we want to implement web services for
> the for people around the world for a programmatic access to our  server.

This is a quite general task. I think the people on this perl list would help 
for the perlish part(s) of the task, provided adequate infos.

> Our databse at the moment is not technically a database - 
> its only a server which retreive server 

Never heard about servers retrieving servers.

You expect people to take their time to provide help for you.
So *please* take a sufficient amount of time to at least reread what you 
wrote.

> and present it on browser according to query say id no like 6523  or name 
> like foo etc. 

This gives a hint that you reference the resources by id and/or name.
But it's still unclear how your current text data is organised.

Generally, perl is great in taking textual input and reorganise/modify it.

> First we want to transfer this data to xml 
> then we need to put it in a database,

Why XML? Just as an intermediate format, or do you intend to use it also, 
besides the data hold in the database? Or do you want to store xml in the 
database?

> Regarding XML - i dont have much idea
> -  we are planning for a PGSQL db 

[snip]

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




Checking a list for a value

2006-02-11 Thread David Gilden
I would like to loop through 'all' acceptable values in an array (my white list)
then assign a pass or fail value.

In the following code does not accomplish this, it needs to go through the 
entire list 
before assigning a value.


#!/usr/bin/perl 

$valToTest = "ac";

@myGoodList = ("10_rater","36_600","ac","cr914","ec12","fairwind");
$testOk = -1;

foreach my $cat  (@myGoodList){
if ($cat =~ /$valToTest/) {
$testOk = 1; 
next;
} else {
$testOk = -1;
# value not in list
last;
}
}

print "$testOk\n";


I am going to guess that the foreach is not the right way to address this 
problem.

Thanks for any insight into this problem,

Dave Gilden

(kora musician / audiophile / webmaster @ www.coraconnection.com  / Ft. Worth, 
TX, USA)

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




Re: pseudohash

2006-02-11 Thread Tom Phoenix
On 2/10/06, Beast <[EMAIL PROTECTED]> wrote:
>
> Could someone explain what is pseudohash means?

A "pseudohash", much like "the macarena", "N-rays", "Herbalife",
"Paris Hilton", "New Coke", and "Intelligent Design", is an idea that
sounded good at the time. It's obsolete; it's deprecated. It may cause
drowsiness, dry mouth, and frequent urination. Avoid, avoid, avoid.

But if you have to maintain some old code that uses it, the perlref
manpage explains it pretty well. Beyond that, did you have any
questions?

Cheers!

--Tom Phoenix
Stonehenge Perl Training

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




Re: pseudohash

2006-02-11 Thread Owen
James Marks wrote:
> On Feb 11, 2006, at 12:04 AM, Owen Cook wrote:

>> Maybe have a read of perlref, try http://perldoc.perl.org/perlref.html

> To my amusement, when I followed your suggestion, I got:
> 
> -- Perl 5.8.6 documentation --
> Home > Search results
> Search results
> 
> No matches found for your query "pseudohash"
> 
> :)


Well this is what I get? See Item 5 under description



-- Perl 5.8.8 documentation --
Home > Language reference > perlref
perlref
* NAME reference pointer data structure structure struct
* NOTE
* DESCRIPTION
  o Making References reference, creation referencing
  o Using References reference, use dereferencing dereference
  o Symbolic references reference, symbolic reference, soft symbolic
reference soft reference
  o Not-so-symbolic references
  o Pseudo-hashes: Using an array as a hash pseudo-hash pseudo hash
pseudohash
  o Function Templates scope, lexical closure lexical lexical scope
subroutine, nested sub, nested subroutine, local sub, local
* WARNING reference, string context reference, use as hash key
* SEE ALSO

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




Re: text file to xml to database

2006-02-11 Thread I BioKid
Dear All,
We have a text based database, now we want to implement web services for the
for people around the world for a programmatic access to our  server. Our
databse at the moment is not technically a database - its only a server
which retreive server and present it on browser according to query say id
no like 6523  or name like foo etc.

First we want to transfer this data to xml then we need to put it in a
database ,
Regarding XML - i dont have much idea -  we are planning for a PGSQL db


Hope you guys care to advice :)

S K
On 2/11/06, John Doe <[EMAIL PROTECTED]> wrote:
>
> I BioKid am Samstag, 11. Februar 2006 17.47:
> > hi all,
>
> Hi
>
> There are reasons why you didn't get answers you like.
>
> > I need technical advice from all perlbuddies,
>
> There are quite a lot of perlbuddies...
>
> > I have 2 text files and I want to convert it to XML and then to a
> > database. It will be really helpfull, if you could give me a proper
> > technical descritption to do it using PERL.like which module should i
> use,
> > how to parse my text file to xml and how to store xml in PG /MySQL db
>
> I think anybody who tries to answer needs as a prerequisite a
> *proper problem description* (e.g. what text structure; what xml
> structure;
> why via xml; what db layout; intended usage...)
> from you first, and prefers to see what you already tried and what went
> wrong.
>
> See also:
> search.cpan.org for perl modules
> dev.mysql.com for a description of mySQL
>
> hth,
> joe
>
> [snip]
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
>
>
>


Re: text file to xml to database

2006-02-11 Thread John Doe
I BioKid am Samstag, 11. Februar 2006 17.47:
> hi all,

Hi

There are reasons why you didn't get answers you like.

> I need technical advice from all perlbuddies,

There are quite a lot of perlbuddies...

> I have 2 text files and I want to convert it to XML and then to a
> database. It will be really helpfull, if you could give me a proper
> technical descritption to do it using PERL.like which module should i use,
> how to parse my text file to xml and how to store xml in PG /MySQL db

I think anybody who tries to answer needs as a prerequisite a 
*proper problem description* (e.g. what text structure; what xml structure; 
why via xml; what db layout; intended usage...)
from you first, and prefers to see what you already tried and what went wrong.

See also:
search.cpan.org for perl modules
dev.mysql.com for a description of mySQL

hth,
joe

[snip]


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




Re: pseudohash

2006-02-11 Thread James Marks

On Feb 11, 2006, at 12:04 AM, Owen Cook wrote:


On Sat, 11 Feb 2006, Beast wrote:



Could someone explain what is pseudohash means?


Maybe have a read of perlref, try http://perldoc.perl.org/perlref.html



Owen



To my amusement, when I followed your suggestion, I got:

-- Perl 5.8.6 documentation --
Home > Search results
Search results

No matches found for your query "pseudohash"

:)

James

Suggest a mod_perl book for apache2

2006-02-11 Thread Brian
Hi all. Can someone suggest a good book for learning mod_perl with  
apache2. After a little reading I get the impression the two  
implementations of mod_perl are very different. In searching amazon  
it seems just about every book is written for mod_perl on apache1.3.


Thanks,
Brian

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




text file to xml to database

2006-02-11 Thread I BioKid
hi all,
I need technical advice from all perlbuddies,

I have 2 text files and I want to convert it to XML and then to a
database. It will be really helpfull, if you could give me a proper
technical descritption to do it using PERL.like which module should i use,
how to parse my text file to xml and how to store xml in PG /MySQL db -

thank and cheers! inadvance !!!


happy perl,
S K


Re: text files to xml database

2006-02-11 Thread Chris Devers
On Sat, 11 Feb 2006, I BioKid wrote:

> I need technical advice from all perlbuddies,
> 
> I have 2 text files and I want to convert it to XML and then to a 
> database. I need a proper technical descritption to do it using PERL. 
> I need details like which db should i use also.

Good luck with that! 

Let us know if you turn up any good leads.


-- 
Chris Devers

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




text files to xml database

2006-02-11 Thread I BioKid
hi all,
I need technical advice from all perlbuddies,

I have 2 text files and I want to convert it to XML and then to a
database. I need a proper technical descritption to do it using PERL.
I need details like which db should i use also.

S K

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




Re: searching question

2006-02-11 Thread Wijnand Wiersma
On 2/11/06, Xavier Noria <[EMAIL PROTECTED]> wrote:

> I don't completely understand the problem, but curiously there was a
> similar question from someone else yesterday in the SQLite mailing-
> list. Is this homework?

No, this is not homework. I left school 5 years ago.
And no, this not a database specific question.

--
No virus was found in this outgoing message as I didn't bother looking.
This is not an automated signature. I type this in to the bottom of every
message.

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




Re: searching question

2006-02-11 Thread Xavier Noria

On Feb 11, 2006, at 5:01, Wijnand Wiersma wrote:


I want to search in a database for values belonging to a key.
The key can be one word, or several words.
I get the key in a string, but it is not needed that the whole string
is the key.
You may ask: "what is the perl language?"
The key may be "the perl language"
The most right word in the string is most important.
When I have a key called "language" for example I should get that.
I already chopped off the question mark.


I don't completely understand the problem, but curiously there was a  
similar question from someone else yesterday in the SQLite mailing- 
list. Is this homework?


-- fxn


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




Re: Stuck on last step

2006-02-11 Thread Omega -1911
Proper structure:

if ($...) {} # UNLESS NOT TO BE USED HERE
elsif {}
else {}

JMPO... (Just My Perl Opinion)

On 2/11/06, Ron Smith <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
>   I've got a CGI script that takes two strings and sorts them in order,
> then prints them. The problem is I don't want nulls or numbers entered. I
> think I've got the "null" end of it right, but I'd also like to error-out
> any numbers entered. Take a look at the "unless" line.
>
>   ...any suggestions??
>
>   #!E:/www/perl/bin/perl.exe
>   use strict;
> use warnings;
> use CGI qw( :standard );
> use CGI::Carp qw( fatalsToBrowser );
>
>   print header();
>
>   my $firstString = param( "textfield" );
> my $secondString = param( "textfield2" );
>
>   my @list = sort ( $firstString, $secondString );
>
>   unless ( $firstString && $secondString && /\w+/ ) {
> print< 
> 
>  This page takes two strings from the user and prints them in
> alphabetical order. If they are equal, they will print on separate lines.
> 
>  action="../webroot/cgi-bin/pg59ex2.11SortStrings.pl">
>   
> 
>   Enter your first string:
> 
>   
> 
> 
>   Enter your second string: 
>   
> 
> 
>Please, enter
> two words! 
> 
> 
>href="/pg59ex2.11SortStrings.html"> Click here to go back 
> 
>   
> 
> 
> 
> 
> HTML
> }
>   elsif ( $firstString eq $secondString ) {
> print< 
> 
> This page takes two strings from the user and prints them in
> alphabetical order. If they are equal, they will print on separate
> lines.
>  action="../webroot/cgi-bin/pg59ex2.11SortStrings.pl">
>   
> 
>   Enter your first string:
> 
>   
> 
> 
>   Enter your second string: 
>   
> 
> 
>$firstString$secondString
> 
> 
> 
>href="/pg59ex2.11SortStrings.html"> Click here to go back 
> 
>   
> 
> 
> 
> 
> HTML
> }
>   else {
> print< 
> 
> This page takes two strings from the user and prints them in
> alphabetical order. If they are equal, they will print on separate
> lines.
> 
>   
> 
>   Enter your first string:
> 
>   
> 
> 
>   Enter your second string: 
>   
> 
> 
>@list 
> 
> 
> href="/pg59ex2.11SortStrings.html"> Click here to go back 
> 
>   
> 
> 
> 
> 
> HTML
> }
>
>
> Ron Smith
> [EMAIL PROTECTED]
>


Stuck on last step

2006-02-11 Thread Ron Smith
Hi all,
   
  I've got a CGI script that takes two strings and sorts them in order, then 
prints them. The problem is I don't want nulls or numbers entered. I think I've 
got the "null" end of it right, but I'd also like to error-out any numbers 
entered. Take a look at the "unless" line.
   
  ...any suggestions??
   
  #!E:/www/perl/bin/perl.exe
  use strict;
use warnings;
use CGI qw( :standard );
use CGI::Carp qw( fatalsToBrowser );
   
  print header();
   
  my $firstString = param( "textfield" );
my $secondString = param( "textfield2" );
   
  my @list = sort ( $firstString, $secondString );
   
  unless ( $firstString && $secondString && /\w+/ ) {
print<

 This page takes two strings from the user and prints them in alphabetical 
order. If they are equal, they will print on separate lines. 

  

  Enter your first string: 
  


  Enter your second string: 
  


   Please, enter two 
words! 


   Click here to go back 

  

 


HTML
}
  elsif ( $firstString eq $secondString ) {
print<

This page takes two strings from the user and prints them in alphabetical 
order. If they are equal, they will print on separate lines.

  

  Enter your first string: 
  


  Enter your second string: 
  


   $firstString$secondString 



   Click here to go back 

  

 


HTML
}
  else {
print<

This page takes two strings from the user and prints them in alphabetical 
order. If they are equal, they will print on separate lines.

  

  Enter your first string: 
  


  Enter your second string: 
  


   @list 



Click here to go back 

  

 


HTML
}


Ron Smith
[EMAIL PROTECTED]

Re: pseudohash

2006-02-11 Thread Owen Cook

On Sat, 11 Feb 2006, Beast wrote:

> 
> Could someone explain what is pseudohash means?

Maybe have a read of perlref, try http://perldoc.perl.org/perlref.html



Owen


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