Change $line = <INDATA> to <INDATA>

        When you do a Regex without any designations as to what you are
searching vs, it goes against $_. You are reading into $line. So make the
change above, replace chomp($line) with chomp; . Also replace the output of
the headers from $line to $_.  In fact, where ever you have $line replace
with $_ and it should do what you want.

Wags ;)

-----Original Message-----
From: Greg [mailto:[EMAIL PROTECTED]]
Sent: Sunday, July 22, 2001 16:02
To: [EMAIL PROTECTED]
Cc: Wagner-David
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]

Reply via email to