Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 938455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:38:51+00:00 2026-05-15T21:38:51+00:00

I am modifying some HTML pages and want to increase the font size dynamically

  • 0

I am modifying some HTML pages and want to increase the font size dynamically with a regex. In my script below, I want the ‘8’ and ‘3’ to turn into ‘9’ and ‘4’ but I get ‘8++’ and ‘3++’, respectively. I have the following:

#!/usr/bin/perl
use warnings;
use LWP::Simple;

my $content = "<TD><FONT STYLE=\"font-family:Verdana, Geneva, sans-serif\" SIZE=\"8\">this is just a bunch of text</FONT></TD>";
$content .= "<TD><FONT STYLE=\"font-family:Verdana, Geneva, sans-serif\" SIZE=\"3\">more text</FONT></TD>";

$content=~s/SIZE="(\d+)">/SIZE="$1++">/g;

print $content;     
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T21:38:51+00:00Added an answer on May 15, 2026 at 9:38 pm

    I’ll just skip the part about how regexps are a bad way to parse HTML, because sometimes a quick-and-dirty solution is good enough.

    You can’t use an operator inside a string like that. The ++ is just treated as plain text (as you found). You have to use the /e flag to indicate that the replacement should be evaluated as Perl code, and then use the appropriate expression, like:

    $content =~ s/SIZE="(\d+)">/'SIZE="' . ($1 + 1) . '">'/eg;
    

    You can’t use $1++ for two reasons. First, it would do the increment after returning the value, so you’d be replacing 8 with 8 instead of 9. Second, $1 is a read-only value, and the increment would want to modify it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am modifying a Nant build script to run some unit tests. I have
I'm constantly modifying some text on a web page with JavaScript. I want the
As part of our branding of Sharepoint 2010, we'll be modifying some custom HTML
I'm using the following to grab some updated HTML and insert it into a
I am modifying some code and came across a declaration that I am having
I'm working on modifying some existing code for a payment gateway and I'm not
I'm modifying some code that calls enumerate on a list declared via a list
I've been modifying some code to work between Mac OS X and iPhone OS.
I was trying to rebuild my kernel after modifying some source files and noticed
I need some help modifying the Webform Module so that it can work for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.