Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Don't ask to ask, just ask
 
PerlMonks  

Re: Sorting names using Regular Expressions and placing them in different Files.

by jZed (Prior)
on Dec 28, 2006 at 12:40 UTC ( [id://592089]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Sorting names using Regular Expressions and placing them in different Files.

  1. open the input file, checking for file-open error
  2. open the output files, checking for file-open errors
  3. for each line in the input file
  4. use a regex or split to see if it has the date you want
  5. write it to the appropriate output when appropriate
  6. close the files
Please try to do that yourself and if you have problems, feel free to come back and tell us which steps are giving you problems.
  • Comment on Re: Sorting names using Regular Expressions and placing them in different Files.

Replies are listed 'Best First'.
Re^2: Sorting names using Regular Expressions and placing them in different Files.
by Kiran Kumar K V N (Initiate) on Dec 28, 2006 at 12:53 UTC

    Hi jZed,

    I assumed the following Code but it seems vague and there is some real problem with it. I am not able to implement Regular Expressions Logic. Other things are also messed up.

    As such, can you please explain the Logic you mentioned in your Algo by giving your own Actual Perl Script for the Scenario.

    #!/usr/bin/perl -w #List.plx $file_name="/home/Wireless/kkiran/PERL/Files"; $files="file_name1, file_name2, file_name3"; $file_name1="BSC"; $file_name2="SBSCSubsystem"; $file_name3="MCBTS"; $dir_name = "/home/Wireless/kkiran/PERL"; @files=`ls -prt $file_name |grep -v / `; # Extract all files with the date file_name1.20041204********* and pla +ce in the file named BSC. $count=0, max_count; foreach $eachline(@file_name1.20041204*********) { chomp($eachline); print"\n$eachline"; } for (count=1; count=max_count;count++) { print "BSC.20041204*********\n : $file_name1.20041204*********\n"; } if($count > max_count) { return(0); } exit; # Extract all files with the date file_name2.20041204********* and pla +ce in the file named SBSCSubsystem. $count=0, max_count; foreach $eachline(@file_name2.20041204*********) { chomp($eachline); print"\n$eachline"; } for (count=1; count=max_count;count++) { print "SBSCSubsystem.20041204*********\n : $file_name2.20041204******* +**\n"; } if($count > max_count) { return(0); } exit; # Extract all files with the date file_name3.20041204********* and pla +ce in the file named MCBTS. $count=0, max_count; foreach $eachline(@file_name3.20041204*********) { chomp($eachline); print"\n$eachline"; } for (count=1; count=max_count;count++) { print "MCBTS.20041204*********\n : $file_name3.20041204*********\n"; } if($count > max_count) { return(0); } exit;
      Please follow marto's advice and reformat both of your postings using code tags so that they are legible.
        Hi jZed, I am trying to reformat my both the postings. Meanwhile, I am sure, you might have seen my code in my second posting. It seems vague and there is some real problem with it. I am not able to implement Regular Expressions Logic. Other things also seem to be messed up. As such, can you please explain the Logic you mentioned in your Algo by giving your own Actual Perl Script for the Scenario. Waiting for your aggressive response. Thanks and Regards, Kiran
      wow man $count=0, max_count; this is deep, and you should probably a) listen to marto and jZed, and b) start Reading the Friendly Manuals like perlfaq.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://592089]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.