Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Re: All of my terms end up in @foo0

by jerrygarciuh (Curate)
on Feb 08, 2002 at 05:04 UTC ( #144037=note: print w/replies, xml ) Need Help??


in reply to Re: All of my terms end up in @foo0
in thread All of my terms end up in @foo0

Per request here is the code. The commented out bit is just problem solving to be sure it wasn't the culprit.
Thx for lookin'!
jg
sub do_the_clean_up { open (ST,"$search_terms_file") or die "where's the search_terms fi +le? : $!"; flock (ST,LOCK_EX) or die "Couldn't flock search_terms: $!"; my @search_terms = <ST>; flock(ST,LOCK_UN); close ST or die "search_terms won't close : $!"; chomp (@search_terms); open (FTS,"$file_to_search") or die "where's the file_to_search? : + $!"; flock (FTS,LOCK_EX) or die "Couldn't flock file_to_search.: $!"; my @file = <FTS>; flock(FTS,LOCK_UN); close FTS or die "Couldn't close file_to_search. : $!"; foreach $term(@search_terms) { if ( !grep { /$term/ } @file ) { $term="$news_directory$term"; push (@delete_me,$term); } else { push (@keep_me,$term); } } chomp @delete_me; unlink @delete_me[0] or die "Couldn't unlink @delete_me[0]: $!"; # open (NEWST,"+< $search_terms_file") or die "where's the search_t +erms file? : $!"; # flock (NEWST,LOCK_EX) or die "Couldn't flock search_terms: $!"; # seek NEWST, 0, 0; # truncate (NEWST,0) or die "Can't truncate: $!"; # foreach (@keep_me) { # print NEWST "$_\n"; # } # flock(NEWST,LOCK_UN); # close NEWST or die "search_terms won't close : $!"; print "Location: $this_script_url\n\n"; exit; }
_____________________________________________________
If it gets a little bit out of hand sometimes, don't let it fool you into thinkin' you don't care.TvZ

Replies are listed 'Best First'.
Re: Re: Re: All of my terms end up in @foo0
by chipmunk (Parson) on Feb 08, 2002 at 05:14 UTC
    Ah, just as I had guessed, @file is being read in from an external file. So, the file probably has the wrong line endings for the system. Either convert the file to have the appropriate line endings, or change your code so that it can deal with any line endings.

    Here's a very simple, but probably not optimal, example of the latter:

    { local $/; my @files = split /\r\n?|\n\r?/, <FTS>; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://144037]
help
Chatterbox?
[Corion]: I'm looking into Firefox Accounts (to self-host bookmark synchronization, among other things) and the one thing I like about their documentation is that they include test vectors for ...
[Corion]: ... their hashes. Even though their backends claim to be open, they don't really seem to be geared towards self-hosting them, so I'm pondering writing a (simplicistic) Perl backend for my needs

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2017-11-18 17:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (277 votes). Check out past polls.

    Notices?