Skip to content

Add CPAN Phases 1 & 2: Socket, Archive::Tar, Net::FTP, and more#312

Merged
fglock merged 10 commits into
masterfrom
feature/cpan-phase1-modules
Mar 13, 2026
Merged

Add CPAN Phases 1 & 2: Socket, Archive::Tar, Net::FTP, and more#312
fglock merged 10 commits into
masterfrom
feature/cpan-phase1-modules

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Mar 13, 2026

Summary

Phases 1 & 2 of CPAN client dependencies - adds networking, archive handling, and related modules.

Phase 1: Low-hanging Fruit

  • DirHandle: Directory handle OO interface
  • Dumpvalue: Debugging value dumper
  • Sys::Hostname: Hostname retrieval using syscall
  • flock(): File locking with LOCK_SH, LOCK_EX, LOCK_UN, LOCK_NB
  • syscall(): System calls with SYS_gethostname support

Phase 2: Archive/Network Modules

  • IO::Socket, IO::Socket::INET, IO::Socket::UNIX: OO socket interface
  • IO::Zlib: Compressed I/O for gzip files
  • Archive::Tar: Tar archive handling
  • Net::FTP, Net::Cmd, Net::SMTP, Net::POP3, Net::NNTP: Network clients
  • Socket.pm: Added $VERSION and 20+ constants (INADDR_, IPPROTO_, SHUT_*, etc.)

Bug Fixes

  • Symbol::gensym() now returns glob reference for bless
  • Parser: keywords after :: no longer parsed as package name
  • Parser: @{${...}} nested dereference now works in push/unshift
  • Archive::Tar: GZIP_MAGIC_NUM regex octal to hex workaround

Design Document

dev/design/cpan_client.md with full dependency analysis and roadmap.

Test Plan

  • All unit tests pass
  • ./jperl -e 'use IO::Socket; ...' - works
  • ./jperl -e 'use Archive::Tar; ...' - works
  • ./jperl -e 'use Net::FTP; ...' - works
  • ./jperl -e 'use IO::Zlib; ...' - works

Generated with Devin

fglock and others added 2 commits March 13, 2026 18:17
New modules:
- DirHandle: directory handle OO interface (imported via sync.pl)
- Dumpvalue: debugging value dumper (imported via sync.pl)
- Sys::Hostname: hostname retrieval using syscall

New operators:
- flock(): file locking with LOCK_SH/LOCK_EX/LOCK_UN/LOCK_NB
- syscall(): system calls (SYS_gethostname support)

Bug fixes:
- Symbol::gensym() now returns glob reference (not glob) for bless
- Parser: keywords after '::' no longer parsed as package name part

Design document: dev/design/cpan_client.md

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
New modules (imported via sync.pl):
- IO::Socket, IO::Socket::INET, IO::Socket::UNIX - OO socket interface
- IO::Zlib - Compressed I/O for gzip files
- Archive::Tar - Tar archive handling
- Net::FTP, Net::Cmd, Net::SMTP, Net::POP3, Net::NNTP - Network clients
- Tie::StdHandle - Required by IO::Zlib
- File::Spec platform modules - Required by Archive::Tar

Socket enhancements:
- Added $VERSION to Socket.pm
- Added 20+ socket constants (INADDR_*, IPPROTO_*, SHUT_*, etc.)

Bug fixes:
- Parser: @{${...}} nested dereference now works in push/unshift
- Archive::Tar::Constant: GZIP_MAGIC_NUM regex octal to hex workaround

Design document: dev/design/cpan_client.md updated

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
@fglock fglock changed the title Add CPAN Phase 1: DirHandle, Dumpvalue, Sys::Hostname, flock, syscall Add CPAN Phases 1 & 2: Socket, Archive::Tar, Net::FTP, and more Mar 13, 2026
fglock and others added 8 commits March 13, 2026 18:36
In Perl regex:
- \1 through \9 (single digit) are ALWAYS backreferences
- \10 and above with all octal digits (0-7) are ALWAYS octal escapes
- Examples: \10, \77, \123, \213, \377 are all octal, not backreferences

This fixes Archive::Tar which uses \037\213 (gzip magic number) in patterns.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
- Create SysHostname.java with ghname() using InetAddress.getLocalHost()
- Fix XSLoader::load() to use caller() when no argument provided
- Eliminates 'Can't load Java XS module' warning for Sys::Hostname

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
- Mark completed modules: DirHandle, Sys::Hostname, Archive::Tar, Net::FTP, IO::Socket, Dumpvalue
- Mark flock() as implemented
- Add SysHostname.java and XSLoader changes to files list

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
The previous change incorrectly stopped parsing variable names when
identifiers that happen to also be keywords (like 'x', 'and', 'isa',
'if', etc.) appeared after '::'. This broke valid Perl like:
- $main::x
- $Foo::and
- &UNIVERSAL::isa

In Perl, keywords CAN be used as identifiers in fully qualified
package variable names.

Fixes test regressions in:
- op/sub.t (42 tests restored)
- mro/method_caching.t (31 tests restored)
- op/goto-sub.t (15 tests restored)
- test_pl/can_isa_ok.t (14 tests restored)

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
… File::Spec::Unix

- Add Symbol.pm wrapper that loads the XS module without depending on Exporter
- Remove `use constant` declarations from File/Spec/Unix.pm that were causing
  cascading dependency failures when tests cleared %INC

This fixes comp/require.t and io/through.t regressions where clearing %INC
caused Symbol.pm (and its dependencies) to fail loading because @inc was
modified to not include JAR paths.

Fixes:
- comp/require.t: 51 → 1743 tests restored
- io/through.t: 164 → 942 tests restored

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
Implement Perl's actual disambiguation rules from perlrebackslash:
1. Single digit (\1-\9) is always a backreference
2. Leading zero (\0xx) is always octal
3. Multi-digit number N: backreference if N <= capture groups seen,
   otherwise octal (if all digits are 0-7)

Examples:
- \100 with 100 capture groups -> backreference to group 100
- \100 with 0 capture groups -> octal 100 = @
- \037 with 0 capture groups -> octal 037 (used in Archive::Tar)

This fixes the re/pat.t regression where tests 1048-1049 failed
because \100 was incorrectly treated as octal even when 100 capture
groups existed.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
Add Symbol.pm to sync config - it's a pure Perl module that provides
gensym and qualify_to_ref. This is needed by constant.pm which is
used by File::Spec::Unix.pm.

Reverted File::Spec::Unix.pm to CPAN version (with use constant).

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
@fglock fglock merged commit 3208cd2 into master Mar 13, 2026
2 checks passed
@fglock fglock deleted the feature/cpan-phase1-modules branch March 13, 2026 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant