- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Perl help
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2011 10:51 PM
03-23-2011 10:51 PM
I have a piece of perl code which makes a http call to a URL and in return gets a bunch of data related to application version.
There is a string which gets returned from the http call -
"BuildVersion" = "/tmp/maven-build-nHNMkWwtlz/applicationABC-20101029-105300-31abb9224ff046fe84f3914293a8cae0";
I have made a piece of code which returns this information for me but I need it to return just "maven-build-.....cae0" and not /tmp.
Here is the snippet of the code -
my $BV = $httpmethod->objectForKey("BuildVersion");
if ($BV && $$BV) {
if ($version) {
$version .= ", ";
}
$BV = $BV->UTF8String();
$version .= "BV=$BV";
I want the output to return -
BuildVersion = "maven...."
Thanks,
Allan.
Solved! Go to Solution.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2011 04:01 AM
03-24-2011 04:01 AM
Re: Perl help
Just add:
print "BuildVersion=";
$BV =~ m/^\/(.*)\/(.*)\/(.*)/;
print $2;
print "\/";
print $3;
$OUT = "BuildVersion=".$2."\/".$3;
in $OUT var. you would have the string you are looking for.
Best regards
Horia.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2011 04:18 AM
03-24-2011 04:18 AM
Re: Perl help
# BV='"BuildVersion" = "/tmp/maven-build-nHNMkWwtlz/applicationABC-20101029-105300-31abb9224ff046fe84f3914293a8cae0"'
# echo ${X} | perl -nle 'm{(".*[^"]\s*=\s*")/.*?/(.*)} and print "$1$2"'
"BuildVersion" = "maven-build-nHNMkWwtlz/applicationABC-20101029-105300-31abb9224ff046fe84f3914293a8cae0"
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2011 04:29 AM
03-24-2011 04:29 AM
Re: Perl help
># echo ${X} | ...
This is a shell code. Please provide a perl code, as Allan asked from the first time.
Best regards
Horia.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2011 04:50 AM
03-24-2011 04:50 AM
Re: Perl help
> @James: ># echo ${X} | ...This is a shell code. Please provide a perl code, as Allan asked from the first time.
I'll leave that to Allan to decide what helps him or doesn't. I don't need to be told what to post and what not to post.
If you look more closely at what I posted, the only shell code is the 'echo' into a pipe for Perl to read from its STDIN.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2011 05:00 AM
03-24-2011 05:00 AM
Re: Perl help
Of course, this is it. This is a shell code.
My point was that you assumed too much. Maybe Allan really needed a plain perl code. Maybe he does not know at all how to write a script in shell code.
If someone is asking for help, he expects to receive what he asked for.
Best regards,
Horia.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2011 05:18 AM
03-24-2011 05:18 AM
SolutionSee if this addresses your need more directly:
#!/usr/bin/perl
use strict;
use warnings;
my $BV=q("BuildVersion" = "/tmp/maven-build-nHNMkWwtlz/applicationABC-20101029-105300-31abb9224ff046fe84f3914293a8cae0");
print "BEFORE: $BV\n";
$BV =~ s{(".*[^"]\s*=\s*")/.*?/(.*)}{$1$2};
print "AFTER : $BV\n";
1;
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2011 05:20 AM
03-24-2011 05:20 AM
Re: Perl help
Have a nice day.
Horia.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2011 09:57 AM
03-24-2011 09:57 AM
Re: Perl help
I am able get the BV but only thing is that I want /tmp/ removed...
Regards,
Allan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2011 03:33 AM
03-25-2011 03:33 AM
Re: Perl help
Have you tried my piece of script?
Best regards
Horia.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2011 03:36 AM
03-25-2011 03:36 AM
Re: Perl help
Best regards,
Horia.
Horia.