Re: Help needed for perl rookie
ioneabu_at_yahoo.com
Date: 12/27/04
- Next message: ioneabu_at_yahoo.com: "Re: regexp match large file"
- Previous message: John Fields: "Re: Is zero even or odd?"
- In reply to: GRLCOPM: "Help needed for perl rookie"
- Next in thread: GRLCOPM: "Re: Help needed for perl rookie"
- Reply: GRLCOPM: "Re: Help needed for perl rookie"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 27 Dec 2004 14:17:37 -0800
GRLCOPM wrote:
> I am new to perl, but so far have had decent success in
writing/modifying
> code to do what I want to do. However I am stuck trying to modify the
> following code. I am sure the solution is quite simple, but I can't
> completely figure out what this piece of code does. I think it is
just
> matching up a data pattern but this is an area I am unfamiliar with.
>
> All I want to do is change the format of the data file from example
#1 to
> example #2 and need this section of code to work with the new format.
I
> would be grateful for any help provided in understanding what this
piece of
> code does and suggestions on the modification needed.
>
> If more information or a larger chunk of the code is needed please
let me
> know and I will provide.
>
> EXAMPLE #1 - Current format of data file:
> 0000000050 20041227 0000000003 'my-page.shtml'
> 0000000054 20041227 0000000004 'another-page.shtml'
> 0000000020 20041227 0000000003 'yet-another-page.shtml'
>
> EXAMPLE #2 - New format of data file:
> 0000000050|20041227|0000000003|my-page.shtml
> 0000000054|20041227|0000000004|another-page.shtml
> 0000000020|20041227|0000000003|yet-another-page.shtml
>
looks like you are replacing the spaces after the numbers with a '|'
and removing the single quotes.
s/(\d+)\s/$1|/g;
s/'//g;
maybe
> Current code that reads original data format:
>
> &LockOpen (COUNT,"$AccessFile");
> $location = tell COUNT;
> while ($line = <COUNT>) {
> if (($acc,$day,$dayacc,$uri) = ($line =~ /^(\d+) (\d+) (\d+)
'(\S+)'$/)) {
> if ($uri eq $doc_uri) {
> last;
> }
> }
> last if ($uri eq $doc_uri);
> $location = tell COUNT;
> $acc = 0;
> $dayacc = 0;
> }
>
>
> Thanks!
>
> PM
- Next message: ioneabu_at_yahoo.com: "Re: regexp match large file"
- Previous message: John Fields: "Re: Is zero even or odd?"
- In reply to: GRLCOPM: "Help needed for perl rookie"
- Next in thread: GRLCOPM: "Re: Help needed for perl rookie"
- Reply: GRLCOPM: "Re: Help needed for perl rookie"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]