The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Text formatting in Perl. fenox Shell Programming and Scripting 2 02-15-2008 01:06 PM
Perl Sort on Text File eltinator Shell Programming and Scripting 6 08-07-2007 11:20 AM
how to insert text before first line in perl umen Shell Programming and Scripting 3 08-17-2006 12:25 AM
Perl text file Sn33R Shell Programming and Scripting 5 10-31-2003 08:59 AM
Perl: taking text from a .txt file perleo Shell Programming and Scripting 2 06-19-2003 07:23 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 04-23-2008
Registered User
 

Join Date: Feb 2007
Posts: 34
Need help take out few text in perl

I have perl program and I know that while sending an e-mail the following code returns "Remote (/opt/seasoft/db/nervecenter.nms00tst1):"
in an email, I need to take out the entire "opt/seasoft/db/nervecenter" and leave with "ms00tst1" only. How do I do it:

So the output would be "Remote (nms00tst1)"


$email_msg .= "Remote (".$server->[3]."):\n";


Thanks.,
Reply With Quote
Forum Sponsor
  #2  
Old 04-23-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
I'm not sure I understand your request, but here's a first attempt.

Code:
my $remote = $server->[3];
$remote =~ s%.*\.%%;  # Remove up to first dot
$email_msg .= "Remote ($remote):\n";
If you want to remove the n after the dot too, I'm sure you can figure that part out.
Reply With Quote
  #3  
Old 04-23-2008
Registered User
 

Join Date: Feb 2007
Posts: 34
$$server->[3] will return (/opt/seasoft/db/nervecenter.nms00tst1)
(This path is hardcoded)

But the email return the entire path (/opt/seasoft/db/nervecenter.nms00tst1)

I need to return only "Remote (nms00tst1)."

Thanks.
Reply With Quote
  #4  
Old 04-23-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
And for some reason you didn't try the code I posted?

Code:
vnix$ perl -le '$server->[3] = "/opt/seasoft/db/nervecenter.nms00tst1";
> my $remote = $server->[3]; $remote =~ s%.*\.%%; $email_msg .= "Remote ($remote):\n";
> print $email_msg'
Remote (nms00tst1):
vnix$
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:05 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0