Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.86k stars 528 forks source link

bugrep0-153825 #1388

Closed p5pRT closed 21 years ago

p5pRT commented 24 years ago

Migrated from rt.perl.org#2470 (status was 'resolved')

Searchable as RT2470$

p5pRT commented 24 years ago

From dolezal@comp.cz

Created by dolezal@comp.cz

=====BEGIN===== If I use regular expression in extended mode (with X modifier)\, Perl insert all whitespaces from replacement part into result string.

Sample​: s{   abcd }{   1234 }x;

Per use patter "abcd" without all whitespaces (\t or \n in sample) and replacement "\n\t1234\n" with all whitespaces from sample.

The unsightly solution is following​: s{   abcd }{   "1234" }xe;

Result string is "1234". But\, if I want using replacement on more lines\, this solution is slow (string concatenation) than classic replacement without pattern as an expression.

Thanks\, Tom.

I using Perl under Windows 98 CZ.

=====END=====

Perl Info ``` Site configuration information for perl 5.00503: Summary of my perl5 (5.0 patchlevel 5 subversion 03) configuration: Platform: osname=MSWin32, osvers=4.0, archname=MSWin32-x86-object uname='' hint=recommended, useposix=true, d_sigaction=undef usethreads=undef useperlio=undef d_sfio=undef Compiler: cc='cl.exe', optimize='-Od -MD -DNDEBUG -TP -GX', gccversion= cppflags='-DWIN32' ccflags ='-Od -MD -DNDEBUG -TP -GX -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DPERL_OBJECT' stdchar='char', d_stdstdio=define, usevfork=false intsize=4, longsize=4, ptrsize=4, doublesize=8 d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10 alignbytes=8, usemymalloc=n, prototype=define Linker and Libraries: ld='link', ldflags ='-nologo -nodefaultlib -release -libpath:"D:\Develop\Perl\lib\CORE" -machine:x86' libpth="D:\Develop\Perl\lib\CORE" libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib PerlCRT.lib libc=D:\Develop\Perl\lib\CORE\PerlCRT.lib, so=dll, useshrplib=yes, libperl=perlcore.lib Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -release -libpath:"D:\Develop\Perl\lib\CORE" -machine:x86' Locally applied patches: ACTIVEPERL_LOCAL_PATCHES_ENTRY @INC for perl 5.00503: D:/Develop/Perl/lib D:/Develop/Perl/site/lib . Environment for perl 5.00503: HOME (unset) LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\PACKER;C:\BATCH;D:\DEVELOP\PERL\BIN;D:\DEVELOP\DEVSTUDIO\VC\BIN;D:\DEVELOP\PHP;D:\APLIKACE\MTS PERL_BADLANG (unset) SHELL (unset) ```
p5pRT commented 21 years ago

From @iabyn

Hi\, I'm just going through the Perl bugs database closing old bug reports.

if I use regular expression in extended mode (with X modifier)\, Perl insert all whitespaces from replacement part into result string.

Sample​: s{ abcd }{ 1234 }x;

This is the intended behaviour. the /x modifier applies only to the pattern string\, not the replacement string. Even if we wanted to change it we couldn't\, because it would break many existing scripts.

Regards\,

Dave M.

p5pRT commented 21 years ago

@iabyn - Status changed from 'open' to 'resolved'