summaryrefslogtreecommitdiffhomepage
path: root/perl.html.markdown
diff options
context:
space:
mode:
authorMarcel Ribeiro Dantas <ribeirodantasdm@gmail.com>2022-06-27 00:28:16 +0200
committerGitHub <noreply@github.com>2022-06-27 00:28:16 +0200
commit5d133e847846b4c8d436f7a567674c2e1df35a13 (patch)
tree7ebc7704f02ceef195a8896a80a06ed81cc12585 /perl.html.markdown
parent27f7f03401ff747a61a912fdf73549b1788b13e1 (diff)
parent8f28c8021b8ce3cb791861ad19c41e12228d8bcd (diff)
Merge branch 'master' into patch-1
Diffstat (limited to 'perl.html.markdown')
-rw-r--r--perl.html.markdown6
1 files changed, 6 insertions, 0 deletions
diff --git a/perl.html.markdown b/perl.html.markdown
index 8811dd08..88185e9d 100644
--- a/perl.html.markdown
+++ b/perl.html.markdown
@@ -217,6 +217,12 @@ open(my $log, ">>", "my.log") or die "Can't open my.log: $!";
my $line = <$in>;
my @lines = <$in>;
+# You can iterate through the lines in a file one at a time with a while loop:
+
+while (my $line = <$in>) {
+ print "Found apples\n" if $line =~ m/apples/;
+}
+
# You can write to an open filehandle using the standard "print"
# function.