I had no problems with using /^/ for the beginning of a line - maybe because I processed the records line by line.
#!/usr/bin/perl use warnings; use strict; $/ = "#"; while (<DATA>) { next if $. == 1; # Skipt the empty "first" record; my @lines = split /\n/; my ($vlan, $ifconfig) = (0, 0); for (@lines) { if (/^hostname/) { print "$_\n"; } elsif (/^vlan/) { $vlan++ for m/\S+/g; $vlan -= 3; } elsif (/^ifconfig/) { $ifconfig++ for m/\S+/g; $ifconfig -= 3; } } print "vlan $vlan\nifconfig $ifconfig\n"; print "WRONG!!!\n" if $vlan != $ifconfig; }
In reply to Re: Help with logic/syntax
by choroba
in thread Help with logic/syntax
by randompug
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |