Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC perlfunc::sort missing switch to m// in example #468

Closed
p5pRT opened this issue Sep 2, 1999 · 2 comments
Closed

DOC perlfunc::sort missing switch to m// in example #468

p5pRT opened this issue Sep 2, 1999 · 2 comments

Comments

@p5pRT
Copy link

p5pRT commented Sep 2, 1999

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

Searchable as RT1309$

@p5pRT
Copy link
Author

p5pRT commented Sep 2, 1999

From scastle@sced.esoc.esa.de

  @​new = sort {
  ($b =~ /=(\d+)/)[0] <=> ($a =~ /=(\d+)/)[0]
  ||
  uc($a) cmp uc($b)
  } @​old;

should have '/g' as below :-

  ($b =~ /=(\d+)/g)[0] <=> ($a =~ /=(\d+)/g)[0]

if not the match returns true/false not the required integer.

Hope this helps.

Simon Castle.

@p5pRT
Copy link
Author

p5pRT commented Sep 2, 1999

From [Unknown Contact. See original ticket]

Simon Castle x2087 <scastle@​sced.esoc.esa.de> wrote

as fare as i can tell the following example from perlfunc sort :-

             @&#8203;new = sort \{
                 \($b =~ /=\(\\d\+\)/\)\[0\] \<=> \($a =~ /=\(\\d\+\)/\)\[0\]
                                     ||
                             uc\($a\)  cmp  uc\($b\)
             \} @&#8203;old;

should have '/g' as below :-

                 \($b =~ /=\(\\d\+\)/g\)\[0\] \<=> \($a =~ /=\(\\d\+\)/g\)\[0\]

if not the match returns true/false not the required integer.

No it doesn't. Did you actually try the example?

Read up in perlop about the different results which are returned by m//
in scalar and in list context.

Mike Guy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant