• Perl syntax

    From Avon@21:1/101 to All on Sat May 8 09:09:32 2021
    I'm playing with a perl script that generates a report of held packets for 1/100 HUB. I want to add a printed header that includes the date and time the snapshot was generated. Can anyone advise the best syntax and code to use?

    Currently the script starts of printing a header that looks like this

    print <<EOF;
    +------------------+--------+-----------+-----------+-----------+
    | Node | Days | NetMail | EchoMail | Files | +------------------+--------+-----------+-----------+-----------+
    EOF

    I want to add the date/time prior to it.

    Thanks for any guidance :)

    --- Mystic BBS v1.12 A46 2020/08/26 (Windows/32)
    * Origin: Agency BBS | Dunedin, New Zealand | agency.bbs.nz (21:1/101)
  • From Spectre@21:3/101 to Avon on Sat May 8 10:27:00 2021
    Thanks for any guidance :)

    You could try knit 1 and pearl 2 ;)

    Spec


    *** THE READER V4.50 [freeware]
    --- SuperBBS v1.17-3 (Eval)
    * Origin: We know where you live, we're coming round to get you (21:3/101)
  • From bugz@21:4/110 to Avon on Sat May 8 20:02:00 2021
    Hi Avon,

    That's called here-doc (the << and EOF parts). "EOF" isn't anything special, it can be any text. Just so long as it matches.

    The easiest way would be to create a variable with the datetime in it, and have that printed.

    my $dt = localtime();

    print <<EOF;
    Generated: $dt +------------------+--------+-----------+-----------+-----------+
    | Node | Days | NetMail | EchoMail | Files | +------------------+--------+-----------+-----------+-----------+
    EOF

    If you want more control over the datetime output, I think this
    will help: https://www.tutorialspoint.com/perl/perl_date_time.htm

    Take care,
    bugz


    --- ENiGMA 1/2 v0.0.12-beta (linux; x64; 14.16.0)
    * Origin: BZ&BZ BBS (21:4/110)
  • From Avon@21:1/101 to bugz on Sun May 9 13:27:03 2021
    On 08 May 2021 at 08:02p, bugz pondered and said...

    The easiest way would be to create a variable with the datetime in it,
    and have that printed.

    my $dt = localtime();

    print <<EOF;
    Generated: $dt

    Brill, thanks kind sir. :)

    --- Mystic BBS v1.12 A46 2020/08/26 (Windows/32)
    * Origin: Agency BBS | Dunedin, New Zealand | agency.bbs.nz (21:1/101)
  • From Nigel Reed@21:2/101 to Avon on Sun May 9 15:31:17 2021
    Avon wrote:
    I'm playing with a perl script that generates a report of held packets for 1/100 HUB. I want to add a printed header that includes the date and time the snapshot was generated. Can anyone advise the best syntax and code to use?

    Currently the script starts of printing a header that looks like this

    print <<EOF; +------------------+--------+-----------+-----------+-----------+
    | Node | Days | NetMail | EchoMail | Files | +------------------+--------+-----------+-----------+-----------+
    EOF

    I want to add the date/time prior to it.

    Though not answering your question, why aren't you using the formats
    abilities of PERL to display your headers?

    https://www.tutorialspoint.com/perl/perl_format.htm

    This makes it extremely easy to add and change headers and details, while dealing with the formatting for you. If you've never used it, it's really
    worth learning. It can save you a lot of time in the end once you understand it.
    --- SBBSecho 3.14-Linux
    * Origin: End Of The Line BBS - endofthelinebbs.com (21:2/101)
  • From Avon@21:1/101 to Nigel Reed on Mon May 10 19:34:47 2021
    On 09 May 2021 at 03:31p, Nigel Reed pondered and said...

    Though not answering your question, why aren't you using the formats abilities of PERL to display your headers?

    Mmmm it's not my script, I don't know Perl (but hear she has a nice sister...heh, sorry couldn't resist) so I am learning as I go. It's always
    the case of learn by doing with stuff you want to tweak. :)

    https://www.tutorialspoint.com/perl/perl_format.htm

    This makes it extremely easy to add and change headers and details, while dealing with the formatting for you. If you've never used it, it's really worth learning. It can save you a lot of time in the end once you understand it.

    Thank you I'll try to make some time to read and review this - appreciated :)

    --- Mystic BBS v1.12 A46 2020/08/26 (Windows/32)
    * Origin: Agency BBS | Dunedin, New Zealand | agency.bbs.nz (21:1/101)