60 PerlMonks - Newest Nodes New nodes appearing on PerlMonks http://perlmonks.org/~monkads/index.pl?node_id=30175 http://blogs.law.harvard.edu/tech/rss PerlMonks Newest Nodes XML Generator 30 Wed Nov 25 09:25:30 2020 961 PerlMonks http://perlmonks.org/ 2020-11-25 20:25:30 rss,clean Anonymous Monk Wed Nov 25 09:25:30 2020 20201125092530 Regexp substitution using variables MikeTaylor http://perlmonks.org/~monkads/index.pl?node_id=11124218 I have a string $value that I want to transform by regexp substitution. But the pattern, replacement and flags are known only at run-time. They are specified by $pattern, $replac... perlquestion Wed, 25 Nov 2020 19:20:30 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124218 11124218 11121877 2020-11-25 14:20:30 MikeTaylor Re^3: Pointers and References GrandFather http://perlmonks.org/~monkads/index.pl?node_id=11124224 Please, in the context of Perl at least, expunge "pointer" from your head. Perl references are simply not pointers. Yes, there are pointers under the hood, but thinking of them as pointers will jus... note Wed, 25 Nov 2020 20:10:11 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124224 11124224 461912 2020-11-25 15:10:11 GrandFather Re^3: Quick and dirty mobile fix Leudwinus http://perlmonks.org/~monkads/index.pl?node_id=11124223 Personally, the "old school" look of the site is what I initially found so appealing. The great help I've received so far has just been icing on the cake. However, I do know that people in the wi... note Wed, 25 Nov 2020 20:06:14 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124223 11124223 11123295 2020-11-25 15:06:14 Leudwinus Re: Regexp substitution using variables choroba http://perlmonks.org/~monkads/index.pl?node_id=11124222 Some of the flags can be moved to a non-capturing group: #!/usr/bin/perl use warnings; use strict; my $string = 'abc'; my $pattern = 'B'; my $replacement = 'X'; my $flags = 'i'; $stri... note Wed, 25 Nov 2020 19:56:04 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124222 11124222 832495 2020-11-25 14:56:04 choroba Re: Regexp substitution using variables Bod http://perlmonks.org/~monkads/index.pl?node_id=11124221 You need to add the modifiers at the start of the substitution like this: use strict; my $pattern = 'test'; my $replacement = 'New'; my $flags = 'i'; my $value = 'My Test Text';... note Wed, 25 Nov 2020 19:53:19 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124221 11124221 11123653 2020-11-25 14:53:19 Bod Re^3: Pointers and References kcott http://perlmonks.org/~monkads/index.pl?node_id=11124220 "And thanks for the alias tip. I will have to park that one away for the time being because as useful as Perl one-liners are, I don't think I'm quite ready to use them that fr... note Wed, 25 Nov 2020 19:51:57 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124220 11124220 861371 2020-11-25 14:51:57 kcott Re: Regexp substitution using variables jwkrahn http://perlmonks.org/~monkads/index.pl?node_id=11124219 For certain flags you can do: $value =~ s/(?$flags:$pattern)/$replacement/; ... note Wed, 25 Nov 2020 19:49:30 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124219 11124219 540414 2020-11-25 14:49:30 jwkrahn Re^4: Quick and dirty mobile fix Bod http://perlmonks.org/~monkads/index.pl?node_id=11124217 Mobile delivery is not subjective... There are numerous standards which set out design standards for the mobile web such as W3C... note Wed, 25 Nov 2020 18:56:38 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124217 11124217 11123653 2020-11-25 13:56:38 Bod Re^5: Quick and dirty mobile fix Bod http://perlmonks.org/~monkads/index.pl?node_id=11124216 needing to type html-tags with a mobile would be a no-go It's a pain and one that should be un-necessary. If the code that parsed the input assumed that everything without any mar... note Wed, 25 Nov 2020 18:34:15 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124216 11124216 11123653 2020-11-25 13:34:15 Bod Re^4: Quick and dirty mobile fix Bod http://perlmonks.org/~monkads/index.pl?node_id=11124215 Might be interesting (and someone's probably done so in the past) to look at the user agent info and see what people are actually using That would be very interesting, especially p... note Wed, 25 Nov 2020 18:28:33 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124215 11124215 11123653 2020-11-25 13:28:33 Bod Re^6: CPAN PREFIX or INSTALL_BASE Bod http://perlmonks.org/~monkads/index.pl?node_id=11124214 But when it comes to installing SSL certificates ... oh not that :( That is one thing that cPanel does really well... I create them locally using ... note Wed, 25 Nov 2020 18:17:59 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124214 11124214 11123653 2020-11-25 13:17:59 Bod Re^6: Pointers and References davido http://perlmonks.org/~monkads/index.pl?node_id=11124213 Your use of do is obviously not wrong. I tend to reserve its use for when I have things I want to pass back out of it. As an example that I use sometimes when I'm in quick and dirty mode:... note Wed, 25 Nov 2020 18:11:04 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124213 11124213 281137 2020-11-25 13:11:04 davido Re: Pointers and References Leudwinus http://perlmonks.org/~monkads/index.pl?node_id=11124212 I just wanted to say thank you again to all who responded to my questions with thoughtful replies, examples and -- for a lack of a better word -- references to the Perl documentation. And apologie... note Wed, 25 Nov 2020 17:58:42 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124212 11124212 11123295 2020-11-25 12:58:42 Leudwinus Re: Pointers and References Leudwinus http://perlmonks.org/~monkads/index.pl?node_id=11124211 <a href="?node=jcb">jcb</a>, <a href="?node=erix">erix</a>, <a href="?node=Anonymous%20Monk">Anonymous Monk</a>, Thank you for the additional explanations on the differences between references and pointers (which don't apply here) as well as on the concept of aliases... note Wed, 25 Nov 2020 17:50:34 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124211 11124211 11123295 2020-11-25 12:50:34 Leudwinus Re^2: Pointers and References Leudwinus http://perlmonks.org/~monkads/index.pl?node_id=11124210 Thank you for that!... note Wed, 25 Nov 2020 17:39:10 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124210 11124210 11123295 2020-11-25 12:39:10 Leudwinus Re^2: Pointers and References Leudwinus http://perlmonks.org/~monkads/index.pl?node_id=11124209 Hi Ken, You're using terms pointer, address, memory location which I suspect you've picked up from one or more other languages. You are then attempting to apply those term... note Wed, 25 Nov 2020 17:36:03 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124209 11124209 11123295 2020-11-25 12:36:03 Leudwinus Re^5: A short whishlist of Perl5 improvements leaping to Perl7 LanX http://perlmonks.org/~monkads/index.pl?node_id=11124208 The "original sin" was backwards compatibility to Perl 4, which had no my or strict . Back in the time piggybacking private variables had huge advantages, but it led to paradoxes... note Wed, 25 Nov 2020 17:06:58 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124208 11124208 708738 2020-11-25 12:06:58 LanX Re^2: script hanging at thread start marto http://perlmonks.org/~monkads/index.pl?node_id=11124207 See <a href="?node_id=1200648">Re^4: Threading with a twist -- a panorama</a>, the reply with the responses that tend to be posted when someone quotes this.... note Wed, 25 Nov 2020 16:39:58 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124207 11124207 324763 2020-11-25 11:39:58 marto Re^4: A short whishlist of Perl5 improvements leaping to Perl7 kennethk http://perlmonks.org/~monkads/index.pl?node_id=11124206 I agree with the origins; I just wish that Perl had rolled a no strict; into -e rather than providing no constraint on variables in proper scripts. ... note Wed, 25 Nov 2020 16:39:17 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124206 11124206 712372 2020-11-25 11:39:17 kennethk Re^9: Pointers and References LanX http://perlmonks.org/~monkads/index.pl?node_id=11124205 Perl is <a href="https://perldoc.perl.org/perlglossary#alias">aliasing</a> in for loops. So $x = 42 is as useful as 1 = 42 HTH! :) ... note Wed, 25 Nov 2020 16:14:51 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124205 11124205 708738 2020-11-25 11:14:51 LanX Re^5: CPAN PREFIX or INSTALL_BASE bliako http://perlmonks.org/~monkads/index.pl?node_id=11124204 But when it comes to installing SSL certificates ... oh not that :(... note Wed, 25 Nov 2020 16:10:57 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124204 11124204 1165397 2020-11-25 11:10:57 bliako Re^10: Pointers and References bliako http://perlmonks.org/~monkads/index.pl?node_id=11124203 Sure, thanks! I will ask if I have a problem.... note Wed, 25 Nov 2020 16:08:50 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124203 11124203 1165397 2020-11-25 11:08:50 bliako Re^8: Pointers and References Leudwinus http://perlmonks.org/~monkads/index.pl?node_id=11124202 Thank you for providing your examples demonstrating how variables, but not literals, can be modified in a list via a for loop or subroutine.... note Wed, 25 Nov 2020 15:37:43 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124202 11124202 11123295 2020-11-25 10:37:43 Leudwinus Re^8: Pointers and References Leudwinus http://perlmonks.org/~monkads/index.pl?node_id=11124201 That's because 1,2,3 are literals which are read only. Use variables (sic) and you can change them in the loop. ;) It took me a few times to understand this line based o... note Wed, 25 Nov 2020 15:33:02 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124201 11124201 11123295 2020-11-25 10:33:02 Leudwinus Re: script hanging at thread start Anonymous Monk http://perlmonks.org/~monkads/index.pl?node_id=11124200 From perldoc threads WARNING The "interpreter-based threads" provided by Perl are not the fast, lightweight system for multitasking that one might ... note Wed, 25 Nov 2020 15:32:15 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124200 11124200 961 2020-11-25 10:32:15 Anonymous Monk Re^2: Pointers and References Leudwinus http://perlmonks.org/~monkads/index.pl?node_id=11124199 So, in answer to question 1: no, it contains a reference (which might be an address of something, but you don't {and shouldn't} need to know what). Got it. Thanks for t... note Wed, 25 Nov 2020 15:13:07 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124199 11124199 11123295 2020-11-25 10:13:07 Leudwinus Re^3: Testing unexpected I/O failures Fletch http://perlmonks.org/~monkads/index.pl?node_id=11124198 The idiom I've normally used is more along the lines of something like this; call open then use constants from <a href="http://search.cpan.org/perldoc?Errno">Errno</a> to figure out from !$ what specifically went wr... note Wed, 25 Nov 2020 14:31:20 +0000 http://perlmonks.org/~monkads/index.pl?node_id=11124198 11124198 58196 2020-11-25 09:31:20 Fletch