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

  • Home
  • SEARCH
  • 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 6009361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:57:35+00:00 2026-05-23T01:57:35+00:00

I’m some trouble finding the problem with my program. Getting the error: Use of

  • 0

I’m some trouble finding the problem with my program. Getting the error:

Use of uninitialized value in substitution (s///)

I realize this has been asked before, but that didn’t help me. I realize $1 might be unitialized, but I was wondering if you guys could help me figure out why?

Here’s the problem part of the code:

$one_match_ref->{'sentence'} = $1 if ($line =~ /^Parsing \[sent. \d+ len. \d+\]: \[(.+)\]/);
$one_match_ref->{'sentence'} =~ s/, / /g;

EDIT: I have declared the $one_match_ref->{'sentence'} like so:

my $sentence;
$one_match_ref = {
        chapternumber => $chapternumber_value,
        sentencenumber => $sentencenumber_value,
        sentence => $sentence, ##Get from parsed text: remove commas
        grammar_relation => $grammar_relation_value, ##Get from parsed text: split?
        arg1 => $argument1, ##Get from parsed text: first_dependencyword
        arg2 => $argument2 ##Get from parsed text: second_dependencyword
    };

But none of these variables have anything assigned to them.

My attempts:

A. If I put: if( defined (one_match_ref->{'sentence'})) after the s///, it works. But this is cumbersome, and seems to be avoiding the problem instead of fixing it.

The last time I used that fix, it was because my loop had an “off-by-one” error, I don’t think this is the case this time.

B. If I declare: my $sentence = ''; It prints, but with a lot of blank lines in between. How can I eliminate these?

EDIT: For interest and efficiency purposes: Is it better to use split to get what I want?

Thanks in advance for any help or advice. Let me know if you need an example of the file format.

  • 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-23T01:57:36+00:00Added an answer on May 23, 2026 at 1:57 am

    Your code boils down to

    my $sentence;
    $one_match_ref = { sentence => $sentence };
    () if ($line =~ /^Parsing \[sent. \d+ len. \d+\]: \[(.+)\]/);
    $one_match_ref->{'sentence'} =~ s/, / /g;
    

    You assign undef to $one_match_ref->{'sentence'}, then you try to remove the commas from it. That doesn’t make any sense, thus the warning.

    Maybe you want

    my $sentence;
    $one_match_ref = { sentence => $sentence };
    if ($line =~ /^Parsing \[sent. \d+ len. \d+\]: \[(.+)\]/) {
       $one_match_ref->{'sentence'} = $1;
       $one_match_ref->{'sentence'} =~ s/, / /g;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I've got a string that has curly quotes in it. I'd like to replace
I am trying to understand how to use SyndicationItem to display feed which is
I have a JSP page retrieving data and when single or double quotes are
i got an object with contents of html markup in it, for example: string
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.