- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - Microsoft
- >
- Re: Perl - pattern matching
-
- Forums
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Latin America
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Blogs
-
Information
-
English
- 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
- Email to a Friend
- Report Inappropriate Content
03-31-2014 03:48 AM - last edited on 03-31-2014 07:24 PM by Lisa198503
03-31-2014 03:48 AM - last edited on 03-31-2014 07:24 PM by Lisa198503
Perl - pattern matching
Hi Support,
I have created a perl script that read a configuration file and extract from it one field if pattern match (field separator is ;;)
If i run it on HPUX/Linux host it works corretcly but if i try to run the script on Windows box it fails.
The perl version is for both environment v5.8.8.
Can you help me ?
Thanks.
Fabrizio
------------------------
#!/opt/OV/contrib/perl/bin/perl
#Set my variables
my $in_file = $ARGV[0];
#my $in_file = 'configuration_logfile_weblogic';
open my $in_fh, '<', $in_file or die "Could not open file $in_file: $!
+";
my $fqdn = `hostname`;
@hostname_short = split(/\./,$fqdn,2);
my $hostname = "@hostname_short[0]";
$hostname=~ tr/A-Z/a-z/;
while ( my $line = <$in_fh> ) {
if($line =~ m/^$hostname;;(.*);;/) {
print $1;
}
}
close $in_fh or die "Could not close file $in_file: $!";
P.S. This thread has been moved from HP-UX>Languages and Scripting to Microsoft > general. -HP Forum Moderator
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
03-31-2014 08:40 AM
03-31-2014 08:40 AM
Re: Perl - pattern matching
>> ...if i try to run the script on Windows box it fails.
How does it fail? What sort of error do you get?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-01-2014 01:04 AM
04-01-2014 01:04 AM
Re: Perl - pattern matching
Hi,
It didn't print $1 .. but now with this change:
my ($hostname) = `hostname` =~ /([-a-zA-Z0-9]+)/;
$hostname=~ tr/A-Z/a-z/;
it works correctly !
Thanks,
Fabrizio
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2021 Hewlett Packard Enterprise Development LP