Subversion Repositories DevTools

Rev

Rev 263 | Rev 283 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
########################################################################
279 dpurdie 2
# Copyright ( C ) 2004-2009 ERG Limited, All rights reserved
227 dpurdie 3
#
279 dpurdie 4
# Module name   : JatsError
227 dpurdie 5
# Module type   : Perl Package
279 dpurdie 6
# Compiler(s)   : Perl
227 dpurdie 7
# Environment(s): jats
8
#
9
# Description   : A Perl Package to perform error handling within JATS
10
#
11
#                 Uses global variables
12
#                       $::ScmWho;
13
#                       $::ScmVerbose;
14
#                       $::ScmQuiet;
15
#                       $::ScmDebug;
16
#                 For use with existing scripts
17
#
18
#
19
#......................................................................#
20
 
255 dpurdie 21
require 5.006_001;
227 dpurdie 22
use strict;
23
use warnings;
24
use Data::Dumper;
25
use IO::Handle;
26
 
27
package JatsError;
28
 
29
#-------------------------------------------------------------------------------
30
# Function        : BEGIN
31
#
32
# Description     : Standard Package Interface
33
#
34
# Inputs          :
35
#
36
# Returns         :
37
#
38
 
39
BEGIN {
40
    use Exporter   ();
41
    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
42
 
43
    # set the version for version checking
44
    $VERSION     = 1.00;
45
 
46
    @ISA         = qw(Exporter);
279 dpurdie 47
    @EXPORT      = qw(ErrorConfig ErrorReConfig ErrorDoExit
261 dpurdie 48
                      ReportError Fatal Error Warning
227 dpurdie 49
                      Message Message1
50
                      Information Information1
51
                      Question
263 dpurdie 52
                      Verbose0 Verbose Verbose2 Verbose3
227 dpurdie 53
                      Debug0 Debug Debug2 Debug3
54
                      IsVerbose IsDebug IsQuiet
231 dpurdie 55
                      DebugDumpData DebugDumpPackage DebugTraceBack
227 dpurdie 56
                      DebugPush DebugPop
57
                      );
58
 
59
    %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
60
 
61
    # your exported package globals go here,
62
    # as well as any optionally exported functions
63
    @EXPORT_OK   = qw();
64
 
65
    #
66
    #   Ensure globals have a defined value
67
    #
263 dpurdie 68
    $::ScmWho = ''                          unless defined( $::ScmWho );
69
    $::ScmVerbose = $ENV{GBE_VERBOSE} || 0  unless defined( $::ScmVerbose );
70
    $::ScmDebug = $ENV{GBE_DEBUG} || 0      unless defined( $::ScmDebug );
71
    $::ScmQuiet = 0                         unless defined( $::ScmQuiet );
227 dpurdie 72
 
73
    #
74
    #   Force autoflush in an attempt to limit the intermingling of
75
    #   Error and non-error output.
76
    #
77
    STDOUT->autoflush(1);
78
    STDERR->autoflush(1);
79
}
80
 
81
 
82
 
83
# exported package globals go here
84
#our $ScmWho;
85
#our $ScmVerbose;
86
#our $ScmDebug;
279 dpurdie 87
#our $ScmQuiet;
227 dpurdie 88
our $ScmOnExit;
89
our $ScmDelayExit;
90
our $ScmErrorCount;
261 dpurdie 91
our $ScmExitCode;
227 dpurdie 92
 
93
# non-exported package globals go here
94
$ScmErrorCount = 0;
261 dpurdie 95
$ScmExitCode = 1;
227 dpurdie 96
 
279 dpurdie 97
my $EName = '';
98
my $EFn = '';
99
 
227 dpurdie 100
#  initialize package globals, first exported ones
101
 
102
 
103
#-------------------------------------------------------------------------------
104
# Function        : import
105
#
106
# Description     : Package import function
279 dpurdie 107
#                   This function will examine arguments provided in the
227 dpurdie 108
#                   invoking 'uses' list and will configure the package
109
#                   accordingly.
110
#
111
# Inputs          : $pack           - Name of this package
112
#                   @vars           - User Config Options
113
#                   Config Options:
114
#                       :name=xxxx
279 dpurdie 115
#                       :function=xxxx
227 dpurdie 116
#                       :quiet=xxx
117
#                       :debug=xxx
118
#                       :verbose=xxx
119
#                       :delay_exit=xxx
120
#
121
# Returns         : 
122
#
123
sub import {
124
    my $pack = shift;
125
    my @vars;
126
    my @config;
127
 
128
    #
129
    #   Extract options of the form: :name=value and pass them to the
130
    #   ErrorConfig function. All other arguments will be passed to the
131
    #
132
    foreach ( @_ )
133
    {
134
        if ( m/^:(.+)=(.+)/ ) {
135
            push @config, $1, $2;
136
        } else {
137
            push @vars, $_;
138
        }
139
    }
140
 
141
    ErrorConfig( @config )
142
        if ( @config );
143
 
144
    #
145
    #   Invoke Exporter function to handle the arguments that I don't understand
146
    #
147
    $pack->export_to_level(1, $pack , @vars);
148
}
149
 
150
#-------------------------------------------------------------------------------
151
# Function        : ErrorConfig
152
#
153
# Description     : Configure aspects of the JATS error handle
279 dpurdie 154
#                   See ErrorReConfig
227 dpurdie 155
#
156
# Inputs          : A hash of option,value pairs
157
#                   Valid options
158
#                       name        - Name to report in error
279 dpurdie 159
#                       function    - Name of enclosing function
227 dpurdie 160
#                       verbose     - vebosity level
161
#                       debug       - debug level
162
#                       on_exit     - Register on-exit function
163
#                       delay_exit  - Delay exit on error
164
#
165
# Returns         :
166
#
167
sub ErrorConfig
168
{
169
    my %args = @_;
170
 
171
    while (my($key, $value) = each %args)
172
    {
173
        if (       $key =~ /^name/ ) {
279 dpurdie 174
            $EName = $value;
227 dpurdie 175
 
279 dpurdie 176
        } elsif ( $key =~ /^function/ ) {
177
            $EFn = ':' . $value;
178
 
227 dpurdie 179
        } elsif ( $key =~ /^debug/ ) {
279 dpurdie 180
            $::ScmDebug = $value
181
                if ( defined $value && $value > $::ScmDebug  );
227 dpurdie 182
 
183
        } elsif ( $key =~ /^verbose/ ) {
279 dpurdie 184
            $::ScmVerbose = $value
185
                if ( defined $value && $value > $::ScmVerbose  );
227 dpurdie 186
 
187
        } elsif ( $key =~ /^quiet/ ) {
188
            $::ScmQuiet = $value || 0;
189
 
190
        } elsif ( $key =~ /^on_exit/ ) {
191
            $ScmOnExit = $value;
192
 
193
        } elsif ( $key =~ /^delay_exit/ ) {
194
            $ScmDelayExit = $value;
195
 
196
        } else {
197
            Error("ErrorConfig, Unknown option: $key");
198
        }
199
    }
200
 
201
    #
279 dpurdie 202
    #   Calculate the prefix to all messages
203
    #   Based on Name and Function( if provided
204
    #
205
    $::ScmWho = "[$EName$EFn] ";
206
 
207
    #
227 dpurdie 208
    #   Extract program specfic debug flags from the environment
209
    #   These will be based on the reporting 'name'
210
    #       GBE_name_DEBUG
211
    #       GBE_name_VERBOSE
212
    #
279 dpurdie 213
    if ( $EName )
227 dpurdie 214
    {
215
        my ($value, $tag);
216
 
279 dpurdie 217
        $tag = "GBE_${EName}_DEBUG" ;
261 dpurdie 218
        $tag =~ s~\s+~~g;
227 dpurdie 219
        $value = $ENV{ $tag };
220
        if (defined $value)
221
        {
222
            $::ScmDebug = $value;
223
            Warning("Envar: $tag setting debug: $value");
224
        }
225
 
279 dpurdie 226
        $tag = "GBE_${EName}_VERBOSE" ;
261 dpurdie 227
        $tag =~ s~\s+~~g;
227 dpurdie 228
        $value = $ENV{ $tag };
229
        if (defined $value)
230
        {
231
            $::ScmVerbose = $value;
232
            Warning("Envar: $tag setting verbose: $value");
233
        }
234
    }
235
 
236
    #
237
    #   Sanitise quiet and verbose
238
    #   Any verboseness disables quiet
239
    #
240
    $::ScmQuiet = 0 if ( $::ScmVerbose );
241
    $::ScmQuiet = 0 if ( $::ScmDebug );
242
}
243
 
279 dpurdie 244
#-------------------------------------------------------------------------------
245
# Function        : ErrorReConfig
246
#
247
# Description     : Similar to ErrorConfig , except it is used to push and
248
#                   automatically pop the current state
249
#
250
#                   Intended to be used to control error reporting
251
#                   within a function. Let the class go out of scope
252
#                   at the end of the function.
253
#
254
#                   Not intended that the user hold and pass around the
255
#                   class ref as this may confuse all.
256
#
257
# Inputs          : As for ErrorConfig
258
#
259
# Returns         : Ref to a class
260
#                   When this goes out of scope the Error State will be
261
#                   restored.
262
#
263
sub ErrorReConfig
264
{
265
    #
266
    #   Create a small class to hold existing Error Information
267
    #   The error information will be restored when the handle returned to
268
    #   the user goes out of scope.
269
    #
270
    my $self;
227 dpurdie 271
 
279 dpurdie 272
    $self->{ScmWho}         =  $::ScmWho;
273
    $self->{ScmVerbose}     =  $::ScmVerbose;
274
    $self->{ScmDebug}       =  $::ScmDebug;
275
    $self->{ScmQuiet}       =  $::ScmQuiet;
276
    $self->{ScmOnExit}      =  $ScmOnExit;
277
    $self->{ScmDelayExit}   =  $ScmDelayExit;
278
    $self->{ScmErrorCount}  =  $ScmErrorCount;
279
    $self->{ScmExitCode}    =  $ScmExitCode;
280
    $self->{EName}          =  $EName;
281
    $self->{EFn}            =  $EFn;
282
 
283
    bless ($self, __PACKAGE__);
284
 
285
    #
286
    #   Invoke ErrorConfig to do the hard work
287
    #
288
    ErrorConfig (@_);
289
 
290
    #
291
    #   Return ref to stored data
292
    #
293
    return $self;
294
 
295
}
296
 
227 dpurdie 297
#-------------------------------------------------------------------------------
279 dpurdie 298
# Function        : DESTROY
299
#
300
# Description     : Called when the handle retruned by ErrorConfig goes out of
301
#                   scope.
302
#
303
#                   Restores the state of the Error Reporting information
304
#
305
# Inputs          : $self               - Created by ErrorReConfig
306
#
307
# Returns         : Nothing
308
#
309
 
310
sub DESTROY
311
{
312
    my ($self) = @_;
313
    $::ScmWho         = $self->{ScmWho};
314
    $::ScmVerbose     = $self->{ScmVerbose};
315
    $::ScmDebug       = $self->{ScmDebug};
316
    $::ScmQuiet       = $self->{ScmQuiet};
317
    $ScmOnExit        = $self->{ScmOnExit};
318
    $ScmDelayExit     = $self->{ScmDelayExit};
319
    $ScmErrorCount    = $self->{ScmErrorCount};
320
    $ScmExitCode      = $self->{ScmExitCode};
321
    $EFn              = $self->{EFn};
322
    $EName            = $self->{EName};
323
}
324
 
325
 
326
#-------------------------------------------------------------------------------
227 dpurdie 327
# Function        : Information
328
#                   Message
329
#                   Question
330
#                   Warning
331
#                   Error
332
#                   Verbose
333
#                   Debug
334
#                   _Message ( Internal use only )
335
#
336
# Description     : Error, Warning and Message routines
337
#                   These routines will display a message to the user
338
#                   with the module name.
339
#
340
#                   Multiple arguments are displayed on their own line
341
#                   with suitable spacing.
342
#
343
# Inputs          : Lines of text to display
344
#
345
# Returns         : Nothing
346
#
347
sub _Message
348
{
349
    my $tag = shift;                # First argument is a tag
350
    my $count = 0;
351
 
352
    #
353
    #   Generate the message prefix
354
    #   This will only be used on the first line
355
    #   All other lines will have a space filled prefix
356
    #
357
    my $prefix = $::ScmWho . $tag;
358
    #
359
    #   Kill the eol if the Question is being asked
360
    #
361
    my $eol = ( $tag =~ m/Q/ ) ? "" : "\n";
362
    foreach my $nextline ( @_ )
363
    {
231 dpurdie 364
        next unless ( defined $nextline );              # Ignore undefined arguments
227 dpurdie 365
        chomp( my $line = $nextline );
366
        if ( $count eq 1 )
367
        {
368
            my $bol = $eol ? "" : "\n";
369
            $prefix = $bol . ' ' x length($prefix);
370
        }
371
 
372
        print "$prefix $line$eol";
373
        $count++;
374
    }
375
}
376
 
377
#-------------------------------------------------------------------------------
378
# Function        : Information
379
#                   Information1
380
#
381
# Description     : Will display informational messages
382
#                   These are normal operational messages. These may be
383
#                   supressed through the use of QUIET options
384
#
385
# Inputs          : An array of strings to display
386
#
387
sub Information
388
{
389
    _Message '(I)', @_ unless ( $::ScmQuiet);
390
}
391
 
392
sub Information1
393
{
394
    _Message '(I)', @_ unless ( $::ScmQuiet > 1);
395
}
396
 
397
 
398
#-------------------------------------------------------------------------------
399
# Function        : Message
400
#                   Message1
401
#
402
# Description     : Same as Information, except a different prefix
403
#
404
# Inputs          : An array of strings to display
405
#
406
sub Message
407
{
408
    _Message '(M)', @_ unless ( $::ScmQuiet > 1);
409
}
410
 
411
sub Message1
412
{
413
    _Message '(M)', @_ unless ( $::ScmQuiet);
414
}
415
 
416
#-------------------------------------------------------------------------------
417
# Function        : IsQuiet
418
#
419
# Description     : Determine if an Infrmation or Message will be displayed
420
#                   May be used to reduce excessive processing that may be
421
#                   discarded
422
#
423
# Inputs          : $level      - Level to test
424
#
425
# Returns         : TRUE:       A Message at $level would be displayed
426
#
427
sub IsQuiet
428
{
429
    my( $level) = @_;
430
    return $::ScmQuiet >= $level;
431
}
432
 
433
#-------------------------------------------------------------------------------
434
# Function        : Warning
435
#
436
# Description     : Display a warning message
437
#                   These may be disabled with a high quiet level
438
#
439
# Inputs          : An array of strings to display
440
#
441
sub Warning
442
{
443
    _Message '(W)', @_ unless ( $::ScmQuiet > 2);
444
}
445
 
446
#-------------------------------------------------------------------------------
447
# Function        : Question
448
#
449
# Description     : Display a Question message
450
#                   These cannot be disabled
451
#
452
# Inputs          : An array of strings to display
453
#
454
sub Question
455
{
456
    _Message '(Q)', @_;
457
    STDERR->flush;              # Force output to be displayed
458
    STDOUT->flush;              # Force output to be displayed
459
}
460
 
461
#-------------------------------------------------------------------------------
261 dpurdie 462
# Function        : Fatal
463
#
464
# Description     : Display a multi line fatal message
465
#                   This will cause the program to exit.
466
#
467
#                   Similar to Error(), except
468
#                       Display a (F) prefix
469
#                       Alters the exit code to "2"
470
#                       Will terminate program execution.
471
#                       Will not honor delayed exit configuration.
472
#
473
#                   Fatal is to be used to indicate to consumer processes that
474
#                   the error is a function of the infrastructure and cannot be
475
#                   corrected by a user. ie:
476
#                       clearcase is not available
477
#                           Not just a bad user parameter
478
#                       dpkg_archive is not available
479
#                       release manager database is not available
480
#
481
#                   Intended to be used by build deamons to determine if building
482
#                   should continue, or if the entire build process should be
483
#                   terminated.
484
#
485
# Inputs          : An array of strings to display
486
#
487
# Returns         : May not return
488
#
489
sub Fatal
490
{
491
    _Message '(F)', @_;
492
    $ScmErrorCount++;
493
    $ScmExitCode = 2;
494
    ErrorDoExit() unless ( $ScmDelayExit );
495
}
496
 
497
#-------------------------------------------------------------------------------
227 dpurdie 498
# Function        : Error
499
#
261 dpurdie 500
# Description     : Display a multi line error message
227 dpurdie 501
#                   This may cause the program to exit, or the user may have
502
#                   configured the package to accumulate error messages
503
#
504
#                   This could be used to generate multiple error messages
505
#                   while parsing a file, and then terminate program execution at
506
#                   the end of the phase.
507
#
508
# Inputs          : An array of strings to display
509
#
510
# Returns         : May not return
511
#
512
 
513
sub Error
514
{
515
    _Message '(E)', @_;
516
    $ScmErrorCount++;
517
    ErrorDoExit() unless ( $ScmDelayExit );
518
}
519
 
520
#-------------------------------------------------------------------------------
521
# Function        : ReportError
522
#
523
# Description     : Like Error, but the error exit is delayed
524
#
525
# Inputs          : An array of strings to display
526
#
527
sub ReportError
528
{
529
    _Message '(E)', @_;
530
    $ScmErrorCount++;
531
}
532
 
533
#-------------------------------------------------------------------------------
534
# Function        : ErrorDoExit
535
#
536
# Description     : Will terminate the program if delayed error messages
537
#                   have been seen.
538
#
539
# Inputs          : None
540
#
541
# Returns         : Will return if no errors have been reported
542
#
543
 
544
sub ErrorDoExit
545
{
546
    if ( $ScmErrorCount )
547
    {
548
        #
549
        #   Prevent recusion.
550
        #   Kill error processing while doing error exit processing
551
        #
552
        if ( my $func = $ScmOnExit )
553
        {
554
            $ScmOnExit = undef;
555
            &$func();
556
        }
261 dpurdie 557
        exit $ScmExitCode;
227 dpurdie 558
    }
559
}
560
 
561
#-------------------------------------------------------------------------------
263 dpurdie 562
# Function        : ArgsToString
563
#
564
# Description     : Convert an array of arguments to a string
565
#                   Main purpose is to allow Debug and Verbose
566
#                   calls to pass undef values without causing warnings
567
#
568
# Inputs          : REF to a list of scalar values
569
#                   Passing a REF is faster
570
#
571
# Returns         : A string
572
#
573
sub ArgsToString
574
{
575
    my $result = '';
576
 
577
    $result .= (defined ($_) ? $_ : '\'undef\'') . ' ' foreach  ( @{$_[0]} );
578
    return $result;
579
}
580
 
581
#-------------------------------------------------------------------------------
582
# Function        : Verbose0
583
#                   Verbose
227 dpurdie 584
#                   Verbose2
585
#                   Verbose3
586
#
587
# Description     : Various levels of progress reporting
588
#                   By default none are displayed
589
#
590
# Inputs          : A single line string
591
#                   Multi-line output is not supported
263 dpurdie 592
#                   Arguments will be processed such that undef is handled well
227 dpurdie 593
#
263 dpurdie 594
sub Verbose0
595
{
596
    _Message '------', ArgsToString (\@_);
597
}
227 dpurdie 598
sub Verbose
599
{
263 dpurdie 600
    _Message '(V)', ArgsToString (\@_) if ($::ScmVerbose);
227 dpurdie 601
}
602
 
603
sub Verbose2
604
{
263 dpurdie 605
    _Message '(V)', ArgsToString (\@_) if ($::ScmVerbose >= 2);
227 dpurdie 606
}
607
 
608
sub Verbose3
609
{
263 dpurdie 610
    _Message '(V)', ArgsToString (\@_) if ($::ScmVerbose >= 3);
227 dpurdie 611
}
612
 
613
sub IsVerbose
614
{
615
    my( $level) = @_;
616
    return $::ScmVerbose >= $level;
617
}
618
 
619
#-------------------------------------------------------------------------------
620
# Function        : Debug
621
#                   Debug0
622
#                   Debug1
623
#                   Debug2
624
#                   Debug3
625
#
626
# Description     : Various levels of debug reporting
627
#                   By default none are displayed
628
#
629
# Inputs          : A single line string
630
#                   Multi-line output is not supported
263 dpurdie 631
#                   Arguments will be processed such that undef is handled well
227 dpurdie 632
#
633
sub Debug0
634
{
263 dpurdie 635
    _Message '------', ArgsToString (\@_);
227 dpurdie 636
}
637
 
638
sub Debug
639
{
263 dpurdie 640
    _Message '(D)', ArgsToString (\@_) if ($::ScmDebug >= 1 ) ;
227 dpurdie 641
}
642
 
643
 
644
sub Debug2
645
{
263 dpurdie 646
    _Message '(D)', ArgsToString (\@_) if ($::ScmDebug >= 2) ;
227 dpurdie 647
}
648
 
649
 
650
sub Debug3
651
{
263 dpurdie 652
    _Message '(D)', ArgsToString (\@_) if ($::ScmDebug >= 3) ;
227 dpurdie 653
}
654
 
655
sub IsDebug
656
{
657
    my( $level) = @_;
658
    return $::ScmDebug >= $level;
659
}
660
 
661
#-------------------------------------------------------------------------------
662
# Function        : DebugDumpData
663
#
664
# Description     : Dump a data structure
665
#
666
# Inputs          : $name           - A name to give the structure
667
#                   @refp           - An array of references
668
#
669
# Returns         :
670
#
671
sub DebugDumpData
672
{
673
    my ($name, @refp) = @_;
674
 
675
    my $ii = 0;
676
    foreach  ( @refp )
677
    {
678
        print Data::Dumper->Dump ( [$_], ["*[Arg:$ii] $name" ]);
679
        $ii++
680
    }
681
}
682
 
683
#-------------------------------------------------------------------------------
231 dpurdie 684
# Function        : DebugTraceBack
685
#
686
# Description     : Display the call stack
687
#
688
# Inputs          : $tag
689
#
690
# Returns         : Nothing
691
#
692
sub DebugTraceBack
693
{
694
    my ($tag) = @_;
695
    $tag = 'TraceBack' unless ( $tag );
696
 
697
    #
698
    #   Limit the stack stace.
699
    #   It can't go on forever
700
    #
701
    foreach my $ii ( 0 .. 20 )
702
    {
703
         my ($package, $filename, $line) = caller($ii);
704
         last unless ( $package );
705
         print "$tag: $ii: $package, $filename, $line\n";
706
    }
707
}
708
 
709
#-------------------------------------------------------------------------------
227 dpurdie 710
# Function        : DebugPush
711
#
712
# Description     : Save the current debug level and then use a new name and
713
#                   debug level for future reporting
714
#
279 dpurdie 715
#                   Provided for backward compatability
716
#                   Preferred solution is ErrorReConfig
717
#
718
# Inputs          : $name       - New program name
227 dpurdie 719
#                   $level      - New program debug level
720
#
721
# Returns         : Current debug level
722
#
723
 
724
my @DebugStack = ();
725
sub DebugPush
726
{
727
    my ($name, $new_level) = @_;
279 dpurdie 728
    my %args;
227 dpurdie 729
 
279 dpurdie 730
    #
731
    #   Save current state on a stack
732
    #
733
    my $estate = ErrorReConfig ();
734
    push @DebugStack, $estate;
735
 
227 dpurdie 736
    $::ScmDebug = $new_level if ( defined $new_level && $new_level );
737
    $::ScmWho =   $name      if ( defined $name && $name );
738
 
739
    return $::ScmDebug;
740
}
741
 
742
#-------------------------------------------------------------------------------
743
# Function        : DebugPop
744
#
745
# Description     : Restores the operation of the DebugPush
746
#
747
# Inputs          : None
748
#
749
sub DebugPop
750
{
279 dpurdie 751
    pop @DebugStack;
227 dpurdie 752
}
753
 
754
#-------------------------------------------------------------------------------
755
# Function        : DebugDumpPackage
756
#
757
# Description     : Dump data within the scope of a given package
758
#
759
# Inputs          : $packageName            - To dump
760
#
761
# Returns         : 
762
#
763
 
764
sub DebugDumpPackage
765
{
766
    no strict "vars";
767
    no strict "refs";
768
    my ($packageName) = @_;
769
    print "==DebugDumpPackage: $packageName =============================\n";
770
 
771
 
772
    local (*alias);             # a local typeglob
773
    local $Data::Dumper::Pad = "\t ";
774
    local $Data::Dumper::Maxdepth = 2;
775
    local $Data::Dumper::Indent  = 1;
776
 
777
    # We want to get access to the stash corresponding to the package name
778
 
779
    *stash = *{"${packageName}::"};  # Now %stash is the symbol table
780
#    $, = " ";                        # Output separator for print
781
    # Iterate through the symbol table, which contains glob values
782
    # indexed by symbol names.
783
    while (my ($varName, $globValue) = each %stash)
784
    {
785
        print "$varName =============================\n";
786
        next if ( $varName eq 'stash' );
787
        *alias = $globValue;
788
        if (defined ($alias)) {
789
            print Data::Dumper->Dump ( [$alias], ["*$varName" ]);
790
#            print "\t \$$varName $alias \n";
791
        } 
792
        if (defined (@alias)) {
793
            print Data::Dumper->Dump ( [\@alias], ["*$varName" ]);
794
#            print "\t \@$varName @alias \n";
795
        } 
796
        if (defined (%alias)) {
797
            print Data::Dumper->Dump ( [\%alias], ["*$varName" ]);
798
#            print "\t \%$varName ",%alias," \n";
799
        }
800
        if (defined (&alias)) {
801
#            print Data::Dumper->Dump ( [\&alias], ["*$varName" ]);
802
            print "\t \&$varName ","Code Fragment"," \n";
803
        }
804
     }
805
}
806
 
807
#
808
#
809
1;