Advertisement

07.23.2007 at 11:51PM PDT, ID: 22716270
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.6

Making a text file into an array, and substr

Asked by Simon336697 in Scripting Languages, Perl Programming Language

Tags:

Hi guys!
Hope you masters can help with your wisdom.
What I have is the following..

===========================A text file called sorty.txt
SS0594Nxxxx
SS0594Nxxxx
SS0594Nxxxx
SS2834Nxxxx
SS2834Nxxxx
ST7523Nxxxx
ST7523Nxxxx
ST7523Nxxxx
ST7523Nxxxx

etc etc
------------------------------ The above is just a snippet.

In the above are entries for computer names.

What I want to do with this text file is the following....
- Find UNIQUE entries and pump to a new file (eg.unique.txt).
- The script would read the sorty.txt file, and find unique entries starting from the 0 position, and length 6 characters.
- For example, if there were 4 lines starting with "SS0594" in sorty.txt, then the script would find and write  to a new file the line "SS0594".  
- Only 1 entry in the new file for SS0594, not four. Then, if there were 2 lines starting with "SS2887" in sorty.txt, the script would find and write to a new file the line "SS2887", and so on and so on.

sorty.txt                                                 unique.txt
SS0594Nxxxx                                       SS0594
SS0594Nxxxx                                       SS2834
SS0594Nxxxx                                       ST7523
SS2834Nxxxx                                  
SS2834Nxxxx
ST7523Nxxxx
ST7523Nxxxx
ST7523Nxxxx
ST7523Nxxxx

============================================= So far I have the following:

open (FINDUNIQUE, "< sorty.txt") or die "can't open sorty.txt: $!";

$a = 0;
while( <FINDUNIQUE> )      {
   $Sys = $_;
      chomp ($Sys);
   @System[$a] = $Sys;
#print "a = $a - system = $System[$a]\n";
   $a++
}
      foreach $line (@System) {
      $six = substr($line,0,6);
                      print "$line\n";
         foreach $line1 (@System) {
           $newsix = substr ($line1, 0,6);      
            if ($six == $newsix) {
               shift (@System);
                
         }
      }
   }
   
======================================================

Any help greatly appreciated.
Somehow I have to (I think):
a) Turn the sorty.txt file into an array (slurp or something?)
b) Go through each line aind the first 6 characters of a line
c) If there are multiple lines with the same first 6 characters, then only use one unique.
I think I might have to use shift or something to move these entries from the array, along with a next function.

Thanks guys.Start Free Trial
 
Loading Advertisement...
 
[+][-]07.24.2007 at 12:01AM PDT, ID: 19553964

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.24.2007 at 12:01AM PDT, ID: 19553967

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 14-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.24.2007 at 12:21AM PDT, ID: 19554056

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.24.2007 at 12:32AM PDT, ID: 19554093

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.24.2007 at 12:32AM PDT, ID: 19554098

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.24.2007 at 12:37AM PDT, ID: 19554111

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.24.2007 at 12:40AM PDT, ID: 19554122

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.24.2007 at 12:44AM PDT, ID: 19554135

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.24.2007 at 12:45AM PDT, ID: 19554137

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.24.2007 at 12:53AM PDT, ID: 19554166

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 14-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.24.2007 at 12:54AM PDT, ID: 19554170

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.24.2007 at 01:17AM PDT, ID: 19554276

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.24.2007 at 01:18AM PDT, ID: 19554279

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.24.2007 at 01:34AM PDT, ID: 19554359

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.24.2007 at 01:35AM PDT, ID: 19554363

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.24.2007 at 01:40AM PDT, ID: 19554383

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.24.2007 at 01:47AM PDT, ID: 19554417

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.24.2007 at 01:52AM PDT, ID: 19554439

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.24.2007 at 02:06AM PDT, ID: 19554507

View this solution now by starting your 14-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Scripting Languages, Perl Programming Language
Tags: file
Sign Up Now!
Solution Provided By: ozo
Participating Experts: 3
Solution Grade: A
 
 
[+][-]07.24.2007 at 02:18AM PDT, ID: 19554566

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-43