Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: Selecting the difference between two strings

by hgolden (Pilgrim)
on Sep 26, 2006 at 22:22 UTC ( [id://575033]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Selecting the difference between two strings
in thread Selecting the difference between two strings

I don't know much about Perforce, but from what you've said, there are probably easier ways to do this than what you're asking for.

If all of the information is of the format that you show in your original post, you could pretty easily form an indented list showing the branches.

For simplicity, let's call the text between slashes units. Now, sort the list ASCIbetically, and do a very simple loop that preserves the entry above. By comparing the current entry to the above entry, you could determine the number of tabs to print before the current entry. I.E if they have no units in common, we would print no spaces. If they have three units in common, but are both longer than three units, then we insert three tabs. If they have three units in common, but the above entry is only three units long, then we need four tabs.

Anyway, you can fit the particulars to what you want. To me, a Perl solution is one that's elegant in Perl, and not one that takes advantage of Perl's string abilities.

Hays

  • Comment on Re^3: Selecting the difference between two strings

Replies are listed 'Best First'.
Re^4: Selecting the difference between two strings
by qazwart (Scribe) on Sep 27, 2006 at 03:42 UTC
    There is a difference between a branch and a directory for a file. It just happens that the branch name is the fourth of what you called an entity. I have a few dozen branches, but tens of thousands of files, sorting the way you tell me will simply give me a sorted list of all files and not the branches.

    Second of all, although I can tell you that the branch name is the fourth entity, I cannot by simply looking at the name tell you the relationship between branches. For example:

    //Efp/Acme/MAIN/Mydir/bar.c //Efp/Acme/FOO/Mydir/bar.c //Efp/Acme/BAR/Mydir/bar.c
    In this example, MAIN, FOO, and BAR are branches. However, what are the relationship between these branches? Did both BAR and FOO branch directly off of MAIN, or did BAR branch off of MAIN, and then FOO branched off of BAR? Nothing in the name is telling you this. Maybe MAIN was what branched off of FOO. Simply sorting this information tells me nothing.

    The only way I know is by looking at the integration records that tell me for each and every file the fromBranch and the toBranch. So, I might have a few hundred records of files branching from MAIN to FOO. By stripping out the file names (which is what I want to do), and removing duplicates, I end up with a single record telling me that FOO branched off of MAIN.

    By taking these from/to branch entries, I can then reconstruct the entire tree structure of the branches. However, getting there means stripping the file information which is why I asked this query.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://575033]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2025-05-24 13:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.