Guest User

Untitled

a guest
Jun 23rd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #!perl
  2. package Example::Constants;
  3.  
  4. use Exporter qw( import );
  5. use Readonly;
  6.  
  7. Readonly my $EMPTY_STRING => q{};
  8. our @EXPORT = qw( $EMPTY_STRING );
  9.  
  10. #!perl
  11. use Example::Constants;
  12. print $EMPTY_STRING . 'foo' . $EMPTY_STRING;
  13.  
  14. Readonly our $EMPTY_STRING => q{}; # 'our' instead of 'my'
  15.  
  16. package Example::Constants;
  17.  
  18. use strict;
  19. use warnings;
  20. use base 'Exporter';
  21. use Readonly;
  22.  
  23. Readonly our $EMPTY_STRING => q{};
  24. our @EXPORT = qw( $EMPTY_STRING );
  25.  
  26. 1;
  27.  
  28. #!perl
  29. package Example::Constants;
  30.  
  31. use Exporter qw( import );
  32. use Readonly;
  33. use Scalar::Util qw(readonly);
  34.  
  35. our $EMPTY_STRING;
  36. our @EXPORT = qw( $EMPTY_STRING );
  37.  
  38. if ( !readonly( $EMPTY_STRING ) ) {
  39. Readonly $EMPTY_STRING => q{};
  40. }
  41.  
  42. #!perl
  43. package Example::Constants;
  44.  
  45. use Exporter qw( import );
  46. use Readonly;
  47. use vars qw( $EMPTY_STRING );
  48.  
  49. Readonly $EMPTY_STRING => q{};
  50. our @EXPORT = qw( $EMPTY_STRING );
  51.  
  52. #!perl
  53. package Example::Constants;
  54.  
  55. use Exporter qw( import );
  56. use Readonly;
  57.  
  58. our $EMPTY_STRING;
  59. *EMPTY_STRING = q{};
  60. our @EXPORT = qw( $EMPTY_STRING );
Add Comment
Please, Sign In to add comment