Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Welcome to the Monastery
 
PerlMonks  

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

by ikegami (Patriarch)
on Dec 28, 2006 at 13:18 UTC ( [id://592111]=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^4: Sorting names using Regular Expressions and placing them in different Files.
in thread Sorting names using Regular Expressions and placing them in different Files.

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.

Replies are listed 'Best First'.
Re^6: Sorting names using Regular Expressions and placing them in different Files.
by Kiran Kumar K V N (Initiate) on Dec 28, 2006 at 13:25 UTC
    Hi jZed & Ikegami,

    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

      Hi All,

      I am a real real beginner of Perl.

      I am trying to write a Perl Script to extract all the filenames with the date <FileName>.20041204****** in the given list of Filenames as below and place BSC, SBSCSubsystem and MCBTS filenames in separate files:

      -rw-rw-rw- 1 bsmbin bsmbin 0 Dec 3 00:31 arun2-20041127120100

      -rw-rw-rw- 1 bsmbin bsmbin 0 Dec 3 00:31 abc2-20041127130812

      -rw-rw-rw- 1 bsmbin bsmbin 0 Dec 3 00:31 abc1-20041127131046

      -rw-rw-rw- 1 bsmbin bsmbin 10065 Dec 3 02:06 SBSCSubsystem-20041202143000

      -rw-rw-rw- 1 bsmbin bsmbin 10065 Dec 3 02:06 SBSCSubsystem-20041202140000

      -rw-rw-rw- 1 bsmbin bsmbin 10065 Dec 3 02:06 SBSCSubsystem-20041202133000

      -rw-rw-rw- 1 bsmbin bsmbin 7018 Dec 3 02:06 MCBTSSubsystem-20041202143000

      -rw-rw-rw- 1 bsmbin bsmbin 7019 Dec 3 02:06 MCBTSSubsystem-20041202140000

      -rw-rw-rw- 1 bsmbin bsmbin 7020 Dec 3 02:06 MCBTSSubsystem-20041202133000

      -rw-rw-rw- 1 bsmbin bsmbin 303 Dec 3 02:06 BSC-20041202143000

      -rw-rw-rw- 1 bsmbin bsmbin 303 Dec 3 02:06 BSC-20041202140000

      -rw-rw-rw- 1 bsmbin bsmbin 303 Dec 3 02:06 BSC-20041202133000

      -rw-rw-rw- 1 bsmbin bsmbin 10065 Dec 3 03:00 SBSCSubsystem-20041202150000

      -rw-rw-rw- 1 bsmbin bsmbin 7020 Dec 3 03:00 MCBTSSubsystem-20041202150000

      -rw-rw-rw- 1 bsmbin bsmbin 303 Dec 3 03:00 BSC-20041202150000

      -rw-rw-rw- 1 bsmbin bsmbin 10065 Dec 3 04:00 SBSCSubsystem-20041202160000

      -rw-rw-rw- 1 bsmbin bsmbin 10065 Dec 3 04:00SBSCSubsystem-20041202153000

      The Algorithm I thought of is like this :-

      1) Create 3 separate Files with names BSC, SBSCSubsystem and MCBTSSubsystem using File I/O.

      2) First, check in the given list of filenames starting from the top, files with name BSC-20041202******. For each filename found/sorted out in this Format, move the corresponding filename to the File BSC.Continue this process, until you reach the end of the List.

      3) Second, check in the given list of filenames starting from the top, files with name SBSCSubsystem- 20041202******. For each filename found/sorted out in this Format, move the corresponding filename to the File SBSCSubsystem. Continue this process, until you reach the end of the List.

      4) Third, check in the given list of filenames starting from the top, files with name MCBTSSubsystem- 20041202******. For each filename found/sorted out in this Format, move the corresponding filename to the File MCBTSSubsystem. Continue this process, until you reach the end of the List.

      In this way, all the respective filenames are transferred to the corresponding Files. Think that Regular Expressions might be required to implement the Logic of File Sorting.

      Can anyone help me with a Perl Script for the same.

      Thanks,

      Kiran

      Considered: gregor42 - reap: dupliate of Sorting names using Regular Expressions and placing them in different Files.. Final vote: Keep = 5, Edit = 1, Reap = 20.
      Unconsidered: davido. Keep votes blocked reaping. Node has a followup, and is buried in a thread; reaping not advisable.

        Perl? Nah. BASH! First, since the format is XXXX-dddd, you can echo the filename to "cut" and use a shell escape to put the XXXX part into another shell variable. Then echo the filename into the file specified in that variable. Wrap a for loop for all files around it, and you got yourself a oneliner!

        --
        $Stalag99{"URL"}="http://stalag99.keenspace.com";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://592111]
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.