Perl script for sorting out an input


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl script for sorting out an input
# 1  
Old 06-09-2011
Perl script for sorting out an input

Code:
     <order>10.08.0</order>
      <order>11.02.0</order>
      <order>11.02.1</order>
      <order>11.02.2</order>
      <order>11.02.4</order>
      <order>11.02.5</order>
      <order>11.02.6</order>
      <order>11.04.0</order>
      <order>11.04.1</order>
      <order>11.04.2</order>
      <order>11.04.3</order>
      <order>11.04.4</order>

I want a perl script which sorts out the above input and pops out the value just as

11.04.4.

Can anyone please help me?
# 2  
Old 06-09-2011
Sort it how? It looks sorted already.
# 3  
Old 06-09-2011
Please read through the lines... I want the value 11.04.04 in a variable.

---------- Post updated at 03:23 PM ---------- Previous update was at 02:59 PM ----------

I will post my scenario in a different way.. Please help me in finding a solution.

Code:
my $content=get($url);

so in $content I have the following xml data..
Code:
<?xml order="1.0" encoding="UTF-8"?>
<metadata>
  <groupId>helloworld.tools</groupId>
  <artifactId>helltools-ear</artifactId>
  <ordering>
    <latest>11.04.2</latest>
    <release>11.04.4</release>
    <orders>
      <order>10.08.0</order>
      <order>11.02.0</order>
      <order>11.02.1</order>
      <order>11.02.2</order>
      <order>11.02.4</order>
      <order>11.02.5</order>
      <order>11.02.6</order>
      <order>11.04.0</order>
      <order>11.04.1</order>
      <order>11.04.2</order>
      <order>11.04.3</order>
      <order>11.04.4</order>
    </orders>
    <lastUpdated>20110607172227</lastUpdated>
  </ordering>
</metadata>

I want the value inside the release tags.
<release>11.04.4</release>

so in this case "11.04.4"

---------- Post updated at 05:06 PM ---------- Previous update was at 03:23 PM ----------

Found the answer myself...
Code:
if($content =~ m/<release>(.*)<\/release>/) {
            $recent=$1;
        }

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl Sorting Help

Hey guys, I have started to learn perl recently because of a position I took. They want me to master perl and I've been reading books and practicing myself. Basically I,m having my perl script run through a text pad and give the output in a special way e.g input deviceconfig { ... (5 Replies)
Discussion started by: zee3b
5 Replies

2. Shell Programming and Scripting

HELP on Perl array / sorting - trying to convert Korn Shell Script to Perl

Hi all, Not sure if this should be in the programming forum, but I believe it will get more response under the Shell Programming and Scripting FORUM. Am trying to write a customized df script in Perl and need some help with regards to using arrays and file handlers. At the moment am... (3 Replies)
Discussion started by: newbie_01
3 Replies

3. Shell Programming and Scripting

The scope of the shell/perl script is to read the input text file. Validate the expiry date of each

The scope of the shell/perl script is to read the input text file. Validate the expiry date of each certificate and send the mail to the user. The user takes action to add the new certificate to the storage file and user owns the responsibility to update the input text file with the new certificate... (5 Replies)
Discussion started by: casmo
5 Replies

4. Shell Programming and Scripting

Perl Script Not Reading Input Files Correctly

This is one of the strangest things that's happening to me. I'm writing a new Perl script that is trying to read a file. The file is originally in .mof format, but I also saved the contents into a .txt file. As a simple test, I wrote this: #!/user/bin/perl -w use strict; ... (3 Replies)
Discussion started by: kooshi
3 Replies

5. Shell Programming and Scripting

Remove default data hash sorting in perl script?

Hi, I have a datahash with 'n' number of values in perl script. I am writing a xml file from the datahash. I am getting output with sorting(Field sorting). My question is that i don't want any default sorting.whatever i am inserting into datahash it should give same xml file. Any help? ... (0 Replies)
Discussion started by: solo123
0 Replies

6. Shell Programming and Scripting

need shell or Perl script to read multiple input

I need shell 0r Perl script to read multiple input and do something and come out example: echo “ enter the host names separated by space “ read servers foreach @servers { do do something done} Here host names like host1 host2 host3 . . . . . . . so on Please help me... (8 Replies)
Discussion started by: sreedhargouda
8 Replies

7. Shell Programming and Scripting

Executing program with Perl script but needs user input

Hello, I'm running a perl script to execute a program through my Unix command line. The program requires a user input but I want to automatically have perl input the string. Is there a way to do this? Thanks (1 Reply)
Discussion started by: leonard2352
1 Replies

8. Shell Programming and Scripting

Perl - pass shell-vars into perl for input loop

I need to process a file line-by-line using some value from a shell variable Something like:perl -p -e 's/$shell_srch/$shell_replace/g' input.txt I can't make the '-s' work in the '-p' or '-n' input loop (or couldn't find a syntaxis.) I have searched and found... (4 Replies)
Discussion started by: alex_5161
4 Replies

9. Shell Programming and Scripting

Give input to a perl script while execution

Hi, I have a perl script which prints me the epoch value of a specific date and time given.Now I want to proceed to a next step ie i want to give the input at the time of execution. I have to initialise the date and time values in the script before executing it.But now i want to give the date... (3 Replies)
Discussion started by: jyothi_wipro
3 Replies

10. Shell Programming and Scripting

perl sorting

I have many files that I need to sort each week. I know how to do in Unix, but for this task it appears best to do native inside an existing perl program. So, simplified, I have a file similar to the following: Joe_________12_Main_St__A001________LX Benny_______5_Spring____A002________LX... (5 Replies)
Discussion started by: joeyg
5 Replies
Login or Register to Ask a Question