- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Microsoft
- >
- Perl - pattern matching
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
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
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-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
- 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
- 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