Use either

---------------------------
while (($line=<INDATA>))
{
    chomp($line);
    if (!($line =~ /^\d/))
    {
        print OUTDATA "$line **unchanged** \n";
        next;
    }
    else
    {

        blah blah blah
---------------------------

or

---------------------------
while (<INDATA>)
{
    chomp;
    if (! /^\d/)
    {
        print OUTDATA "$_ **unchanged** \n";
        next;
    }
    else
    {
        $line = $_;
        blah blah blah
---------------------------

or even (and this is the way I like it)

---------------------------
while (<INDATA>) {
    chomp;
    print (OUTDATA "$_ **unchanged** \n"), next if (! /^\d/);
    $line = $_;
    blah blah blah
---------------------------




----- Original Message -----
From: "Greg" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: "Wagner-David" <[EMAIL PROTECTED]>
Sent: Sunday, July 22, 2001 8:01 PM
Subject: RE: pattern matching


>
> I have tried your example, but perhaps I have something else incorrect in
my
> script.  I included the full script.  (I'm fairly new so there may be some
> other issues..)
>
> If I exec this script below..  It passes all lines untouched.  I have
tried
> a couple other methods and still no luck..
>
> Thanks...
>
> Greg.
>
>
>
> ################
> # code example...
> ############
>
> #!/usr/bin/perl
>
> my $sonfile;    #source .son file
> my $houramount; #offset in hours
> my $minutamount;#offset in minutes
> my $secondamount;#offset in seconds
> my $famount;  #offset in frames
> my $count; #subtitle number (column one)
> my $start; #start time for sub (column two)
> my $stop;  #stop time for sub (column three)
> my $tiff; #tiff name (column four)
> my $hour;
> my $newhour;
> my $newminute;
> my $newsecond;
> my $newframe;
> my $hourb;
> my $minuteb;
> my $secondb;
> my $frameb;
> my $newframeb;
> my $newsecondb;
> my $newminuteb;
> my $newhourb;
>
> #START
> #print banner....
>
> print "\n\n\n\n\n";
> print "                 TimeAdjust v1.30 \n\n";
> print "                 greg\@meatplow.com \n";
> print "\n\n\n\n\n";
>
>
>
> #get data from user...
>
> print "What is the name of the input file ? \n(include absolut path if in
> different directory)  :";
> $sonfile = <STDIN>;
> chomp $sonfile;
> print "What is the name of the output file ?:  ";
> $result = <STDIN>;
> chomp $result;
> print "\n\n\n\n";
> print "What is the hour difference ?  (single digit):   ";
> $houramount = <STDIN>;
> chomp $houramount;
> print "What is the minute difference ? (one or two digits):   "   ;
> $minutamount = <STDIN>;
> chomp $minutamount;
> print "What is the second difference ? (one or two digits):   ";
> $secondamount = <STDIN>;
> chomp $minutamount;
> print "What is the frame difference ? (one or two digits):   ";
> $famount = <STDIN>;
> chomp $famount;
>
>
>
>
> open (INDATA, "$sonfile") ||die "cannot open $sonfile $!\n";
> open (OUTDATA, "> $result") ||die "cannot open $result $!\n";
>
> while (($line=<INDATA>))
> {
>
> chomp($line);
>
>
> ###########
> # added example from beginners.per
> ###########
>
> #
> #  This prints all lines UNCHANGED..
> #
> #
>
>
> if (! /^\d/)
> {
> print OUTDATA "$line **unchanged** \n";
> next;
> }
> else
> {
>
>
> ################
> #  End added example from beginners.per
> ################
>
>
>
> @_ = ($count, $hour, $minute, $second, $frame,
>      $hourb,$minuteb, $secondb, $frameb, $tiff)
>      = split(/[: ]/,$line);
>
>
> #
> #print Column one
> #
>
> print OUTDATA "$count ";
> print "$count ";
>
>
> #
> #print column TWO
> #
>
>
>
> $newhour = $hour + $houramount;
> $newminute = $minute + $minuteamount;
> $newsecond = $second + $secondamount;
> $newframe = $frame + $famount;
>
>
>
>
>
> #base 30 for frames
> if ($newframe >29)
> {
> $newframe = ($newframe - 30);
> $newsecond = ($newsecond + 1);
> }
>
> #base 60 for seconds
> if ($newsecond > 59)
> {
> $newsecond = ($newsecond - 30);
> $newminute = ($newminute + 1);
> }
> #base 60 for minutes
> if ($newminute > 59)
> {
> $newminute = ($newminute - 30);
> $hour = ($hour + 1);
> }
>
> # Write the data to the file.
> if ($newhour < 10)
> {
> # print OUTDATA "0";
> }
> print OUTDATA "$hour:";
> print "$hour:";
>
> if ($newminute < 10)
> {
> print OUTDATA "0";
> }
> print OUTDATA "$newminute:";
> print "$newminute:";
>
> if ($newsecond < 10)
> {
> print OUTDATA "0";
> }
> print OUTDATA "$newsecond:";
> print "$newsecond:";
>
> if ($newframe < 10)
> {
> print OUTDATA "0";
> }
> print OUTDATA "$newframe ";
> print "$newframe ";
>
>
>
> #
> # print column three
> #
>
>
>
> $newhourb = $hourb + $houramount;
> $newminuteb = $minuteb + $minuteamount;
> $newsecondb = $secondb + $secondamount;
> $newframeb = $frameb + $famount;
>
>
>
>
>
> #base 30 for frames
> if ($newframeb >29)
> {
> $newframeb = ($newframeb - 30);
> $newsecondb = ($newsecondb + 1);
> }
>
> #base 60 for seconds
> if ($newsecondb > 59)
> {
> $newsecondb = ($newsecondb - 30);
> $newminuteb = ($newminuteb + 1);
> }
> #base 60 for minutes
> if ($newminuteb > 59)
> {
> $newminuteb = ($newminuteb - 30);
> $hourb = ($hourb + 1);
> }
>
> # Write the data to the file.
> if ($newhourb < 10)
> {
> #print OUTDATA "0";
> }
> print OUTDATA "$hour:";
> print "$hourb:";
>
> if ($newminuteb < 10)
> {
> print OUTDATA "0";
> }
> print OUTDATA "$newminuteb:";
> print "$newminuteb:";
>
> if ($newsecondb < 10)
> {
> print OUTDATA "0";
> }
> print OUTDATA "$newsecondb:";
> print "$newsecondb:";
>
> if ($newframeb < 10)
> {
> print OUTDATA "0";
> }
> print OUTDATA "$newframeb ";
> print "$newframeb \n";
>
>
> #
> #print column four
> #
>
> print OUTDATA "$tiff \n";
>
> }
> }
> close (OUTDATA);
> close (INDATA);
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to