regexp inside <> + typos in perldoc

H

Hendrik Maryns

Hi,

I know it is possible to read in the current dir with @list=<*.*> or
even <*>. Now, I want to read all the current files, except for the
..pl-files. I tried <*.[^(pl)]*>, but this gave me the pl files alone!.
How do regexps inside <> work? Or do these follow the syntax of my
command line (WinXP, I'm afraid)? And, related: how can I get the
current directory?

Apart from this, I sometimes find minor typos in the docs. Where can I
report those? Via perlbug seems a bit too strong to me...
(e.g.: in perlretut, line 15 of "Using character classes": 'away' should
be 'a way')

Cheers, Hendrik
 
P

Paul Lalli

Hendrik Maryns said:
Hi,

I know it is possible to read in the current dir with @list=<*.*> or
even <*>.

Those do not do the same thing.
Now, I want to read all the current files, except for the
.pl-files. I tried <*.[^(pl)]*>, but this gave me the pl files alone!.
How do regexps inside <> work?

They don't. <*> syntax is a glob, not a regex. glob() simply passes
its argument to be interpreted by your shell. If you really want to use
that syntax, you'd have to figure out how you would get a listing of the
files you want from your shell.
Or do these follow the syntax of my
command line (WinXP, I'm afraid)?

Yes. So determine what argument you would pass to `dir` on the command
line, and pass that argument to the glob.

Frankly, I'd abandon the glob technique, and use a more platform
independent method:
opendir my $dir, '.' or die "Cannot open current directory: $!";

#read all at once:
my @files = grep {!/\.pl$/i} readdir ($dir);

#OR, file by file:
while ($_ = readdir($dir)){
next if /\.pl$/i;
# . . .
}

closedir $dir;

And, related: how can I get the current directory?

use Cwd;
my $curdir = getcwd;
Apart from this, I sometimes find minor typos in the docs. Where can I
report those? Via perlbug seems a bit too strong to me...
(e.g.: in perlretut, line 15 of "Using character classes": 'away' should
be 'a way')

I don't understand your problem with perlbug. The docs are part of the
standard Perl distribution. perlbug is for reporting errors with Perl.
What's the dilemma?

Paul Lalli
 
T

Tad McClellan

Hendrik Maryns said:
Now, I want to read all the current files,


What is a "current file"?

How is it different from a "file"?

except for the
.pl-files.


foreach my $file ( grep !/\.pl$/, glob '* .*' ) {

How do regexps inside <> work?


There *are no* regexes involved with globbing.

Globbing is a different language, and the all of the funny
characters have different meanings.
 
H

Hendrik Maryns

Paul Lalli schreef:
Hi,

I know it is possible to read in the current dir with @list=<*.*> or
even <*>.


Those do not do the same thing.

Now, I want to read all the current files, except for the
.pl-files. I tried <*.[^(pl)]*>, but this gave me the pl files
alone!.

How do regexps inside <> work?


They don't. <*> syntax is a glob, not a regex. glob() simply passes
its argument to be interpreted by your shell. If you really want to use
that syntax, you'd have to figure out how you would get a listing of the
files you want from your shell.

Or do these follow the syntax of my
command line (WinXP, I'm afraid)?


Yes. So determine what argument you would pass to `dir` on the command
line, and pass that argument to the glob.

Frankly, I'd abandon the glob technique, and use a more platform
independent method:
opendir my $dir, '.' or die "Cannot open current directory: $!";

#read all at once:
my @files = grep {!/\.pl$/i} readdir ($dir);

#OR, file by file:
while ($_ = readdir($dir)){
next if /\.pl$/i;
# . . .
}

closedir $dir;


And, related: how can I get the current directory?


use Cwd;
my $curdir = getcwd;

Apart from this, I sometimes find minor typos in the docs. Where can
I

report those? Via perlbug seems a bit too strong to me...
(e.g.: in perlretut, line 15 of "Using character classes": 'away'
should

be 'a way')


I don't understand your problem with perlbug. The docs are part of the
standard Perl distribution. perlbug is for reporting errors with Perl.
What's the dilemma?

Paul Lalli

Wow, thanks for the proposals! I'll plunge into perldoc -f glob now!

H.
 
A

Anno Siegel

[...]
Apart from this, I sometimes find minor typos in the docs. Where can I
report those? Via perlbug seems a bit too strong to me...
(e.g.: in perlretut, line 15 of "Using character classes": 'away' should
be 'a way')

When it's part of the Perl distribution, as perlretut, perlbug is the
right method. A patch in "diff -u" format is appreciated -- I think
perlbug will tell you this again :)

Anno
 
H

Hendrik Maryns

Anno Siegel schreef:
[...]

Apart from this, I sometimes find minor typos in the docs. Where can I
report those? Via perlbug seems a bit too strong to me...
(e.g.: in perlretut, line 15 of "Using character classes": 'away' should
be 'a way')


When it's part of the Perl distribution, as perlretut, perlbug is the
right method. A patch in "diff -u" format is appreciated -- I think
perlbug will tell you this again :)

Thanks, I'll have a look at it!

And the people that handle the perlbug reports will have a whole list of
typos to correct...

H.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top