problems regexp

J

john.swilting

I try to test a scalar which ends by a .gif
With any OS

try
if($data{attachement} = ~m/$`\.gif/){
MAIL($data{attachement});
}else{
AFFICHAGE_ERREUR_ATTACHEMENT($data{attachement});
}

It does not walk(work)
please help me

serge
 
J

john.swilting

john.swilting said:
I try to test a scalar which ends by a .gif
With any OS

try
if($data{attachement} = ~m/$`\.gif/){
MAIL($data{attachement});
}else{
AFFICHAGE_ERREUR_ATTACHEMENT($data{attachement});
}

It does not walk(work)
please help me

serge
iseek a scalar which ens in .gif
 
P

Paul Lalli

I try to test a scalar which ends by a .gif

You have to define what you mean by "test" a scalar.
With any OS

try
if($data{attachement} = ~m/$`\.gif/){

If you'd enabled strict and warnings, Perl would tell you you'd done a
few things wrong here.

First, the operator is =~. Those two characters, right next to each
other. You can not put a space in betwene them. Second, the $`
variable is used *after* a successful pattern match, not within it.
Third, you are only testing if the scalar *contains* .gif, not if it
ends in .gif - you have to anchor the pattern.

if ($data{attachment} =~ m/\.gif$/) {
It does not walk(work)

"work" is the correct English word here. "walk" makes no sense.

Paul Lalli
 
J

john.swilting

Dr.Ruud said:
john.swilting schreef:



Or try substr:

if ( substr($data{attachement}, -4) eq q/.gif/ ) {

succes
very nice
its ok
i am beginners in perl
I progress
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top