We help IT Professionals succeed at work.

many rows to one row :-)

nifer
nifer asked
on
Medium Priority
239 Views
Last Modified: 2010-03-04
I need to have all text beetween:
<url  and </url> to be in one long row.. Any simple perl solution?
Comment
Watch Question

Author

Commented:
Edited text of question

Commented:
When you say "in one long row" do you mean there are now multiple lines inside the <url> tags and you want a single line?

And what is "<url>" used for? I don't recognize that tag.

Author

Commented:
Yes there could be multiple lines inside the <url> tag, but not allways.

<url> are just some thing I use to make some splits later..




Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Commented:
Umm, should be "copies $1 to $s" not "copies $s to $1" in my description.

Author

Commented:
And if i want it to be a simple script let say:

scriptname textfile > textfile2

Commented:
Piece of cake, perl is cool:-)

$str = join('',<>);
local($s);
$str =~ s!(<url>.*?</url>)!{($s=$1)=~s/\n+/ /sg; $s;}!segi;
print $str;

Commented:
Of course if you are on a unix-like system, you'll need to include a first line of something like

#!/bin/perl

so it knows to run perl.

Author

Commented:
worked well ;-)
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.