No Print output

Discussion in 'Perl Misc' started by William, Dec 3, 2005.

  1. William

    William Guest

    my objective is to get the "desk" using the CGI script accmgr.

    in display.pl:

    61 $desk='/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk';
    62 print $desk;

    in accmgr:
    71 elsif ($ACTION eq "getDesk") {
    72 $STATUS_MSG=getDesk();
    73 }

    553 # get the desk from user.cfg and return this desk to display.pl to
    show/hide radio buttons
    554 sub getDesk{
    555 return $USERS{$Group};
    556 }



    my question: why is there no print outout on line 62 of display.pl?
    i.e. print $desk;
    William, Dec 3, 2005
    #1
    1. Advertising

  2. William wrote:
    > my objective is to get the "desk" using the CGI script accmgr.
    >
    > in display.pl:
    >
    > 61 $desk='/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk';
    > 62 print $desk;
    >
    > in accmgr:
    > 71 elsif ($ACTION eq "getDesk") {
    > 72 $STATUS_MSG=getDesk();
    > 73 }
    >
    > 553 # get the desk from user.cfg and return this desk to display.pl to
    > show/hide radio buttons
    > 554 sub getDesk{
    > 555 return $USERS{$Group};
    > 556 }
    >
    >
    >
    > my question: why is there no print outout on line 62 of display.pl?
    > i.e. print $desk;


    Because of the error on line 139.

    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Dec 3, 2005
    #2
    1. Advertising

  3. William <> writes:

    > my objective is to get the "desk" using the CGI script accmgr.


    Never heard of it.

    > in display.pl:
    >
    > 61 $desk='/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk';
    > 62 print $desk;


    Okay.

    > in accmgr:
    > 71 elsif ($ACTION eq "getDesk") {
    > 72 $STATUS_MSG=getDesk();
    > 73 }


    How is that related to what's in display.pl?

    > 553 # get the desk from user.cfg and return this desk to display.pl to
    > show/hide radio buttons
    > 554 sub getDesk{
    > 555 return $USERS{$Group};
    > 556 }


    Once again... how is that related?

    > my question: why is there no print outout on line 62 of display.pl?


    There *is* output printed there. $desk is assigned a literal value, so
    there's no possibility of it being empty.

    What's happening to that output after it's printed is an option question,
    and impossible to determine from the tiny snippets of code you've given
    us to work with.

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
    Sherm Pendley, Dec 3, 2005
    #3
  4. William

    William Guest

    >> > in accmgr:
    > > 71 elsif ($ACTION eq "getDesk") {
    > > 72 $STATUS_MSG=getDesk();
    > > 73 }

    >
    > How is that related to what's in display.pl?


    in display.pl, i am calling accmgr with the action of "getDesk", which
    runs the elsif on line 71.


    accmgr:
    > > 553 # get the desk from user.cfg and return this desk to

    display.pl to
    > > show/hide radio buttons
    > > 554 sub getDesk{
    > > 555 return $USERS{$Group};
    > > 556 }

    > Once again... how is that related?


    line 72 of accmgr calls getDesk of accmgr (line 554-556), then returns the
    value to line 61 of display.pl.

    but in line 62 of display.pl, nothing gets printed.

    WHY?



    On Sat, 3 Dec 2005, Sherm Pendley wrote:

    > William <> writes:
    >
    > > my objective is to get the "desk" using the CGI script accmgr.

    >
    > Never heard of it.
    >
    > > in display.pl:
    > >
    > > 61 $desk='/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk';
    > > 62 print $desk;

    >
    > Okay.
    >
    > > in accmgr:
    > > 71 elsif ($ACTION eq "getDesk") {
    > > 72 $STATUS_MSG=getDesk();
    > > 73 }

    >
    > How is that related to what's in display.pl?
    >
    > > 553 # get the desk from user.cfg and return this desk to display.pl to
    > > show/hide radio buttons
    > > 554 sub getDesk{
    > > 555 return $USERS{$Group};
    > > 556 }

    >
    > Once again... how is that related?
    >
    > > my question: why is there no print outout on line 62 of display.pl?

    >
    > There *is* output printed there. $desk is assigned a literal value, so
    > there's no possibility of it being empty.
    >
    > What's happening to that output after it's printed is an option question,
    > and impossible to determine from the tiny snippets of code you've given
    > us to work with.
    >
    > sherm--
    >
    > --
    > Cocoa programming in Perl: http://camelbones.sourceforge.net
    > Hire me! My resume: http://www.dot-app.org
    >
    William, Dec 4, 2005
    #4
  5. William

    Dr.Ruud Guest

    William schreef:

    > 61 $desk='/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk';
    > 62 print $desk;
    >
    > my question: why is there no print outout on line 62 of display.pl?
    > i.e. print $desk;


    Is there a select-call active?
    perldoc -f select

    --
    Affijn, Ruud

    "Gewoon is een tijger."
    Dr.Ruud, Dec 4, 2005
    #5
  6. William <> writes:

    > but in line 62 of display.pl, nothing gets printed.
    >
    > WHY?


    As I said before, it's:

    >> impossible to determine from the tiny snippets of code you've given
    >> us to work with.


    Have you read the posting guidelines that appear here frequently? They
    suggest posting the smallest *working* example that *illustrates* the
    problem. You haven't done that. You've simply copied some lines that may
    or may not be relevant, out of a script you're assuming everyone here is
    familiar with.

    No one here can help you, unless you help us help you.

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
    Sherm Pendley, Dec 4, 2005
    #6
  7. William

    William Guest

    to illustrate display.pl:

    1 #!/usr/bin/perl
    2
    3 require "../accmgr";
    4
    5 use Sys::Hostname;
    6 use File::Basename;
    7 use File::stat;
    8 use Time::localtime;
    9 use CGI;
    10 use CGI::Carp qw(fatalsToBrowser);
    11
    12 print "Content-type: text/html\n\n";
    13 print "<html><title>Form Upload</title><body>\n";
    14
    15
    16 $file = "/mkapp/webapps/mxrt/html/upload_repo.html";
    17
    18 open(IN, "$file");
    19 @lines = <IN>;
    20 close(IN);
    21
    22 print @lines;
    23
    24 # need to get accmgr to pass the userid's desk back to this file
    25 $desk='/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk';
    26 print $desk;
    27
    28 ############ use $desk to dynamically generate the set of radio
    buttons
    29 # loop thru $file
    30 # if <IN> = <input type="radio" name="desk"
    value="BO"> BO
    31 # compare value to (e.g. $desk ?= BO )
    32 # if not match, skip this line
    33 # if match, print this line
    34
    35 print "</body></html>";

    accmgr:


    #!/usr/bin/perl

    # accmgr
    #
    # The script manages the access (login/passwords/ACL) to define which
    users
    # have access to what functionality. In addition, it supports self
    # registration and password changes.

    require "./mxrt_vars.pl";
    require "./mxrt_auth.pl";
    require "/mkapp/webapps/mxrt-cgi/dbConn.pl";


    use File::stat;
    use File::Basename;
    use Time::Local;
    #use Time::localtime;
    use CGI;
    use CGI::Carp qw(fatalsToBrowser);

    my $query = new CGI;

    @GROUPS = qw(BO FO LFO SYS);


    sub loadUserCfg {
    $USERCFG_MTIME = stat($MXUSERCFGFILE)->mtime;

    open(USERCFGFILE, "<$MXUSERCFGFILE") or
    return "Unable to access User config file:".$MXUSERCFGFILE."<br>
    Please try again later.";

    %USERS = ();
    undef @USER_DETAIL_KEYS;
    undef @USER_DETAIL_VALS;
    while (<USERCFGFILE>) {
    chomp; # no newline
    s/#.*//; # no comments
    s/^\s+//; # no leading white
    s/\s+$//; # no trailing white
    next unless length; # anything left?
    my ($var, $value) = split(/\s*=\s*/, $_, 2);
    if ($var eq "UserID") {
    # this is the header definitions
    @USER_DETAIL_KEYS = split(':', $value);
    #print "@USER_DETAIL_KEYS"."<br>";
    }
    else {
    @USER_DETAIL_VALS = split(':', $value);
    #print "@USER_DETAIL_VALS"."<br>";
    my $count=0;
    foreach $key (@USER_DETAIL_KEYS) {
    $USERS{$var}{$key} = $USER_DETAIL_VALS[$count++];
    }
    }
    }
    close USERCFGFILE;

    #foreach $user (keys %USERS) {
    # foreach $key (@USER_DETAIL_KEYS) {
    # print $user, $key, $USERS{$user}{$key}, "<br>";
    # }
    #}

    return "";
    }


    # get the desk from user.cfg and return this desk to display.pl to
    show/hide radio buttons
    sub getDesk{
    return $USERS{$Group}; # $Group is one of {BO FO LFO SYS}
    }



    On Sat, 3 Dec 2005, William wrote:

    > >> > in accmgr:
    > > > 71 elsif ($ACTION eq "getDesk") {
    > > > 72 $STATUS_MSG=getDesk();
    > > > 73 }

    > >
    > > How is that related to what's in display.pl?

    >
    > in display.pl, i am calling accmgr with the action of "getDesk", which
    > runs the elsif on line 71.
    >
    >
    > accmgr:
    > > > 553 # get the desk from user.cfg and return this desk to

    > display.pl to
    > > > show/hide radio buttons
    > > > 554 sub getDesk{
    > > > 555 return $USERS{$Group};
    > > > 556 }

    > > Once again... how is that related?

    >
    > line 72 of accmgr calls getDesk of accmgr (line 554-556), then returns the
    > value to line 61 of display.pl.
    >
    > but in line 62 of display.pl, nothing gets printed.
    >
    > WHY?
    >
    >
    >
    > On Sat, 3 Dec 2005, Sherm Pendley wrote:
    >
    > > William <> writes:
    > >
    > > > my objective is to get the "desk" using the CGI script accmgr.

    > >
    > > Never heard of it.
    > >
    > > > in display.pl:
    > > >
    > > > 61 $desk='/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk';
    > > > 62 print $desk;

    > >
    > > Okay.
    > >
    > > > in accmgr:
    > > > 71 elsif ($ACTION eq "getDesk") {
    > > > 72 $STATUS_MSG=getDesk();
    > > > 73 }

    > >
    > > How is that related to what's in display.pl?
    > >
    > > > 553 # get the desk from user.cfg and return this desk to display.pl to
    > > > show/hide radio buttons
    > > > 554 sub getDesk{
    > > > 555 return $USERS{$Group};
    > > > 556 }

    > >
    > > Once again... how is that related?
    > >
    > > > my question: why is there no print outout on line 62 of display.pl?

    > >
    > > There *is* output printed there. $desk is assigned a literal value, so
    > > there's no possibility of it being empty.
    > >
    > > What's happening to that output after it's printed is an option question,
    > > and impossible to determine from the tiny snippets of code you've given
    > > us to work with.
    > >
    > > sherm--
    > >
    > > --
    > > Cocoa programming in Perl: http://camelbones.sourceforge.net
    > > Hire me! My resume: http://www.dot-app.org
    > >

    >
    William, Dec 4, 2005
    #7
  8. William

    William Guest

    I added
    select STDOUT;
    print $desk;

    but still no output.


    On Sun, 4 Dec 2005, Dr.Ruud wrote:

    > William schreef:
    >
    > > 61 $desk='/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk';
    > > 62 print $desk;
    > >
    > > my question: why is there no print outout on line 62 of display.pl?
    > > i.e. print $desk;

    >
    > Is there a select-call active?
    > perldoc -f select
    >
    > --
    > Affijn, Ruud
    >
    > "Gewoon is een tijger."
    >
    William, Dec 4, 2005
    #8
  9. William <> writes:

    Upside-down - please stop that. Haven't you read the posting guidelines yet?

    > to illustrate display.pl:


    What's up with the line numbers? This is Perl, not BASIC.

    >
    > 1 #!/usr/bin/perl


    Always ask Perl for as much help as it can give you.

    use strict;
    use warnings;

    These should appear first, so the CGI::Carp will be able to tell you if
    one of the other uses or requires fails.

    > 9 use CGI;
    > 10 use CGI::Carp qw(fatalsToBrowser);


    > 2
    > 3 require "../accmgr";
    > 4
    > 5 use Sys::Hostname;
    > 6 use File::Basename;
    > 7 use File::stat;
    > 8 use Time::localtime;
    > 11
    > 12 print "Content-type: text/html\n\n";
    > 13 print "<html><title>Form Upload</title><body>\n";
    > 14
    > 15
    > 16 $file = "/mkapp/webapps/mxrt/html/upload_repo.html";
    > 17
    > 18 open(IN, "$file");


    # Always - yes, *ALWAYS* check the return value of open()
    # Also, quoting $file is unnecessary here - see "perldoc -q always"

    open(IN, $file) or die "Could not open $file: $!";

    > 19 @lines = <IN>;
    > 20 close(IN);
    > 21
    > 22 print @lines;
    > 23
    > 24 # need to get accmgr to pass the userid's desk back to this file
    > 25 $desk='/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk';


    This will print the string you've assigned to $desk above. Is it printing
    something else? Did you *expect* it to print something else? If so, what
    did you expect it to print?

    Use your browser's "view source" function to view what's actually being
    printed - if there is broken and/or missing HTML markup, there could be
    text that your browser isn't showing you.

    I *think* what you might be expecting is a call to the getDesk() function
    that's found in accmgr - if that's the case, then you're *way* off track,
    and you need to have a look at:

    perldoc -f require
    perldoc perlsub
    perldoc perlmod

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
    Sherm Pendley, Dec 4, 2005
    #9
  10. William

    Joe Smith Guest

    William wrote:

    > 25 $desk='/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk';
    > 26 print $desk;


    Do you understand the distinction between

    $desk='/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk';

    and

    $desk=`/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk`;

    ? And are you aware that one CGI program cannot call another
    CGI program using the syntax you're using?

    It appears that you are under the mistaken impression that
    a perl script treats URLs the same way that a browser does.

    For URLs pointing to an external server, use LWP::Simple.
    For CGI scripts running on the same server as the perl script,
    you have to set up the right environment before executing
    the second script, and use either backticks or pipe to read
    the results.

    -Joe
    Joe Smith, Dec 4, 2005
    #10
  11. William

    Joe Smith Guest

    William wrote:

    > but still no output.
    >
    >>> 61 $desk='/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk';
    >>> 62 print $desk;


    Are you sure that line 61 is being executed?

    Have you tried setting $| or adding "\n" to the output?

    -Joe
    Joe Smith, Dec 4, 2005
    #11
  12. William

    William Guest

    I have modified the syntax to the following:
    #!/usr/bin/perl

    require "../accmgr";

    # need to get accmgr to pass the userid's desk back to this file
    $desk = getDesk();
    print $desk;


    where getDesk() is in accmgr:

    554 sub getDesk{
    555 return $USERS{$Group};
    556 }

    Still, $USERS{$Group} is not being printed for print $desk

    I did set up the environment before running the CGI script.



    On Sun, 4 Dec 2005, Joe Smith wrote:

    > William wrote:
    >
    > > 25 $desk='/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk';
    > > 26 print $desk;

    >
    > Do you understand the distinction between
    >
    > $desk='/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk';
    >
    > and
    >
    > $desk=`/mkapp/webapps/mxrt-cgi/accmgr?action=getDesk`;
    >
    > ? And are you aware that one CGI program cannot call another
    > CGI program using the syntax you're using?
    >
    > It appears that you are under the mistaken impression that
    > a perl script treats URLs the same way that a browser does.
    >
    > For URLs pointing to an external server, use LWP::Simple.
    > For CGI scripts running on the same server as the perl script,
    > you have to set up the right environment before executing
    > the second script, and use either backticks or pipe to read
    > the results.
    >
    > -Joe
    >
    William, Dec 6, 2005
    #12
  13. William

    Paul Lalli Guest

    William wrote:
    > I have modified the syntax to the following:


    You've modified *what* syntax? Please quote enough of the thread so we
    know what you're talking about.

    > #!/usr/bin/perl


    You have forgotten
    use strict;
    and
    use warnings;

    > require "../accmgr";
    >
    > # need to get accmgr to pass the userid's desk back to this file
    > $desk = getDesk();
    > print $desk;
    >
    >
    > where getDesk() is in accmgr:
    >
    > 554 sub getDesk{
    > 555 return $USERS{$Group};
    > 556 }
    >
    > Still, $USERS{$Group} is not being printed for print $desk


    Where is %USERS defined? Where is $Group defined?

    > I did set up the environment before running the CGI script.


    How, exactly? Are you assuming your CGI script is run with the same
    environment as your local account?

    Have you read the posting guidelines for this group? They are posted
    here twice a week. Among other good advice, they tell you you should
    post a SHORT but COMPLETE script that illustrates your problem.

    Paul Lalli
    Paul Lalli, Dec 6, 2005
    #13
  14. William

    William Guest

    More details:

    #!/usr/bin/perl
    use strict;
    use warnings;

    require "../accmgr";

    # need to get accmgr to pass the userid's desk back to this file
    $desk = getDesk();
    print $desk;

    $USERS is defined in the following:
    257 sub loadUserCfg {
    258 $USERCFG_MTIME = stat($MXUSERCFGFILE)->mtime;
    259
    260 open(USERCFGFILE, "<$MXUSERCFGFILE") or
    261 return "Unable to access User config
    file:".$MXUSERCFGFILE."<br> Please try again later.";
    262
    263 %USERS = ();
    264 undef @USER_DETAIL_KEYS;
    265 undef @USER_DETAIL_VALS;
    266 while (<USERCFGFILE>) {
    267 chomp; # no newline
    268 s/#.*//; # no comments
    269 s/^\s+//; # no leading white
    270 s/\s+$//; # no trailing white
    271 next unless length; # anything left?
    272 my ($var, $value) = split(/\s*=\s*/, $_, 2);
    273 if ($var eq "UserID") {
    274 # this is the header definitions
    275 @USER_DETAIL_KEYS = split(':', $value);
    276 #print "@USER_DETAIL_KEYS"."<br>";
    277 }
    278 else {
    279 @USER_DETAIL_VALS = split(':', $value);
    280 #print "@USER_DETAIL_VALS"."<br>";
    281 my $count=0;
    282 foreach $key (@USER_DETAIL_KEYS) {
    283 $USERS{$var}{$key} = $USER_DETAIL_VALS[$count++];
    284 }
    285 }
    286 }
    287 close USERCFGFILE;
    288
    289 #foreach $user (keys %USERS) {
    290 # foreach $key (@USER_DETAIL_KEYS) {
    291 # print $user, $key, $USERS{$user}{$key}, "<br>";
    292 # }
    293 #}
    294
    295 return "";
    296 }

    Groups are defined in the following:
    49 @GROUPS = qw(BO FO LFO SYS);



    On Tue, 6 Dec 2005, Paul Lalli wrote:

    > William wrote:
    > > I have modified the syntax to the following:

    >
    > You've modified *what* syntax? Please quote enough of the thread so we
    > know what you're talking about.
    >
    > > #!/usr/bin/perl

    >
    > You have forgotten
    > use strict;
    > and
    > use warnings;
    >
    > > require "../accmgr";
    > >
    > > # need to get accmgr to pass the userid's desk back to this file
    > > $desk = getDesk();
    > > print $desk;
    > >
    > >
    > > where getDesk() is in accmgr:
    > >
    > > 554 sub getDesk{
    > > 555 return $USERS{$Group};
    > > 556 }
    > >
    > > Still, $USERS{$Group} is not being printed for print $desk

    >
    > Where is %USERS defined? Where is $Group defined?
    >
    > > I did set up the environment before running the CGI script.

    >
    > How, exactly? Are you assuming your CGI script is run with the same
    > environment as your local account?
    >
    > Have you read the posting guidelines for this group? They are posted
    > here twice a week. Among other good advice, they tell you you should
    > post a SHORT but COMPLETE script that illustrates your problem.
    >
    > Paul Lalli
    >
    >
    William, Dec 6, 2005
    #14
  15. William

    Brian Wakem Guest

    William wrote:

    > 554 sub getDesk{
    > 555 return $USERS{$Group};
    > 556 }
    >
    > Still, $USERS{$Group} is not being printed for print $desk


    > Paul Lalli wrote:


    > Where is %USERS defined? Where is $Group defined?


    William wrote:

    > $USERS is defined in the following:
    > 257 sub loadUserCfg {
    > 258 $USERCFG_MTIME = stat($MXUSERCFGFILE)->mtime;
    > 259
    > 260 open(USERCFGFILE, "<$MXUSERCFGFILE") or
    > 261 return "Unable to access User config
    > file:".$MXUSERCFGFILE."<br> Please try again later.";
    > 262
    > 263 %USERS = ();
    > Groups are defined in the following:
    > 49 @GROUPS = qw(BO FO LFO SYS);



    So $Groups is never defined, hence $USERS{$Group} is not defined, so trying
    to print it prints nothing.



    --
    Brian Wakem
    Email: http://homepage.ntlworld.com/b.wakem/myemail.png
    Brian Wakem, Dec 6, 2005
    #15
  16. William

    Brian Wakem Guest

    Brian Wakem, Dec 6, 2005
    #16
  17. William

    William Guest

    On Tue, 6 Dec 2005, Brian Wakem wrote:

    > William wrote:
    >
    > > 554 sub getDesk{
    > > 555 return $USERS{$Group};
    > > 556 }
    > >
    > > Still, $USERS{$Group} is not being printed for print $desk

    >
    > > Paul Lalli wrote:

    >
    > > Where is %USERS defined? Where is $Group defined?

    >
    > William wrote:
    >
    > > $USERS is defined in the following:
    > > 257 sub loadUserCfg {
    > > 258 $USERCFG_MTIME = stat($MXUSERCFGFILE)->mtime;
    > > 259
    > > 260 open(USERCFGFILE, "<$MXUSERCFGFILE") or
    > > 261 return "Unable to access User config
    > > file:".$MXUSERCFGFILE."<br> Please try again later.";
    > > 262
    > > 263 %USERS = ();
    > > Groups are defined in the following:
    > > 49 @GROUPS = qw(BO FO LFO SYS);

    >
    >
    > So $Groups is never defined, hence $USERS{$Group} is not defined, so trying
    > to print it prints nothing.


    I have modified my code as follows:

    in accmgr:

    26 $USERID="AULC2";

    565 sub getDesk() {
    571 return $USERS{$USERID}{"Group"}; # $key=BO/FO/LFO/;
    572 }

    $USERS is filled out in the following subroutine:

    258 sub loadUserCfg {
    259 $USERCFG_MTIME = stat($MXUSERCFGFILE)->mtime;
    260
    261 open(USERCFGFILE, "<$MXUSERCFGFILE") or
    262 return "Unable to access User config
    file:".$MXUSERCFGFILE."<br> Please try again later.";
    263
    264 %USERS = ();
    265 undef @USER_DETAIL_KEYS;
    266 undef @USER_DETAIL_VALS;
    267 while (<USERCFGFILE>) {
    268 chomp; # no newline
    269 s/#.*//; # no comments
    270 s/^\s+//; # no leading white
    271 s/\s+$//; # no trailing white
    272 next unless length; # anything left?
    273 my ($var, $value) = split(/\s*=\s*/, $_, 2);
    274 if ($var eq "UserID") {
    275 # this is the header definitions
    276 @USER_DETAIL_KEYS = split(':', $value);
    277 #print "@USER_DETAIL_KEYS"."<br>";
    278 }
    279 else {
    280 @USER_DETAIL_VALS = split(':', $value);
    281 #print "@USER_DETAIL_VALS"."<br>";
    282 my $count=0;
    283 foreach $key (@USER_DETAIL_KEYS) {
    284 $USERS{$var}{$key} = $USER_DETAIL_VALS[$count++];
    285 if ( $key eq "Group" && $var eq $USERID )
    286 {
    287 print $USERS{$var}{$key}; # prints BO
    288 print "\n";
    289 # print $var;
    290 # print "\n";
    291 # print $key;
    292 # print "\n";
    293 }
    294 }
    295 }
    296 }
    297 close USERCFGFILE;
    298
    299 #foreach $user (keys %USERS) {
    300 # foreach $key (@USER_DETAIL_KEYS) {
    301 # print $user, $key, $USERS{$user}{$key}, "<br>";
    302 # }
    303 #}
    304
    305 return "";
    306 }


    in display.pl:

    #!/usr/bin/perl
    use strict;
    use warnings;

    require "../accmgr";

    # need to get accmgr to pass the userid's desk back to this file
    $desk = getDesk;
    print $desk;

    problem: "print $desk;" gives no output
    expected output: BO (see line 287 of display.pl as above)

    I am basically trying to call accmgr::getDesk() from display.pl, to fill
    the $desk in display.pl.

    I have read:
    perldoc -f perlsub
    perldoc -f require

    perldoc -q subroutine

    but couldn't solve the "no output" problem.
    William, Dec 7, 2005
    #17
  18. William

    Brian Wakem Guest

    William wrote:

    > # need to get accmgr to pass the userid's desk back to this file
    > $desk = getDesk;
    > print $desk;



    Bareword "getdesk" not allowed while "strict subs" in use at -e line 1.

    Let perl help you find the errors.


    --
    Brian Wakem
    Email: http://homepage.ntlworld.com/b.wakem/myemail.png
    Brian Wakem, Dec 7, 2005
    #18
  19. William

    William Guest

    On Wed, 7 Dec 2005, Brian Wakem wrote:

    > William wrote:
    >
    > > # need to get accmgr to pass the userid's desk back to this file
    > > $desk = getDesk;
    > > print $desk;

    >
    >
    > Bareword "getdesk" not allowed while "strict subs" in use at -e line 1.
    >
    > Let perl help you find the errors.


    Global symbol "$desk" requires explicit package name at ./test.pl line 8.
    Execution of ./test.pl aborted due to compilation errors.

    what explicit package do i need?

    - i already checked perldoc -q package

    >
    >
    > --
    > Brian Wakem
    > Email: http://homepage.ntlworld.com/b.wakem/myemail.png
    >
    William, Dec 7, 2005
    #19
  20. William

    William Guest

    On Wed, 7 Dec 2005, William wrote:

    >
    >
    > On Wed, 7 Dec 2005, Brian Wakem wrote:
    >
    > > William wrote:
    > >
    > > > # need to get accmgr to pass the userid's desk back to this file
    > > > $desk = getDesk;
    > > > print $desk;

    > >
    > >

    Brian wrote:
    > > Bareword "getdesk" not allowed while "strict subs" in use at -e line 1.
    > >
    > > Let perl help you find the errors.

    >


    William wrote:
    > Global symbol "$desk" requires explicit package name at ./test.pl line 8.
    > Execution of ./test.pl aborted due to compilation errors.
    >
    > what explicit package do i need?
    >
    > - i already checked perldoc -q package


    background and source code:
    in accmgr:

    26 $USERID="AULC2";

    565 sub getDesk() {
    571 return $USERS{$USERID}{"Group"}; # $key=BO/FO/LFO/;
    572 }

    $USERS is filled out in the following subroutine:

    258 sub loadUserCfg {
    259 $USERCFG_MTIME = stat($MXUSERCFGFILE)->mtime;
    260
    261 open(USERCFGFILE, "<$MXUSERCFGFILE") or
    262 return "Unable to access User config
    file:".$MXUSERCFGFILE."<br> Please try again later.";
    263
    264 %USERS = ();
    265 undef @USER_DETAIL_KEYS;
    266 undef @USER_DETAIL_VALS;
    267 while (<USERCFGFILE>) {
    268 chomp; # no newline
    269 s/#.*//; # no comments
    270 s/^\s+//; # no leading white
    271 s/\s+$//; # no trailing white
    272 next unless length; # anything left?
    273 my ($var, $value) = split(/\s*=\s*/, $_, 2);
    274 if ($var eq "UserID") {
    275 # this is the header definitions
    276 @USER_DETAIL_KEYS = split(':', $value);
    277 #print "@USER_DETAIL_KEYS"."<br>";
    278 }
    279 else {
    280 @USER_DETAIL_VALS = split(':', $value);
    281 #print "@USER_DETAIL_VALS"."<br>";
    282 my $count=0;
    283 foreach $key (@USER_DETAIL_KEYS) {
    284 $USERS{$var}{$key} = $USER_DETAIL_VALS[$count++];
    285 if ( $key eq "Group" && $var eq $USERID )
    286 {
    287 print $USERS{$var}{$key}; # prints BO
    288 print "\n";
    289 # print $var;
    290 # print "\n";
    291 # print $key;
    292 # print "\n";
    293 }
    294 }
    295 }
    296 }
    297 close USERCFGFILE;
    298
    299 #foreach $user (keys %USERS) {
    300 # foreach $key (@USER_DETAIL_KEYS) {
    301 # print $user, $key, $USERS{$user}{$key}, "<br>";
    302 # }
    303 #}
    304
    305 return "";
    306 }


    in display.pl:

    #!/usr/bin/perl
    use strict;
    use warnings;

    require "../accmgr";

    # need to get accmgr to pass the userid's desk back to this file
    $desk = getDesk;
    print $desk;

    problem: "print $desk;" gives no output
    expected output: BO (see line 287 of display.pl as above)

    I am basically trying to call accmgr::getDesk() from display.pl, to fill
    the $desk in display.pl.

    I have read:
    perldoc -f perlsub
    perldoc -f require

    perldoc -q subroutine

    but couldn't solve the "no output" problem.
    William, Dec 7, 2005
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bad_Kid
    Replies:
    3
    Views:
    3,933
    Shawn H. Mesiatowsky
    Apr 7, 2005
  2. Bryan Shaw

    Lock Print Screen and File Print

    Bryan Shaw, Apr 19, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    3,933
    Kevin Spencer
    Apr 20, 2005
  3. keto
    Replies:
    0
    Views:
    898
  4. Lew
    Replies:
    0
    Views:
    626
  5. David Cournapeau

    print a vs print '%s' % a vs print '%f' a

    David Cournapeau, Dec 30, 2008, in forum: Python
    Replies:
    0
    Views:
    335
    David Cournapeau
    Dec 30, 2008
Loading...

Share This Page