perl-info 755 B

1234567891011121314151617181920212223242526272829303132333435
  1. #
  2. # Exposes information about the Perl environment via the $perl_info associative
  3. # array.
  4. #
  5. # Authors:
  6. # JINNOUCHI Yasushi <delphinus@remora.cx>
  7. #
  8. # function perl-info {
  9. local version
  10. local version_format
  11. local version_formatted
  12. # Clean up previous $perl_info.
  13. unset perl_info
  14. typeset -gA perl_info
  15. if (( $+commands[perlbrew] )); then
  16. version="${PERLBREW_PERL##*perl-}"
  17. elif (( $+commands[plenv] )); then
  18. version=$(plenv version-name)
  19. elif (( $+commands[perl] )); then
  20. version=$(perl -e 'printf "%vd", $^V')
  21. fi
  22. # Format version.
  23. if [[ -n "$version" ]]; then
  24. zstyle -s ':prezto:module:perl:info:version' format 'version_format'
  25. zformat -f version_formatted "$version_format" "v:$version"
  26. perl_info[version]="$version_formatted"
  27. fi
  28. # }