Script
#!/usr/bin/perl -w use strict; while (my $input = <DATA>){ my ($name,$num,$addr,$date,$n) = split(/:/, $input); print "$name\n", if $name = s/William Kopf/Siegfield/ig; } __DATA__ Tommy Savage: 408–72 4–0140: 12 2 2 Oxbow Court, Sunnyvale, CA 94087: + 5/19/66: 34200 50 Lesle Kerstin: 408–456–1234: 4 Harvard Square, Boston, MA 02133: 4 +/22/62: 52600 51 Jon DeLoach: 408–253–3 122: 12 3 Park St. , San Jose, CA 94086: 7/ +25/53: 85100 52 Ephram Hardy: 293–259–5395: 2 3 5 Carlton Lane, Joliet, IL 73858: +8/12/20: 56700 53 Betty Boop: 245–836–83 57: 63 5 Cutesy Lane, Hollywood, CA 91464: +6/23/23: 14500 54 William Kopf: 846–83 6–2837: 693 7 Ware Road, Milton, PA 93756: 9/ +21/46: 43500 55 Norma Corder: 397–857–2735: 74 Pine Street, Dearborn, MI 23874: 3/ +28/45: 245700 56 James Ikeda: 834–938–8376: 2 3 445 Aster Ave. , Allentown, NJ 8374 +5: 12/1/38: 45000 57 Lori Gortz: 327–832–5728: 3465 Mirlo Street, Peabody, MA 34756: 10 +/2/65: 35200 58 Barbara Kerz: 385–57 3 –8326: 83 2 Ponce Drive, Gary, IN 83756: 12 +/15/46: 268500
Result
Use of uninitialized value $_ in substitution (s///) at ./exer1.pl lin +e 45, <DATA> line 1. Use of uninitialized value $_ in substitution (s///) at ./exer1.pl lin +e 45, <DATA> line 2. ./exer1.pl line 45, <DATA> line 8.

Can anyone explain why I am getting it. Thanks!!


In reply to regex problem by pinnacle

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.