Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

The Monastery Gates

( [id://131]=superdoc: print w/replies, xml ) Need Help??

New here?I want to ask a question of the Perl Monks. Where do I start?

If you're new here, please read PerlMonks FAQ
and Create a new user!

Quests
Wall of Larry Quest
Starts at: Feb 26, 2024 at 05:00
Ends at: Dec 31, 2024 at 04:59
Current Status: Active
2 replies by jdporter

    By now you've all seen The St. Larry Wall Shrine. Well, it could use a fresh coat of gold leaf and shellac. Therefore, we are soliciting Larry-related items to be placed on the shrine. Links to offsite content are good; or if you have small bits of content, such as quotes, you'd like to contribute, that's fine too. Please reply to this Quest with your humble offerings. Thank you! And may St. Larry bless your codings and your debuggings.

poll ideas quest 2024
Starts at: Jan 01, 2024 at 00:00
Ends at: Dec 31, 2024 at 23:59
Current Status: Active
6 replies by pollsters
    First, read How do I create a Poll?. Then suggest your poll here. Complete ideas are more likely to be used.

    Note that links may be used in choices but not in the title.

Perl News
Toronto Perl Mongers present Randal Schwartz: Half My Life with Perl
on Oct 30, 2024 at 13:18
3 replies by talexb

    As part of year 25 of The Perl Advent Calendar, Perl luminary and co-author of O’Reilly’s “Learning Perl” Randal Schwartz will be giving a presentation entitled "Half My Life with Perl".

    ​This event will be a live stream via Zoom. The stream URL will be provided as we get closer to the date. Please register now if you’re interested in the event, so that we know how many Zoom attendees to plan for.

    Updated October 31, 2024: Sounds interesting, Alex. When is the event? Oh, you forgot that part?

    This will be a virtual event (so don't worry if you can't find your passport), to be held Saturday, December 14, 2024 at 5pm ET -- Google Calendar reliably tells me that's 10pm UTC. A link to the event will be posted when it's available. So far, we have 60 people signed up -- and it's six weeks away. I don't know what the limits are for a Zoom session, but Olaf is working on arranging that.

    Alex / talexb / Toronto

    Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

The Science Perl Journal, Issue #1 (Vol. 1, No. 1): Summer 2024 is finally here!
on Oct 17, 2024 at 12:51
3 replies by oodler
    TLDR; After hundreds of hours of work and support from lots of people, the long promised Journal is here.

    The rest is more of a rant.
Supplications
Signal Apache that Response is Complete
No replies — Read more | Post response
by rhumbliner
on Nov 02, 2024 at 00:04
    I'm using a Perl script with Apache and mod_perl to generate dynamic responses to client requests. At times I would like to signal Apache that my response is complete so the client can begin processing the response while on the server I perform a bunch of other clean up tasks. My code looks like this
    use CGI::Simple; my $q = new CGI::Simple; print $q->header(%HTTP_HEADERS); print $html; # response complete ... continue with various tasks ...
Inverse slices
5 direct replies — Read more / Contribute
by Anonymous Monk
on Oct 31, 2024 at 20:07
    Is there a better way to get an inverse slice than to do something like:
    my @array = ('aa'..'zz'); my @slice_idx = (6,13,42,66,69); # Slice my @slice = @array[@slice_idx]; my %slice_idx = map { $_ => 1 } @slice_idx; my @invslice_idx = grep { ! exists $slice_idx{$_} } 0 .. $#array; # Inverse slice. my @invslice = @array[@invslice_idx];
Unusual "Can't locate object method"
3 direct replies — Read more / Contribute
by geoffleach
on Oct 31, 2024 at 17:47
    When executed
    use Audio::TagLib; $test = shift; $file = Audio::TagLib::FileRef->new($test); say 'title:', $file->tag()->title()->toCString(); say 'track', $file->tag()->track()->toCString();
    Perl says
    title:Title Test Can't locate object method "toCString" via package "0" (perhaps you fo +rgot to load "0"?) at ./taglib_test.pl line 9.
    Note that the two calls are identical, except for the title/track. Similar calls in a different context don't have the problem.

    My question: How can I discover what Perl sees that results in the error? Many thanks. (FWIW the module reports content from a MP3 file)

Use global flag when declaring regular expressions with qr?
6 direct replies — Read more / Contribute
by unmatched
on Oct 28, 2024 at 10:41
    Hello!

    I'm just learning Perl and as an exercise I'm writing a small script that reads a file and outputs every URL it can find. I know there are modules for this, this is just for learning purposes, and to brush up on regular expressions. I came up with the following regular expression:

    my $re = qr( ( (?:[a-z][a-z0-9+-.]*) :// (?: (?: [a-z0-9._~!:;=&'\$\(\)\*\+\-\,]+@ )? (?: \[${ipv6}\] | ${ipv4} | [a-z0-9._~!;=&'\$\(\)\*\+\-\,]+ ) ) ) )xi; foreach ($ARGV[0]) { open my $fh, '<', $_ or die("Error opening file $_.\n"); while (my $row = <$fh>) { chomp $row; next if $row eq ""; if ($row =~ $re) { print "$1\n"; } } close($fh); }

    As you can see, I'm using qr to define the regular expression, as it's composed of other regular expressions defined in the code (omitted here for brevity). This gives me the most flexibility to later on refactor this script to make it more general purpose, or at least that is the idea.

    The file is read line by line, comparing against $re, and correctly printing the first URL it finds on that line. And that's the issue, it only finds the first match even when there are multiple URLs on that line. Typically, this is where I'd use the global flag, except that apparently I cannot use it with qr as I get an error: Unknown regexp modifier "/g".

    I've been reading about this but haven't been able to figure out a way to search the entire line to capture all matches. I tried using the s flag, different delimiters for qr, in case that made any difference, and of course tried modifying $re to use operators like + and *, but without any results.

    So, I don't know if I'm misunderstanding the problem that I need to solve, or I just don't know enough about Perl to use it effectively. I would say the issue is that declaring regular expressions with qr is not what I need for this particular case but I'm just not sure. Any ideas? Thank you!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-11-02 07:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    chatterbot is...






    Results (10 votes). Check out past polls.