Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: searching files

by Marshall (Canon)
on Mar 05, 2020 at 05:50 UTC ( [id://11113819]=note: print w/replies, xml ) Need Help??


in reply to searching files

You need a regular expression to match on wildcards like "*".
Adapt this to your situation.
The syntax is a bit weird because the letter immediately following "$user" is a word character and there has to be a way to tell where the $user variable stops and the "_ABC" begins....
use strict; use warnings; my $user_input = "abc"; my $regex = qr/${user_input}_ABC_.*pd/; foreach my $file (qw (abc abc_ABC_something.pdf abc_ABC_anything.pdf +)) { next unless $file =~ /$regex/; print "$file is valid\n"; } __END__ abc_ABC_something.pdf is valid abc_ABC_anything.pdf is valid

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11113819]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-19 22:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found