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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:43:35+00:00 2026-05-19T22:43:35+00:00

I have a data set which has a list of user agents and devices

  • 0

I have a data set which has a list of user agents and devices corresponding to those UAs. There is another data set that has other data along with the User Agents. I need a way to identify the devices in that data.

So, I’ll have to map the UAs in the two files and then get the corresponding device info from the file that has the list. I’ve gotten as far as making a list of UAs in a hash from the first file and matching this with the UA in the data file. How do I get the corresponding information from the first file that has the device info again and write it to a file?

#!/usr/bin/perl

use warnings;
use strict;

our $inputfile = $ARGV[0];
our $outputfile = "$inputfile" . '.devidx';
our $devid_file = "devid_master";  # the file that has the UA and the corresponding device info
our %ua_list_hash = ();

# Create a list of mobile user agents in the devid_master file
 open DEVID, "$devid_file" or die "can't open $devid_file";

 while(<DEVID>) {
        chomp;
        my @devidfile = split /\t/;
        $ua_list_hash{$devidfile[1]} = 0;
 }  

 open IN,"$inputfile" or die "can't open $inputfile";       
 while(<IN>) {      
       chomp;       
       my @hhfile = split /\t/;       

       if(exists $ua_list_hash{$hhfile[24]}) {     
                     # how do I get the rest of the columns from the devidfile, columns 2...10?
       }
 }

 close IN;

Or is there a better way to do this is Perl? That is always welcome :).

  • 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-19T22:43:35+00:00Added an answer on May 19, 2026 at 10:43 pm

    When building the first lookup hash, couldn’t you store a reference to the other column data as the hash value, rather than just 0?

    #!/usr/bin/perl
    
    use warnings;
    use strict;
    
    our $inputfile = $ARGV[0];
    our $outputfile = "$inputfile" . '.devidx';
    our $devid_file = "devid_master";  # the file that has the UA and the corresponding device info
    our %ua_list_hash = ();
    
    # Create a list of mobile user agents in the devid_master file
     open DEVID, "$devid_file" or die "can't open $devid_file";
     while(<DEVID>) {
            chomp;
            my @devidfile = split /\t/;
            # save the columns you'll want to access later and
            # store a reference to them as the hash value
            my @values = @devidfile[2..$#devidfile];   
            $ua_list_hash{$devidfile[1]} = \@values;
     }  
    
     open IN,"$inputfile" or die "can't open $inputfile";       
     while(<IN>) {      
           chomp;       
           my @hhfile = split /\t/;       
    
           if(exists $ua_list_hash{$hhfile[24]}) {
               my @rest_of_vals = @{$ua_list_hash{$hhfile[24]};
               # do something with @rest_of_vals
           }
     }
    
     close IN;
    

    Note: I’ve not tested this.

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

Sidebar

Related Questions

I have a web service which has a generic function that returns a dataset
I have a data set which consists of an ID and a matrix (n
I have a set of data points in 3D space which apparently all fall
I have a PHP-generated page which is displaying some data about a set of
I have a set of XSDs from which I generate data access classes, stored
I have a mysql table field set as time type which stores data in
I have a set of controls bound to data, on which I would like
I have several objects set up in Core Data, one of which is Deck
I have a drop down which has a method which binds data to it:
I have a list of stories defined and, in another table, a set of

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.