Subversion Repositories DevTools

Rev

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