Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8937353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:23:55+00:00 2026-06-15T10:23:55+00:00

I have this perl script working nicely the output is presented in the console.

  • 0

I have this perl script working nicely the output is presented in the console. However, My idea is to redirect to a file…. so far i was able to do half of the task. I can PRINT FILE everything except for the two sub routines which get called within “sub writepage”

any ideas?

#!/usr/bin/perl
use strict;
use warnings;
use POSIX qw/strftime/;
#use warnings;
my $TOTALIOS = 'totalios';
my $READP = 'readpe';
my $CACHEP = 'cachehit';
my $CKBSEC = 'currentkb';
my $MKBSEC = 'maximumkb';
my $CIOSEC = 'currentio';
my $MIOSEC = 'maxio';
my $DATESTORE = 'dates.sec';
my $DATECMD = strftime "%m/%d/%y", localtime;
my $TIOS = 'Tios';
my $READp = 'readp';
my $CACHEp = 'cachep';
my $CKBsec = 'ckbsec';
my $MKBsec = 'mkbsec';
my $CIOsec = 'ciosec';
my $MIOsec = 'miosec';
my ($STORENUM, $STORENAME, $IMGPREFIX, $MONTH, $DAY, $YEAR) = &mysubinput;
#my $STORENUM;
#my $STORENAME;
#my $IMGPREFIX;
#my $MONTH;
#my $DAY;
#my $YEAR;
my $outfile = 'datastore.txt';
sub mysubinput
{
    print "Enter the number for the datastore: \n";
        my $STORENUM = <STDIN>;
        chomp($STORENUM);
        print "Enter the name for the datastore e.g: DataStore or ServerStore: \n";
        my $STORENAME = <STDIN>;
        chomp($STORENAME);
        print "Enter the data store image prefix e.g. datastore or serverstore: \n";
        my $IMGPREFIX = <STDIN>;
        chomp($IMGPREFIX);
        print "Enter the month MM: \n";
        my $MONTH = <STDIN>;
        chomp($MONTH);
        print "Enter the day DD: \n";
        my $DAY = <STDIN>;
        chomp($DAY);
        print "Enter the Year YYYY: \n";
        my $YEAR = <STDIN>;
        chomp($YEAR);
    return ($STORENUM, $STORENAME, $IMGPREFIX, $MONTH, $DAY, $YEAR);
#   print "$STORENUM $STORENAME $IMGPREFIX $MONTH $DAY $YEAR\n";
#   print "Not a very interesting routine\n";
#   print "This does the same thing every time\n";
#   print "$TOTALIOS\n";
#   print "Enter the number for the datastore: \n";
#   $line = <STDIN>;
#   chomp($line);
#   print "$line\n";
#   print "$DATECMD\n";
}
sub writedate 
{
    print "! $DATECMD\n";   
}    

sub writesections
{
    print "| [[File:$STORENAME-$STORENUM-$TIOS-$MONTH-$DAY-$YEAR.png| 100px]]\n";
    print "| [[File:$STORENAME-$STORENUM-$READp-$MONTH-$DAY-$YEAR.png| 100px]]\n";
    print "| [[File:$STORENAME-$STORENUM-$CACHEp-$MONTH-$DAY-$YEAR.png| 100px]]\n";
    print "| [[File:$STORENAME-$STORENUM-$CKBsec-$MONTH-$DAY-$YEAR.png| 100px]]\n";
    print "| [[File:$STORENAME-$STORENUM-$MKBsec-$MONTH-$DAY-$YEAR.png| 100px]]\n";
    print "| [[File:$STORENAME-$STORENUM-$CIOsec-$MONTH-$DAY-$YEAR.png| 100px]]\n";
    print "| [[File:$STORENAME-$STORENUM-$MIOsec-$MONTH-$DAY-$YEAR.png| 100px]]\n";
}   

sub writepage
{
    open (FILE, ">> $outfile") || die "problem opening $outfile\n";
    print FILE "Go back to [[MD3000i-Perf]] \n";
    print FILE "{| border=1 cellspacing=5 cellpadding=2 style=text-align: center \n";
    print FILE "|-\n";
    print FILE "! [[DataStore-1]]\n";
    print FILE "! [[DataStore-2]]\n";
    print FILE "! [[DataStore-3]]\n";
    print FILE "! [[DataStore-4]]\n";
    print FILE "! [[DataStore-5]]\n";
    print FILE "! [[DataStore-6]]\n";
    print FILE "! [[DataStore-7]]\n";
    print FILE "! [[DataStore-8]]\n";
    print FILE "! [[DataStore-9]]\n";
    print FILE "|-\n";
    print FILE "| [[File:disk.png |60px]]\n";
    print FILE "| [[File:disk.png |60px]]\n";
    print FILE "| [[File:disk.png |60px]]\n";
    print FILE "| [[File:disk.png |60px]]\n";
    print FILE "| [[File:disk.png |60px]]\n";
    print FILE "| [[File:disk.png |60px]]\n";
    print FILE "| [[File:disk.png |60px]]\n";
    print FILE "| [[File:disk.png |60px]]\n";
    print FILE "| [[File:disk.png |60px]]\n";
    print FILE "|}\n";
    print FILE "{| border=1 cellspacing=5 cellpadding=2 style=text-align: center\n";
    print FILE "|-\n";
    print FILE writedate();
    print FILE "|-\n";
    print FILE writesections();
    print FILE "|-}\n";
    close(FILE);
}

#open (FILE, "> $myfile") || die "Couldn't open $myfile: $!\n";
#print FILE writepage();
#close (FILE);

writepage();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:23:55+00:00Added an answer on June 15, 2026 at 10:23 am

    You should be using lexical file handles. This will make this task trivial. It’s also the preferred way to handle file handles in general. Here’s an example:

    sub mysub {
        open my $fh, '>>', $outfile or die "Problem opening $outfile\n";
        print $fh "Some string\n";
        anotherSub($fh);
        close $fh;
    }
    
    sub anotherSub {
        my $fh = shift;
        print $fh "A second string\n";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a perl script that's reading an INI file like this: [placeholder_title] Hostname
I'm converting a classified ad/flat file perl script to use mysql/dbi; I have this
I have this Perl script sitting in the cgi-bin folder of my Apache server:
I have this conditional in a perl script: if ($lnFea =~ m/^(\d+) qid\:([^\s]+).*?\#docid =
I have one shell script opening a perl script. This perl script should be
I have this script: #!/var/home/cherry/opt/perl use Test::More; use DBI; use Test::mysqld; use Data::Dumper; my
I have this script, works ok: #!/usr/bin/perl $key = pack(H*,3cb37efae7f4f376ebbd76cd); $str = &4\=80CHB'; $dec
I have a Perl script, that's supposed to match this string: Sometimes, he says
I have a working perl script that grabs the data I need and displays
This problem is really puzzling to me: I have the following script working on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.