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 6673551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:38:25+00:00 2026-05-26T03:38:25+00:00

Consider the following string String = this is for test. i’m new to perl!

  • 0

Consider the following string

String = “this is for test. i’m new to perl! Please help. can u help? i hope so.”

In the above string after . or ? or ! the next character should be in upper case. how can I do that?

I’m reading from text file line by line and I need to write modified data to another file.

your help will be greatly appreciated.

  • 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-26T03:38:26+00:00Added an answer on May 26, 2026 at 3:38 am

    you could use a regular expression
    try this:

    my $s = "...";
    $s =~ s/([\.\?!]\s*[a-z])/uc($1)/ge; # of course $1 , thanks to plusplus
    

    the g-flag searches for all matches and the e-flag executes uc to convert the letter to uppercase

    Explanation:

    • with [.\?!] you search for your punctuation marks
    • \s* is for whitespaces between the marks and the first letter of your next word and
    • [a-z] matches on a single letter (in this case the first one of the next word

    the regular expression mentioned above searches with these patterns for every appearance of a punctuation mark followed by (optional) whitespaces and a letter and replaces it with the result of uc (which converts the match to uppercase).

    For example:

    my $s = "this is for test. i'm new to perl! Please help. can u help? i hope so.";
    $s =~ s/([\.\?!]\s*[a-z])/uc(&1)/ge;
    print $s;
    

    will find “. i”, “! P”, “. c” and “? i” and replaces then, so the printed result is:

    this is for test. I'm new to perl! Please help. Can u help? I hope so.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following line: readonly private string TARGET_BTN_IMG_URL = @\\ad1-sunglim\Test\; In this line, why
consider the following example: public IEnumerable<String> Test () { IEnumerable<String> lexicalStrings = new List<String>
Please consider the following test program (using scala 2.9.0.1) object test { def main(args:Array[String])
Consider the following code snippet private void ProcessFile(string fullPath) { XmlTextReader rdr = new
Consider this code: class test { public static void main(String[] args) { test inst_test
Consider the following code: static void Main(string[] args) { using (MemoryStream memoryStream = new
Consider the following TSQL: declare @xml xml select @xml = '<test xmlns=http://this-is-the-default-namespace-uri>some data</test>' select
Consider the following example. String str = new String(); str = "Hello"; System.out.println(str); //Prints
Let's consider this simple test program: #include <stdio.h> #include <string.h> int main(int argc, char
Consider following program: static void Main (string[] args) { int i; uint ui; i

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.