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 Linux host it works corretcly but if i try to run the script on Windows one it fails (it does not print $1 value) The perl version is for both environment v5.8.8. This an example of entry in configuration file:
hostname1;;/tmp/fab/app01/log/app01.log /tmp/fab/app01/log/app02.stder +r /tmp/fab/app01/log/app03.stdout;; hostname2;;C:\temp\log\loga.txt C:\temp\log\logb.txt;;
#!/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: $!";
Can you help me ? Thanks. Fabrizio

In reply to Perl - pattern matching by fabrizio_start_perl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.