The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Read Single Value From File With Perl Donkey25 Shell Programming and Scripting 1 04-01-2009 01:02 PM
[Perl] Accessing array elements within a sed command in Perl script userix Shell Programming and Scripting 2 10-03-2008 12:05 PM
Perl - combine two xml files nmadpl Shell Programming and Scripting 2 11-16-2006 12:12 PM
sed or grep or perl combine two lines artjaniger UNIX for Dummies Questions & Answers 3 06-27-2003 05:20 PM
combine 2 lines (command & echo) primal UNIX for Dummies Questions & Answers 13 10-09-2001 05:51 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-14-2009
jimmy_y jimmy_y is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 89
Lightbulb combine two perl lines into a single perl command

Hi Everyone,
i have a string 00:44:40

so:
$tmp=~ s/://gi;
$tmp=~s/([0-9]{2})([0-9]{2})([0-9]{2})/$1*3600+$2*60+$3/e;

the output is 2680.

Any way to combine this two lines into a single line?

Thanks
  #2 (permalink)  
Old 06-14-2009
KevinADC KevinADC is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2008
Posts: 731
Code:
$tmp=~s/([0-9]{2}):([0-9]{2}):([0-9]{2})/$1*3600+$2*60+$3/e;
Bits Awarded / Charged to KevinADC for this Post
Date User Comment Amount
06-14-2009 jimmy_y TQ 500
  #3 (permalink)  
Old 06-14-2009
jimmy_y jimmy_y is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 89
Quote:
Originally Posted by KevinADC View Post
Code:
$tmp=~s/([0-9]{2}):([0-9]{2}):([0-9]{2})/$1*3600+$2*60+$3/e;
Thanks

-----Post Update-----

Thanks Kevin
  #4 (permalink)  
Old 06-14-2009
summer_cherry summer_cherry is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,079
Code:
my $str='00:44:40';
$str=~s/([0-9]{2}):([0-9]{2}):([0-9]{2})/$1*3600+$2*60+$3/e;
print $str;
  #5 (permalink)  
Old 06-14-2009
KevinADC KevinADC is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2008
Posts: 731
Quote:
Originally Posted by summer_cherry View Post
Code:
my $str='00:44:40';
$str=~s/([0-9]{2}):([0-9]{2}):([0-9]{2})/$1*3600+$2*60+$3/e;
print $str;
Gee, thats original.
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:05 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0