Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple subtitution

Status
Not open for further replies.

jpillonel

Programmer
Dec 17, 2003
61
CH
Hello,

I have a simple question.

I run a perl script on a windows server which use blat to send an email with an attachement. But blat doesn't support to have a blank in the filename.

My fiename is here:

Code:
my $emaillink="./mail/$start_time.$_[0].msg";
The variable is for example equal to : "./mail/200701231020.Cust Nomade.msg"

So I need to remove all blanks in this variable.

I tried this regular expression but it delete the also the $start_time variable:
Code:
$emaillink_new =~ s// /g;

Does anyone have an idea ?

Thanks in advance
 
Hi

You reversed the order : the space comes first, the nothing after.
Code:
$emaillink_new =~ s/[highlight red] [/highlight]//g;
But I would prefer to remove all whitespace characters ( [tt]\s[/tt] ) :
Code:
$emaillink_new =~ s/[red]\s[/red]//g;

Feherke.
 
Excellent thanks, works fine.

Is there any way to replace / by a \ (useful for windows paths).

Because this syntax doesn't works:

Code:
$emaillink_new =~ s///\/g;

Thanks for your help
 
you don't need to change / to \ for windows. Windows isn't picky about which way the slash goes.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top