case insensitive index() ?

2003-07-08 Thread =James Birkholz=
Is there a way to do an index function that is case-insensitive?

For example:

sub stripTag {
my $startTag = $_[0];
my $endTag = $_[1];
while (index($content, $startTag)0) {
my $first = substr($content, 0, index($content, $startTag) );
my $last = substr($content, (index($content, $endTag)+length($endTag) 
) );
$content = $first.$last;
}
}
stripTag(font,);
stripTag(FONT,);
this code has to be called with each case variant, or I'd have to put a lot 
of IFs inside the SUB

James

ps, tips on improving the above coding welcome, I'm just starting to come 
to grips with Perl. I know there are modules that include similar 
functions, but I'm doing this as a learning exercise.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: case insensitive index() ?

2003-07-08 Thread =James Birkholz=
Thanks, Joseph, I'll chew on this tonight. I didn't start by trying a 
regex, as $content still has many \n in it, but in researching your use 
of the \Q (which isn't in my tutorial book), I ran across the s 
modifier. Or I could change all the \n to placeholders and then change 
them back later. Guess tonight I hit the perl doc on regex.

I presume that the \Q is needed to process the variables? I didn't think 
that was needed.
I'm confused about the ? after the  *  .

$content =~ s/\Q$startTag.*?$endTag//i; # untested!
At 10:35 AM 7/8/03, Joseph Discenza wrote:
=James Birkholz= wrote, on Tuesday, July 08, 2003 9:54 AM
:  Is there a way to do an index function that is case-insensitive?
sub stripTagCaseInsensitive {
my $startTag = lc($_[0]);
my $endTag = lc($_[1]);
my $contentCI = lc($content);
while (index($contentCI, $startTag)0) {
my $first = substr($content, 0, index($contentCI, 
$startTag));
my $last = substr($content, (index($contentCI, 
$endTag)+length($endTag)));
$content = $first.$last;
$contentCI = lc($content);
}
}

stripTagCaseInsensitive(FoNt,);

But wouldn't it be easier to use a regex?

$content =~ s/\Q$startTag.*?$endTag//i; # untested!

Good luck,

Joe

==
  Joseph P. Discenza, Sr. Programmer/Analyst
   mailto:[EMAIL PROTECTED]
  Carleton Inc.   http://www.carletoninc.com
  574.243.6040 ext. 300fax: 574.243.6060
Providing Financial Solutions and Compliance for over 30 Years
* Please note that our Area Code has changed to 574! *


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
James Birkholz
admin, Posen-L mailing list and website
http://www.Posen-L.com
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Newby syntax help request

2003-06-28 Thread =James Birkholz=
Thanks to Rob for helping me get the correct version of  HTML::Parser past 
the gates of PPM so I could run HTML::TableExtract.


Now I can successfully extract table data on web pages, but am having 
trouble parsing some text for my web-crawler, since this is my first Perl 
code. I've banged my head for an hour, so I'm gonna take a walk and hope 
someone can point out what is probably wrong cuz I don't know anything yet.

I'm pretty sure my problem is with the line flagged 
by  #=
I'm trying to parse out the Showing rows x to y of z line from the web 
page content. It appears that I'm not able to correctly assign the text 
from the web page to the $_, because if I manually assign the text 
with   $_ = Showing 1-15 of 70;
then everthing works. I'm confused though, because if I print 
the@$row, it prints fine.

===
$te2-parse($content);
 foreach $ts ($te2-table_states) {
#   print theOutFile Table (, join(',', $ts-coords), ):\n;
   foreach $row ($ts-rows) {
  print theOutFile StartRow, @$row, EndRow, \n;
#	  $_ = Showing 1-15 of 70;
	  $_ = 
@$row; 
#=
	  @theRecs = m/All/;
  print theOutFile TotalElements = , $#theRecs, \n;
  print theOutFile StartRec = , $theRecs[0], \n;
  print theOutFile EndRec = , $theRecs[1], \n;
  print theOutFile TotalRecs = , $theRecs[2], \n;

   }
}
===
TIA,
James
ps (Sorry if this isn't the most correct list, I'll look into subbing to a 
different list later today.)

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs