Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: get list of files matching part of file name

by RichardK (Parson)
on Jul 11, 2012 at 12:37 UTC ( #981106=note: print w/replies, xml ) Need Help??


in reply to get list of files matching part of file name

you didn't say what you expect your code to do, so it difficult to offer any useful suggestions, other than glob('sample*.txt')

Maybe my @files = glob (".* *") doesn't do what you think it does?

see glob

Replies are listed 'Best First'.
Re^2: get list of files matching part of file name
by doubledecker (Scribe) on Jul 11, 2012 at 13:19 UTC

    I used glob to list all the files in my current directory and using those list of files i'm trying to find out matching files in other directory

      A couple of points:

      (1) In the foreach loop, $file contains a filename together with its path and extension. To extract just the name part, you need something like:

      (my $basename = fileparse($file)) =~ s/ \. .* $ //x;

      which uses the fileparse function from File::Basename to extract the filename, then removes the extension (if any).

      (2) print Dumper(@matches); will print each match on a separate line. You would probably be better off with something like this:

      printf "'%s' matches: %s\n", $basename, join(', ', @matches);

      HTH,

      Athanasius <°(((><contra mundum

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://981106]
help
Chatterbox?
[ambrus]: Corion: well Prima::Object says something like that the cleanup method will send an onDestory message and that you can't get more messages after cleanup, or something.
[Corion]: ambrus: Yeah - I don't think the deep source dive will be necessary if things are implemented as simple as they could be :)) And hopefully I won't need (more) timely object destruction. I can update the screen at 60Hz and hopefully even do HTTP ...
[Corion]: ... transfers in the background. Now that I think about it, this maybe even means that I can run the OpenGL filters on Youtube input :)
[ambrus]: Corion: I mentioned that the unix event loop of Prima always wakes up at least once every 0.2 seconds. Have you found out whether the win32 event loop of Prima does that too?
[Corion]: ambrus: Hmm - I would assume that the onDestroy message is sent from the destructor and doesn't go through the messageloop, but maybe it is sent when a window gets destroyed but all components are still alive...
[ambrus]: Corion: partly deep source dive, partly just conservative coding even if it adds an overhead.
[Corion]: ambrus: Hmm - no, I haven't looked at wakeup intervals ... I wonder why it should want to wakeup periodically because it gets a lot of messages from the Windows message loop (on Windows obviously)
[ambrus]: (Alternately a deep source dive and then rewrite that event loop to make it better, and then as a bonus you get an idle method.)
[ambrus]: The 0.2 seconds wakeup is likely a workaround for some bug, but I can't guess what bug that is.
[ambrus]: It's been there since Prima 1.00 iirc

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2016-12-09 10:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (150 votes). Check out past polls.