|
|
Joined: Oct 2000
Posts: 290
Member
|
Member
Joined: Oct 2000
Posts: 290 |
I am using the Upload hack with UBB Code Buttons, and I see the code where it checks to verify .jpg or .gif, but what I want to do is check for SPACES in the names of the files people are trying to upload. I am too shy to post what code I have come up with ![[Linked Image]](https://ubbdev.com/ubb/smilies/smile.gif) It doesn't work anyway....Whaddya think? ------------------ Tony (Vipermad) Rickard Viper Club UBB Admin
|
|
|
|
Joined: May 2000
Posts: 243
Member
|
Member
Joined: May 2000
Posts: 243 |
try: if ($imagename =~ / /sg) { .. do stuff .. } I dunno, Mark could probably make a 1 line, 1 character statement ![[Linked Image]](https://ubbdev.com/ubb/smilies/wink.gif) ------------------ Powered by ZCom Bulletin Boards
|
|
|
|
Joined: Aug 2000
Posts: 3,590
Moderator
|
Moderator
Joined: Aug 2000
Posts: 3,590 |
die 'Contains spaces and those are bad' if($image_name =~ / /); or to make the spaces nice characters $image_name =~ tr/ /_/g; ------------------  :: Who is Andy?
|
|
|
|
Joined: Oct 2000
Posts: 24
Member
|
Member
Joined: Oct 2000
Posts: 24 |
$image_name =~ y! !_!; That's just for !atom!.. ![[Linked Image]](https://ubbdev.com/ubb/smilies/smile.gif)
|
|
|
|
Joined: Oct 2000
Posts: 24
Member
|
Member
Joined: Oct 2000
Posts: 24 |
Dontcha love perl and it's 1,000s ways to do one thing?
$imagename =~ m!s+! ? dobadsub() : dogoodsub();
This one is just for fun.
my $am_i = [split /s+/, $imagename]; ref($am_i) =~ /ARRAY/ ? with_spaces_sub() : without_spaces_sub();
This message has been edited by Matt@ikonboard on January 11, 2001 at 08:27 PM
|
|
|
|
Joined: May 2000
Posts: 243
Member
|
Member
Joined: May 2000
Posts: 243 |
y and tr do the same thing, as well as ! !_! and / /_/ ------------------ Powered by ZCom Bulletin Boards
|
|
|
|
Joined: Oct 2000
Posts: 24
Member
|
Member
Joined: Oct 2000
Posts: 24 |
Yup, they both transliterate. It's a joke between Andy and I. I prefer to use '!' as a limiter/delimiter on pattern matching (I find it easier to read and to find later.).
Plus, you don't need the /g at the end of the pattern match when using 'y' - as it transliterate's the string anyway.
|
|
|
Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.
Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
|
|
Posts: 87
Joined: December 2001
|
|
Forums63
Topics37,575
Posts293,931
Members13,824
|
Most Online6,139 Sep 21st, 2024
|
|
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
|
|
|
|
|