For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > October 2005 > Re: I need help here









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: I need help here
Bill Stephenson

2005-10-14, 6:55 pm

On Oct 14, 2005, at 7:22 AM, Sreedhar reddy wrote:

>
> Hi,
>
> I am very new to PERL and I need a program to do following task. Can
> u help
> me pls.
>
>
> I have a file with following contents.
>
> 454 NV_DS_DEFAULT_BAUDRATE_I
> 455 NV_DIAG_DEFAULT_BAUDRATE_I
> 516 NV_WCDMA_RX_LIN_VS_TEMP_I
>
> I am expecting out put like
>
> NV_DS_DEFAULT_BAUDRATE_I 454
> NV_DIAG_DEFAULT_BAUDRATE_I 455
> NV_WCDMA_RX_LIN_VS_TEMP_I 516
>
> Basically it is interchanging of columns. Looking forward for your
> help.



This should help get you started....

<code>

#!/usr/bin/perl

use strict;
my $output;

my @record_list = ('454 NV_DS_DEFAULT_BAUDRATE_I',
'455 NV_DIAG_DEFAULT_BAUDRATE_I',
'516 NV_WCDMA_RX_LIN_VS_TEMP_I');

for my $items(@record_list) {

my ($number, $name) = split(/ /, $items);

$output .= "$name $number\n";

}

print $output;

</code>

Kindest Regards,

--
Bill Stephenson
417-546-8390

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com