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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

$webdata=<<END; adds extra line: Probably a simple problem

Status
Not open for further replies.

01chris

Technical User
Dec 15, 2006
11
GB
Why, when I use the following code, does my script add an extra blank line after the last </user> tag?

Code:
$webdata=<<END;

<User Name="$FORM{'username'}">
<Option Name="Pass">$md5</Option>
<Option Name="Group">users</Option>
<Option Name="Bypass server userlimit">2</Option>
<Option Name="User Limit">0</Option>
<Option Name="IP Limit">0</Option>
<Option Name="Enabled">2</Option>
<Option Name="Comments"/>
<Option Name="ForceSsl">2</Option>
<IpFilter>
<Disallowed/>
<Allowed/>
</IpFilter>
<Permissions>
<Permission Dir="C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\$FORM{'username'}">
<Option Name="FileRead">1</Option>
<Option Name="FileWrite">1</Option>
<Option Name="FileDelete">1</Option>
<Option Name="FileAppend">1</Option>
<Option Name="DirCreate">1</Option>
<Option Name="DirDelete">1</Option>
<Option Name="DirList">1</Option>
<Option Name="DirSubdirs">1</Option>
<Option Name="IsHome">1</Option>
<Option Name="AutoCreate">0</Option>
</Permission>
</Permissions>
<SpeedLimits DlType="0" DlLimit="10" ServerDlLimitBypass="2" UlType="0" UlLimit="10" ServerUlLimitBypass="2">
<Download/>
<Upload/>
</SpeedLimits>
</User>
END

Any ideas?
Thanks
Chris
 
It doesn't add an "extra" blank line. It adds exactly how many returns as you tell it too.

If you do not want the last tag to be followed by a return, then you can either use a different from of quoting, like qq{}. Or you can simply take the results and chomp it.

Code:
chomp $webdata;
 
It doesn't do it on mine. It does print one at the beginning though, before the first <User> tag. But that's because you've told it to.

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
yep:

Code:
$webdata=<<END;
**blank line here**
<User Name="$FORM{'username'}">


- Kevin, perl coder unexceptional!
 
Thank you both very much for the prompt and helpful replies.

MillerH: Thank you for that chomp command, it has done the trick.

stevexff: Thanks for the response, I had intended for there to be a blank line at the top.

Problem solved!
Chris
 
'here' docs are so ancient anyways, I think people use them because of momentum more than anything. qq and q are easier to handle chunks of text with.

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

Part and Inventory Search

Sponsor

Back
Top