Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

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 ( [id://592095]=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 Re: Sorting names using Regular Expressions and placing them in different Files.
in thread Sorting names using Regular Expressions and placing them in different Files.

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;
  • Comment on Re^2: Sorting names using Regular Expressions and placing them in different Files.
  • Download Code

Replies are listed 'Best First'.
Re^3: Sorting names using Regular Expressions and placing them in different Files.
by jZed (Prior) on Dec 28, 2006 at 12:55 UTC
    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

        Meanwhile, I am sure, you might have seen my code in my second posting.

        No, that was unreadable too.
        Please put para tags (<p>...</p>) around your paragraphs.
        Please put code tags (<c>...</c>) around your code.

        Hi Kiran,

        It's not too polite to expect us to read your code like that, and it sounds an awful lot like this is a homework assignment that you want us to do for you. So, no, I don't think I'll rewrite your entire script for you. However, here's the key pieces you are missing:

        Open a file for reading
        open(INPUT,'<',$filename) or die $!;
        Open a file for writing
        open(BSC,'>','BSC') or die $!;
        Loop through a file looking for dates and names
        for my $searchline(<INPUT>) { if( $searchline =~ /20041204/ ) { if( $searchline =~ /^BSC/) { print BSC $searchline; } } }
        There are some other problems with the variables in your code, putting "use strict" at the top and defining variables with "my $var = ..." would help.
Re^3: Sorting names using Regular Expressions and placing them in different Files.
by alpha (Scribe) on Dec 28, 2006 at 13:03 UTC
    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://592095]
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.