Perl

From SkyWiki

(Difference between revisions)
Jump to: navigation, search
(New page: == PERL syntax == category:remember)
Line 1: Line 1:
== PERL syntax ==
== PERL syntax ==
[[category:remember]]
[[category:remember]]
 +
 +
===read a file line by line===
 +
<source lang=perl>
 +
  open(IN, '<'.$ARGV[0]);
 +
  foreach(<IN>) {
 +
    chomp;
 +
    print $_, "\n";
 +
  }
 +
  close(IN);
 +
</source>

Revision as of 11:15, 15 September 2008

PERL syntax

read a file line by line

  open(IN, '<'.$ARGV[0]);
  foreach(<IN>) {
    chomp;
    print $_, "\n";
  }
  close(IN);
Personal tools