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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:29:37+00:00 2026-06-18T16:29:37+00:00

Hello I have a text which looks like this: And lets say I have

  • 0

Hello I have a text which looks like this:

And lets say I have a Phone number that looks like this:

39349562486245

and a Entry in a file that looks like this:

1002978;ITM;39349;ITALIEN  MOBIL;5;0;414;177

Now The beginning of the Number matches with the one down there how can I check if does begin with that number in Perl. So I am this far but it doesent work:

zeile[5] Is the Phone Number.

open( DATEIMAIN, "<$dateimainc" ) || die("Datei $dateimainc kann nicht geöffnet werden!");
    my @zeilenMAIN = <DATEIMAIN>;   


    for(my $lineNMAIN = 1; $lineNMAIN < @zeilenMAIN; $lineNMAIN++)
        {
            @zeileMAINC =  split( /;/, $zeilenMAIN[$lineNMAIN] );

            if ($zeile[5] =~ /^$zeileMAINC[2]/)
            {
                $displaynameB = $zeileMAINC[3];
                last;
            }
        }
  • 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-06-18T16:29:38+00:00Added an answer on June 18, 2026 at 4:29 pm

    Build a hash of string prefixes, then use that:

    use warnings;
    use strict;
    
    #Load the lines of input data into a hash.
    my %prefixes = map { chomp; split ';' } <DATA>;
    
    my @numbers = ('39349562486245','123456789');
    
    #Create a single regex like /^(12345|48956|...)/ for efficiency.
    my $regex = '^(' . join('|',map{quotemeta} keys %prefixes) . ')';
    
    for my $num (@numbers)
    {
        print "$num is $prefixes{$1}\n" if ($num =~ /$regex/);  
    }
    
    __DATA__
    39349;ITALIEN
    12345;FOO
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text file which contains something like this: Hello, my name is
Currently I am doing this: I have text that looks like: Hello ${user.name}, this
So I have a a text file that looks something like this: public >ret
I have tables which looks like this: text = ID = 1234 Hello World
I have this function that limits text, lets say to 50 chars like above:
I have a text file which looks like this: VariableA = 10 VariableB =
I do have some text(template), which looks like Hello @FirstName, Welcome to @Address. The
I have string which rich text content something like this for example <p>Hello</p> <br/>
I have a string like: hello #this# is #some text string# text text I
If I have some xml like this: <mynode> <mysubnode> <mysubsubnode>hello world</mysubsubnode> some more text

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.