← Back to Pull requests

Update the glob() documentation so it's more novice friendly #18821

Merged
scottchiefbaker merged 1 files (48 lines) on Jun 02, 2021 20:00 UTC
View on GitHub
scottchiefbaker scottchiefbaker commented on May 26, 2021 18:31 UTC
Author

We throw some heavy concepts (internal C functions?, and filenames with whitespace) at the user in the first two paragraphs. This moves some of that documentation to a separate section and gives simple examples for novices.

Also this normalizes all the function calls to glob(...) as per discussion on IRC.

Diff: 48 lines (+37 / -11) across 1 files Reviewer: Grinnz Review duration: 10168m
All Vouch review confidence checks passed
Residual risk 0.03 = Change Risk (0.26) × (1 − Review Confidence (0.90)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.26 · 48 lines diff across 1 files
0.26
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.88 · 5 substantive comment(s)
0.88
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
90%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.233
Real PR Conversation Timeline
6 items
Grinnz Grinnz commented on code on May 26, 2021 18:33 UTC
Code Review
pod/perlfunc.pod:1
@@ -3388,20 +3401,20 @@ For example, to glob filenames that have an C<e> followed by a space
 followed by an C<f>, use one of:
 
     my @spacies = <"*e f*">;
-    my @spacies = glob '"*e f*"';
-    my @spacies = glob q("*e f*");
+    my @spacies = glob('"*e f*"');

I don't think these need to be changed.

Grinnz Grinnz commented on code on May 26, 2021 18:33 UTC
Code Review
pod/perlfunc.pod:1
@@ -3372,10 +3372,23 @@ X<glob> X<wildcard> X<filename, expansion> X<expand>
 In list context, returns a (possibly empty) list of filename expansions on
 the value of EXPR such as the standard Unix shell F</bin/csh> would do.  In
 scalar context, glob iterates through such filename expansions, returning
-undef when the list is exhausted.  This is the internal function
-implementing the C<< <*.c> >> operator, but you can use it directly.  If
-EXPR is omitted, L<C<$_>|perlvar/$_> is used.  The C<< <*.c> >> operator
-is discussed in more detail in L<perlop/"I/O Operators">.
+undef when the list is exhausted. If EXPR is omitted, L<C<$_>|perlvar/$_>
+is used.
+
+    # List context
+    my @txt_files  = glob("*.txt");
+    my @perl_files = glob("*.pl *.pm");
+
+    # Scalar context
+    while (my $file = glob("*.mp3")) {
+        # Do stuff
+    }
+
+Glob also supports an altnernate syntax using C<< < >> C<< > >> as
+delimiters. While this syntax is supported, it is recommended that you
+use C<glob()> instead as it is more readable and searchable.

Functions should not be followed by empty parentheses in sentences according to the new style guide: https://perldoc.perl.org/perldocstyle#Function-names

Grinnz Grinnz commented on code on May 26, 2021 18:34 UTC
Code Review
pod/perlfunc.pod:1
@@ -3415,6 +3428,12 @@ is used as a C<while>/C<for> condition, then the condition actually
 tests for definedness of the expression's value, not for its regular
 truth value.
 
+Internal implemenation details:
+
+In scalar context this is the internal function implementing the

Not just in scalar context.

scottchiefbaker scottchiefbaker commented on code on May 26, 2021 20:15 UTC
Code Review
pod/perlfunc.pod:1
@@ -3388,20 +3401,20 @@ For example, to glob filenames that have an C<e> followed by a space
 followed by an C<f>, use one of:
 
     my @spacies = <"*e f*">;
-    my @spacies = glob '"*e f*"';
-    my @spacies = glob q("*e f*");
+    my @spacies = glob('"*e f*"');

This one I disagree on... I think for consistency all calls should be the same. These are a little harder to read maybe, but they're not different than any of the other glob calls where we used parens.

scottchiefbaker scottchiefbaker commented on May 31, 2021 16:54 UTC
Author

Just pinging people. Anything else I can do to land this PR?

Reviewers
Assignees
scottchiefbaker scottchiefbaker
Labels
risk: low confidence: 90.1% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 26.3% (LOW) · Higher = larger blast radius
26.3%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 90.1% · Lower = rushed or shallow review
90.1%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 2.6% · Safe to merge
2.6%
Repository