Thank you all for your suggestions.
I appreciate you all giving your time...

Craig
[EMAIL PROTECTED]
Pager
Numeric: 1-877-895-3558
Email pager: [EMAIL PROTECTED]
--------------------------------------------------------------
You will never find time for anything.
If you want time, you must make it.

Charles Buxton

----- Original Message -----
From: "John Edwards" <[EMAIL PROTECTED]>
To: "Beginners@Perl (E-mail)" <[EMAIL PROTECTED]>
Sent: Wednesday, June 13, 2001 12:09 PM
Subject: RE: Problem printing a system value to a filehandle (windows)


> Hi, just joined the list and jumping into the middle of this thread, so
> excuse me if I'm talking out of turn.
>
> I have a couple of suggestions for you Craig.
>
> 1) Where you have
> print DATAFILE
>
"\n\n=======================================================================
> ======\n\n";
>
> You could instead use
>
> print DATAFILE "\n\n" . '='x77 . "\n\n";
>
> This will print out two newlines, then 77 equals signs, then the last two
> newlines. It's a little easier to read and make changes to the number of
> equals signs. You could also use a variable number of equals signs if you
> wanted. (Maybe not useful for this task, but some other)
>
> e.g
>
> $repeat = 60;
> print DATAFILE "\n\n" . '='x$repeat . "\n\n";
>
> Next, why do a system call to get the date and time? Perl comes with built
> in functions to do this for you. A really quick and simple way is to use
the
> scalar value of the localtime function. (localtime normally returns a list
> value but called in scalar context it will return an easy to read date and
> time ideal for a timestamp)
>
> print DATAFILE scalar(localtime);
>
> This will store somthing like "Wed Jun 13 16:56:37 2001" into the
DATAFILE.
>
> so all in all you could re-write your code as:
>
> --
> print DATAFILE "\n\n" . '='x77 . "\n\n";
> print DATAFILE scalar(localtime);
> --
>
> You could even do it all on one line and lose the scalar bit as when you
> concancate you use the scalar, not list values of the function.
>
> print DATAFILE "\n\n" . '='x77 . "\n\n" . localtime;
>
> HTH
>
> John
>
> -----Original Message-----
> From: Chas Owens [mailto:[EMAIL PROTECTED]]
> Sent: 13 June 2001 16:41
> To: Craig S Monroe
> Cc: [EMAIL PROTECTED]
> Subject: Re: Problem printing a system value to a filehandle (windows)
>
>
> On 13 Jun 2001 10:49:44 -0400, Craig S Monroe wrote:
> > Hello all,
> >
> > I have a script that opens a socket to a device, issues some commands,
> > then writes the results to a datafile.
> > That all works fine. I decided that I wanted to time stamp each of the
> > entries
> >
> > So where I put my separator:
> >
> >  # print a section separator to the dateFile
> >  print DATAFILE
> > "\n\n===================================================================
> > ==========\n\n";
> >
> > I wanted to put the date below it.
> >
> >  $time =~ system('TIME \/T');
> >  $date =~ system('DATE \/T');
>
> There are two things wrong here.  First system returns the exit code of
> the process you call (not the output), you want to use backticks (shift
> ~ on most keyboards in the US).  Second =~ is the binding operator for
> regexps not the assignment operator.  You should be saying:
>
> $time = `TIME /T`;
> $date = `DATE /T`;
>
> >  print DATAFILE "\n$time $date";
> >
> > It would not append the time and date.
> > So, I used the above to make it it's own perl script, and just removed
> > the filehandle so the output would print to the console.
> >
> > $time =~ system('TIME \/T');
> >  $date =~ system('DATE \/T');
> >  print "\n$time $date";
> >
> > This printed the date and the time to the console.
> > Does anyone have any suggestions as to why this is not working?
>
> It is working exactly as you told it to work <grin />.  It is running
> the TIME command (which outputs the time to stdout) and then running the
> DATE command (which outputs the date to stdout).
>
> >
> > Thank you,
> >
> > Craig
> > [EMAIL PROTECTED]
> > Pager
> > Numeric: 1-877-895-3558
> > Email pager: [EMAIL PROTECTED]
> > --------------------------------------------------------------
> > You will never find time for anything.
> > If you want time, you must make it.
> >
> > Charles Buxton
> >
> --
> Today is Prickle-Prickle, the 18th day of Confusion in the YOLD 3167
> Grudnuk demand sustenance!
>
>
>
> --------------------------Confidentiality--------------------------.
> This E-mail is confidential.  It should not be read, copied, disclosed or
> used by any person other than the intended recipient.  Unauthorised use,
> disclosure or copying by whatever medium is strictly prohibited and may be
> unlawful.  If you have received this E-mail in error please contact the
> sender immediately and delete the E-mail from your system.
>
>

Reply via email to