On Mon, 2008-08-04 at 16:28 -0500, Tom Yarrish wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hey all, > I'm trying to pull some machine names out of a CSV file, and I'm using > the Pattern Test Program from Learning Perl 4th ed, but I don't think > I have the logic right. Here's a sample line from the CSV file: > > TAP0SMITHJ | smithj (192.168.1.1),DOMAIN | Professional,"4.0.0.1180, > 2008-07-31 12:04:56",I,U > > (the data was scrubbed with generic info, but it's the same stuff) > > So what I want to capture is the TAP0SMITHJ stuff only. Here's the > Pattern Test Program I'm using: > > #!/usr/bin/perl > > use strict; > use warnings; > use 5.010; > > while (<>) { # take one input line at a time > chomp; > if (/^TAP+\wb\|/xm) {
if( /^TAP\w+\s*\|/xm ){ # Since you specified the x flag, you could use # if( / ^ TAP \w+ \s* \| /xm ){ # if it makes reading easier. > print "Matched: |$`<$&>$'|\n"; # the special match vars > } else { > print "No match: |$_|\n"; > } > } > > I'm basically working on getting the regex, then I'm going to > incorporate it into a program to pull out the TAP0SMITHJ stuff and put > it in another file. > > Thanks, > Tom > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.8 (Darwin) > > iEYEARECAAYFAkiXdHQACgkQZWzkfeDiTw5hZgCdFOWLfu6eQAGsXUBSVyqwPa/b > ulQAn2oxs869Eh2I172rTqUjCs88VUyV > =DPep > -----END PGP SIGNATURE----- > -- Just my 0.00000002 million dollars worth, Shawn "Where there's duct tape, there's hope." "Perl is the duct tape of the Internet." Hassan Schroeder, Sun's first webmaster -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/