RBW wrote:
> James G. Sack (jim) wrote:
> 
>> RBW wrote:
>>  
>>
>>> I'm a complete noob at Perl so please bear with me... I basically
>>> cobbled this together.
>>>
>>> I'm getting this effect in the output file:
>>>
>>> || shExpMatch(url, "      ad.be.doubleclick.net
>>> ")|| shExpMatch(url, "      ad.harmony-central.com
>>> ")|| shExpMatch(url, "      ad.img.yahoo.co.kr
>>> ")|| shExpMatch(url, "      ad.sales.olympics.com
>>> ")
>>>
>>> ...
>>>
>>> ")|| shExpMatch(url, "adopt.specificclick.net
>>> ")|| shExpMatch(url, "adpick.switchboard.com
>>> ")|| shExpMatch(url, "adpulse.ads.targetnet.com
>>> ")|| shExpMatch(url, "adq.nextag.com
>>>
>>> From this perl code:
>>> #!/usr/bin/perl
>>> #######################################################
>>> open(MYINPUTFILE, "<AdBlockList-Hosts-4May06.test");             # open
>>> for input
>>> my(@lines) = <MYINPUTFILE>;                                      # read
>>> file into list
>>> @lines = sort(@lines);                                           # sort
>>> the list
>>> my($line);
>>>
>>>   
>>
>> move the next line
>>
>>  
>>
>>> chomp($line);                                               # I thought
>>> this was to eliminate the newline in the inputfile...
>>>
>>> $appendString = '")';
>>>
>>> foreach $line (@lines)                                           # loop
>>> thru list
>>> {
>>>   
>>
>> to here
>> (and see what happens)
>>
>>  
>>
>>> print
>>> "$line"."$appendString";                                                
>>> # print in sort order
>>> }
>>>
>>> close(MYINPUTFILE);
>>>
>>> exit;
>>>
>>>
>>>
>>> Which is fine but I need each line to look something like this where the
>>> string   '")';   is at the end of the line and there is a newline after
>>> that, like this:
>>> || shExpMatch(url, "      ad.be.doubleclick.net")
>>> || shExpMatch(url, "      ad.harmony-central.com")
>>> ...
>>>
>>>
>>> When I am done and everything is cleaned up format wise I am going to
>>> pipe this long list to a file like so:
>>> [EMAIL PROTECTED] applications]$./testAppend.pl > outputTestAppend.txt
>>>
>>> I think this is just a formatting problem but I'm not sure.
>>>
>>> TIA,
>>> RBW
>>>
>>>
>>>   
>>
>>  
>>
> Bing-GO!!
> 
> Thanks Jim that worked just fine.
> I also put a newline like so:
> 
> print "$line"."$appendString\n";
> 
> And it worked...
> 
> Now I have a few lines that have a quote mark followed by one space in
> some cases and six spaces in other cases which need to get replaced by
> just a quote mark... I'll let you know how it goes...
> 



You will probably end up with something like

  $line =~ s/"\s+/"/;


You may also wish to ask yourself whether the de-space should be
performed before the sort?

..j

-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to