Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.advocacy > #350996 > unrolled thread

A maybe interesting code challenge

Started byDFS <nospam@dfs.com>
First post2016-04-20 11:37 -0400
Last post2016-04-28 05:46 -0400
Articles 20 on this page of 140 — 16 participants

Back to article view | Back to comp.os.linux.advocacy


Contents

  A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-20 11:37 -0400
    Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-20 08:45 -0700
      Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-20 11:57 -0400
        Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-20 09:02 -0700
        Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-21 01:54 +0000
          Re: A maybe interesting code challenge Steve Carroll <fretwizzen@gmail.com> - 2016-04-20 18:57 -0700
          Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-21 02:45 +0000
            Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-20 23:01 -0400
              Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-21 03:56 +0000
                Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-21 11:06 -0400
                  Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-21 16:13 +0000
                    Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-21 17:27 -0400
                      Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-22 19:07 +0000
    Re: A maybe interesting code challenge Steve Carroll <fretwizzen@gmail.com> - 2016-04-20 19:01 -0700
    Re: A maybe interesting code challenge Fabian Russell <fb@zen.info> - 2016-04-22 09:37 +0000
      Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-22 08:33 -0400
        Re: A maybe interesting code challenge Fabian Russell <fb@zen.info> - 2016-04-22 22:03 +0000
          Re: A maybe interesting code challenge Richard King <kingsley651@webby.org> - 2016-04-22 18:22 -0400
      Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-22 19:48 +0000
        Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-22 17:24 -0400
          Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-22 22:18 +0000
            Re: A maybe interesting code challenge Fabian Russell <fb@zen.info> - 2016-04-22 22:26 +0000
              Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-22 22:43 +0000
                Re: A maybe interesting code challenge Fabian Russell <fb@zen.info> - 2016-04-22 22:50 +0000
                  Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-22 22:57 +0000
                    Re: A maybe interesting code challenge Fabian Russell <fb@zen.info> - 2016-04-23 13:07 +0000
                      Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-23 09:58 -0400
        Re: A maybe interesting code challenge Fabian Russell <fb@zen.info> - 2016-04-22 21:48 +0000
      Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-22 17:00 -0400
        Re: A maybe interesting code challenge Fabian Russell <fb@zen.info> - 2016-04-22 21:56 +0000
          Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-22 19:39 -0400
            Re: A maybe interesting code challenge Fabian Russell <fb@zen.info> - 2016-04-23 15:25 +0000
              Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-23 13:14 -0400
                Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-23 18:37 +0000
                  Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-23 16:50 -0400
                    Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-23 21:15 +0000
                      Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-23 18:36 -0400
                        Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-23 23:24 +0000
    Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-22 08:21 -0400
      Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-22 10:04 -0400
        Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-23 00:09 -0400
          Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-23 00:18 -0400
            Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-23 05:59 +0000
              Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-26 12:46 -0400
                Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-26 19:04 +0000
                  Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-26 20:40 +0000
                    Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-26 17:48 -0400
                      Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-26 22:14 +0000
            Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-23 23:15 -0400
              Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-23 23:30 -0400
                Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-24 08:52 -0400
                  Re: A maybe interesting code challenge Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-04-24 10:06 -0400
                    Re: A maybe interesting code challenge Fabian Russell <fb@zen.info> - 2016-04-24 15:59 +0000
                Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-24 15:45 -0400
                  Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-25 10:19 -0400
                    Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-25 20:26 -0400
                      Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-25 23:24 -0400
                        Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-26 05:03 +0000
                          Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-26 11:40 -0400
    Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-25 15:14 +0000
      Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-25 12:05 -0400
        Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-25 18:06 +0000
          Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-26 12:41 -0400
            Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-26 18:03 +0000
              Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-26 17:39 -0400
                Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-27 05:50 +0000
                  Re: A maybe interesting code challenge chrisv <chrisv@nospam.invalid> - 2016-04-27 06:43 -0500
                    Re: A maybe interesting code challenge William Poaster <wp@dev.null> - 2016-04-27 13:11 +0100
                    Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-27 13:32 +0000
                  Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-27 07:32 -0700
                    Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-27 15:02 +0000
                      Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-27 08:17 -0700
                        Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-27 16:21 +0000
                          Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-27 09:42 -0700
                            Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-27 21:39 +0000
                              Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-27 23:25 +0000
                                Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-28 05:34 +0000
                                  Re: A maybe interesting code challenge vallor <vallor@cultnix.org> - 2016-04-28 05:37 +0000
                                    Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-28 05:42 +0000
                      Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-27 11:45 -0400
                        Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-27 16:23 +0000
                        Re: A maybe interesting code challenge Peter Köhlmann <peter-koehlmann@t-online.de> - 2016-04-27 18:40 +0200
                          Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-27 09:58 -0700
                            Re: A maybe interesting code challenge Peter Köhlmann <peter-koehlmann@t-online.de> - 2016-04-27 20:57 +0200
                              Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-27 12:06 -0700
                                Re: A maybe interesting code challenge Peter Köhlmann <peter-koehlmann@t-online.de> - 2016-04-27 22:44 +0200
                  Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-27 13:38 -0400
                    Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-27 11:07 -0700
                      Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-27 15:51 -0400
                        Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-27 13:30 -0700
                          Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-27 21:38 -0400
                          Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-28 11:33 -0400
                            Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-28 09:14 -0700
                              Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-28 14:17 -0400
                                Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-28 18:49 +0000
                                  Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-29 08:42 -0700
                                    Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-29 13:42 -0400
                                      Re: A maybe interesting code challenge Snit <usenet@gallopinginsanity.com> - 2016-04-29 10:54 -0700
                                        Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-29 11:20 -0700
                                        Re: Snit digest 214 / 2016-04-29 Melzzzzz <mel@zzzzz.com> - 2016-04-30 00:31 +0200
                                        Re: Snit digest 214 / 2016-04-29 DFS <nospam@dfs.com> - 2016-04-29 19:00 -0400
                                          Re: Snit digest 214 / 2016-04-29 DFS <nospam@dfs.com> - 2016-04-30 10:36 -0400
                                        Re: Snit digest 214 / 2016-04-29 chrisv <chrisv@nospam.invalid> - 2016-05-02 07:54 -0500
                                          Re: Snit digest 214 / 2016-04-29 Peter Köhlmann <peter-koehlmann@t-online.de> - 2016-05-02 15:55 +0200
                                          Re: Snit digest 214 / 2016-04-29 Snit <usenet@gallopinginsanity.com> - 2016-05-02 07:23 -0700
                                            Snit digest 215 / 2016-05-02 Sandman <mr@sandman.net> - 2016-05-02 14:39 +0000
                                              Re: Snit digest 215 / 2016-05-02 Snit <usenet@gallopinginsanity.com> - 2016-05-02 07:54 -0700
                                          Re: Snit digest 214 / 2016-04-29 Sandman <mr@sandman.net> - 2016-05-02 14:36 +0000
                                            Re: Snit digest 214 / 2016-04-29 Snit <usenet@gallopinginsanity.com> - 2016-05-02 07:53 -0700
                                      Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-29 11:11 -0700
                                    Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-29 14:44 -0700
                                    Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-29 17:53 -0400
                                      Re: A maybe interesting code challenge Melzzzzz <mel@zzzzz.com> - 2016-04-29 23:56 +0200
                                        Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-29 18:09 -0400
                                        Re: A maybe interesting code challenge Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-04-29 19:09 -0400
                                      Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-30 07:31 -0700
                                        Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-05-01 08:21 +0000
                                        Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-05-01 08:47 -0700
                                      Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-05-02 14:54 -0400
                                        Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-05-02 21:54 -0400
                            Re: A maybe interesting code challenge GreyCloud <mist@cumulus.com> - 2016-04-28 15:39 -0600
                              Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-29 08:48 -0700
                                Re: A maybe interesting code challenge GreyCloud <mist@cumulus.com> - 2016-04-29 16:57 -0600
                        Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-27 21:33 -0400
                          Re: A maybe interesting code challenge Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-04-28 05:45 -0400
                    Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-27 21:32 +0000
                      Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-27 21:48 -0400
                        Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-27 22:57 -0400
                          Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-28 05:44 +0000
                            Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-29 16:32 -0400
                        Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-27 23:05 -0400
                          Re: A maybe interesting code challenge owl <owl@rooftop.invalid> - 2016-04-28 03:20 +0000
                            Re: A maybe interesting code challenge DFS <nospam@dfs.com> - 2016-04-28 09:52 -0400
                              Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-29 02:46 -0400
                                Re: A maybe interesting code challenge Steve Carroll <fretwizzer@gmail.com> - 2016-04-29 08:33 -0700
                                  Re: A maybe interesting code challenge Norman Peelman <npeelman@cfl.rr.com> - 2016-04-30 09:31 -0400
                        Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-28 05:42 +0000
                          Re: A maybe interesting code challenge vallor <vallor@cultnix.org> - 2016-04-28 06:17 +0000
                            Re: A maybe interesting code challenge Sandman <mr@sandman.net> - 2016-04-28 06:56 +0000
                            Re: A maybe interesting code challenge Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-04-28 05:46 -0400

Page 2 of 7 — ← Prev page 1 [2] 3 4 5 6 7  Next page →


#351322

Fromowl <owl@rooftop.invalid>
Date2016-04-22 22:18 +0000
Message-ID<ghjdoa9.3ap@rooftop.invalid>
In reply to#351298
DFS <nospam@dfs.com> wrote:
> On 4/22/2016 3:48 PM, owl wrote:
>> Fabian Russell <fb@zen.info> wrote:
> 
>> state
>> GA
>> name
>> Burger King
>> zip
>> 303*
>> anon@lowtide:~/code/dfs/nah$
>>
>> FAIL!
>> That's not the correct output format.  It's supposed to output field1-field3
>> and value1-value3, regardless of whether those fields exist for a given
>> line, like below, with labels and placeholders for empty fields:
> 
> Actually, I didn't specify an output format, or any output at all.  I 
> showed an output - marked 'for testing' - just to prove the code worked. 
>  All I wanted was a program that parsed 3 different line formats 
> correctly, and declared and populated the variables.
> 
> I can't tell if your initial sed code populated any variables, but your 
> output made it look like it did.  Does your new C version declare and 
> populate 6 variables?
> 

An array of these:

struct vars{
  char field1[LINELENGTH];
  char value1[LINELENGTH];
  char field2[LINELENGTH];
  char value2[LINELENGTH];
  char field3[LINELENGTH];
  char value3[LINELENGTH];
};

[toc] | [prev] | [next] | [standalone]


#351328

FromFabian Russell <fb@zen.info>
Date2016-04-22 22:26 +0000
Message-ID<nfe8ef01h86@news3.newsguy.com>
In reply to#351322
On Fri, 22 Apr 2016 22:18:43 +0000, owl wrote:

> 
> An array of these:
> 

Ha, ha, ha, ha, ha, ha, ha, ha, ha!

What a supreme stupid fuck!

The issue here is lexical analysis, so, ideally, one
would want to utilize a tool like flex or ragel.

But quite obviously, real computer science is well beyond
your simpleton code-monkey skills.

[toc] | [prev] | [next] | [standalone]


#351331

Fromowl <owl@rooftop.invalid>
Date2016-04-22 22:43 +0000
Message-ID<ghjdoe903ra.fji@rooftop.invalid>
In reply to#351328
Fabian Russell <fb@zen.info> wrote:
> On Fri, 22 Apr 2016 22:18:43 +0000, owl wrote:
> 
>> 
>> An array of these:
>> 
> 
> Ha, ha, ha, ha, ha, ha, ha, ha, ha!
> 
> What a supreme stupid fuck!
> 
> The issue here is lexical analysis, so, ideally, one
> would want to utilize a tool like flex or ragel.
>
> But quite obviously, real computer science is well beyond
> your simpleton code-monkey skills.
> 

anon@lowtide:~/code/dfs/nah$ time ./blah input_e >output

real	0m2.718s
user	0m2.716s
sys	0m0.000s
anon@lowtide:~/code/dfs/nah$ wc -l input_e
6000 input_e
anon@lowtide:~/code/dfs/nah$ wc -l output
36000 output
anon@lowtide:~/code/dfs/nah$

Beat it or STFU.

anon@lowtide:~/code/dfs/nah$ head input_e
state=GA 
state=GA ; name = Burger King
state=GA ; name = Burger King ; zip like 303* 
city = Atlanta
state=TN ; name like Burger* ; street like Main*
state=GA ; name like *pizza ; zip = 30017
state=GA 
state=GA ; name = Burger King
state=GA ; name = Burger King ; zip like 303* 
city = Atlanta
anon@lowtide:~/code/dfs/nah$ 


anon@lowtide:~/code/dfs/nah$ head output
var field1 = 'state'
var value1 = 'GA'
var field2 = ''
var value2 = ''
var field3 = ''
var value3 = ''
var field1 = 'state'
var value1 = 'GA'
var field2 = 'name'
var value2 = 'Burger King'
anon@lowtide:~/code/dfs/nah$ 

[toc] | [prev] | [next] | [standalone]


#351333

FromFabian Russell <fb@zen.info>
Date2016-04-22 22:50 +0000
Message-ID<nfe9sf01hs3@news3.newsguy.com>
In reply to#351331
On Fri, 22 Apr 2016 22:43:14 +0000, owl wrote:

> 
> Beat it or STFU.
> 

Oh boy!  I saved 2 seconds!  Now I can enjoy another
quick sip of coffee (or maybe half a sip).  My life
has been truly enriched.

Ha, ha, ha, ha, ha, ha, ha, ha, ha, ha!

[toc] | [prev] | [next] | [standalone]


#351334

Fromowl <owl@rooftop.invalid>
Date2016-04-22 22:57 +0000
Message-ID<gjdi930a.ghjier@rooftop.invalid>
In reply to#351333
Fabian Russell <fb@zen.info> wrote:
> On Fri, 22 Apr 2016 22:43:14 +0000, owl wrote:
> 
>> 
>> Beat it or STFU.
>> 
> 
> Oh boy!  I saved 2 seconds!  Now I can enjoy another
> quick sip of coffee (or maybe half a sip).  My life
> has been truly enriched.
> 
> Ha, ha, ha, ha, ha, ha, ha, ha, ha, ha!
> 

And if it were 60 million records instead of 6000...

[toc] | [prev] | [next] | [standalone]


#351442

FromFabian Russell <fb@zen.info>
Date2016-04-23 13:07 +0000
Message-ID<nffs3702707@news3.newsguy.com>
In reply to#351334
On Fri, 22 Apr 2016 22:57:35 +0000, owl wrote:

> 
> And if it were 60 million records instead of 6000...
>

Then I'd write it in C, using a reentrant lexical parser
and parallel processing.

Or maybe I'd burn machine instructions into an FPGA.

But most probably I wouldn't even bother with such a STUPID
and IDIOTIC project and move on to more interesting and challenging
things.

[toc] | [prev] | [next] | [standalone]


#351453

FromNorman Peelman <npeelman@cfl.rr.com>
Date2016-04-23 09:58 -0400
Message-ID<nffuqr$ptq$1@dont-email.me>
In reply to#351442
On 04/23/2016 09:07 AM, Fabian Russell wrote:
> On Fri, 22 Apr 2016 22:57:35 +0000, owl wrote:
>
>>
>> And if it were 60 million records instead of 6000...
>>
>
> Then I'd write it in C, using a reentrant lexical parser
> and parallel processing.
>
> Or maybe I'd burn machine instructions into an FPGA.
>
> But most probably I wouldn't even bother with such a STUPID
> and IDIOTIC project and move on to more interesting and challenging
> things.
>

Oh, so you're *that* guy...

[toc] | [prev] | [next] | [standalone]


#351305

FromFabian Russell <fb@zen.info>
Date2016-04-22 21:48 +0000
Message-ID<nfe66l01m1r@news6.newsguy.com>
In reply to#351284
On Fri, 22 Apr 2016 19:48:41 +0000, owl wrote:

> 
> FAIL!
> That's not the correct output format.
>

Fuck you.  Your FACE is a FAIL, fucking creep-ass dog fucker.

The output is IRRELEVANT.  If you don't like it, then change
it.  I'm not wasting my fucking time on stupid output nonsense.

The fact remains that my SINGLE LINE of Perl script can process
any and all the strings.

[toc] | [prev] | [next] | [standalone]


#351292

FromDFS <nospam@dfs.com>
Date2016-04-22 17:00 -0400
Message-ID<nfe36q$bne$1@dont-email.me>
In reply to#351219
On 4/22/2016 5:37 AM, Fabian Russell wrote:
> On Wed, 20 Apr 2016 11:37:41 -0400, DFS wrote:
>
>>
>> If someone posts a 2-line perl solution, I'm hurling.
>>
>
> Ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha!
>
> The dumb-fuck Microshit lackey demonstrates his incompetence and
> idiocy yet again.
>
> Ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha!
>
> Two lines?  How about one line?
>
> How about a SINGLE SOLITARY FUCKING LINE of Perl code?
>
> Well, here is the complete Perl script and its one-line essence:
>
> #! /usr/bin/perl -w use warnings; use strict;
>
> my @vals; my $line=""; my $val="";
>
> # Take your pick of any string below by commenting/uncommenting #
> $line="state=GA"; # $line="state=GA ; name = Burger King";
> $line="state=GA ; name = Burger King ; zip like 303*";
>
> ################################################## # HERE IS THE ONE
> SINGLE SOLITARY FUCKING LINE!!!
> ##################################################
>
> $line =~ s/( like )|( = )|( ; )|[=;]/!/ig; @vals = split /!/, $line;
>
> foreach $val (@vals) { print "$val\n"; }


1 use warnings;
2 use strict;
3 my @vals;
4 my $line="";
5 my $val="";
6 $line =~ s/( like )|( = )|( ; )|[=;]/!/ig; @vals = split /!/, $line;
7 foreach $val (@vals) {
8 print "$val\n";
9 }


Where's the one-liner you keep howling about?

As written, you used at least 6 lines, and you didn't complete the task: 
you had to declare and split the string to populate 2, 4 or 6 discrete 
variables named fld1, val1, fld2, val2, fld3, val3.

Get back to us when you can follow simple directions.



> Ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha!
>
> Ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha!
>
> Let's see you beat that with your Microshit junk.

? You act like perl has anything to do with Linux. It doesn't.  It's not 
native to Linux, and it's not unique to Linux.



> The script does need some refinement but that kind of task is for
> dumb-fuck lackeys and imbecilic code monkeys.

Of course it needs refinement; look who wrote it.  You're fired for 
doing this job in a half-ass manner, then asking someone else to finish 
it for you.

I don't know perl at all, but it's probably as bad as your LibreOffice 
'Make Dollars and Cents' FAIL code.  That pile of crap had 6 FAILS in 20 
lines.




> So go to it, lackey.  Get working, dog.
>
> Ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha, ha!
>
> GNU/Linux.  The ONLY choice for REAL men.

So why do you use it?

[toc] | [prev] | [next] | [standalone]


#351308

FromFabian Russell <fb@zen.info>
Date2016-04-22 21:56 +0000
Message-ID<nfe6n411m1r@news6.newsguy.com>
In reply to#351292
On Fri, 22 Apr 2016 17:00:17 -0400, DFS wrote:

> 
> As written, you used at least 6 lines
>

All those other lines are necessary declarations and do
not officially add to the final tally.

I shouldn't have to explain that simple fact, but you
are a total dumb fuck.

The fact remains that my SINGLE LINE of Perl script
can handle any and all of those stupid strings.


> 
> you had to declare and split the string to populate 2, 4 or 6 discrete 
> variables named fld1, val1, fld2, val2, fld3, val3.
> 

As I already mentioned, I don't give a flying fuck about "output."

My SINGLE LINE does ALL the required processing.  The output
is left for stupid lackeys like you.

> 
> ? You act like perl has anything to do with Linux. It doesn't.  It's not 
> native to Linux, and it's not unique to Linux.
> 

Perl IS native to Linux.  Perl is NOT native to Microshit Windows.

On the official CPAN web site there is NO binary or source available
for Microshit.  Unofficial third-parties are the only solution for
Microshit.

[toc] | [prev] | [next] | [standalone]


#351349

FromDFS <nospam@dfs.com>
Date2016-04-22 19:39 -0400
Message-ID<nfeci2$cku$1@dont-email.me>
In reply to#351308
On 4/22/2016 5:56 PM, Fabian Russell wrote:
> On Fri, 22 Apr 2016 17:00:17 -0400, DFS wrote:
>
>>
>> As written, you used at least 6 lines
>>
>
> All those other lines are necessary declarations and do not
> officially add to the final tally.

Of course they add to the tally.  As would the variable declaration 
line(s) and variable assignment line(s) if you had done it right.

But you didn't.  And you didn't because you probably CAN'T.



> I shouldn't have to explain that simple fact, but you are a total
> dumb fuck.
>
> The fact remains that my SINGLE LINE of Perl script can handle any
> and all of those stupid strings.


"can handle" is meaningless.

I need the string parsed and the data put into variables.  Which is
exactly what I said in the first sentence of the first post in this thread:

"Parse a search string composed of 1, 2 or 3 parts, separated by a 
semicolon, into 2, 4 or 6 variables (field1, value1, etc)"

If you can't do it, just say so, but quit lying - you gibbering, fucking 
moron - that your SINGLE LINE accomplishes the challenge.




>> you had to declare and split the string to populate 2, 4 or 6
>> discrete variables named fld1, val1, fld2, val2, fld3, val3.
>>
>
> As I already mentioned, I don't give a flying fuck about "output."


I don't give a flying fuck about what you do or don't give a flying fuck 
about.  Either you answer the challenge or not.  You didn't.





> My SINGLE LINE does ALL the required processing.  The output is left
> for stupid lackeys like you.

No, lying sack of shit, your single line does NOT do all the required 
processing.

Splitting a string is 100% useless if you can't use the parts of the 
string you just split.



>> ? You act like perl has anything to do with Linux. It doesn't.
>> It's not native to Linux, and it's not unique to Linux.
>>
>
> Perl IS native to Linux.

No.  It was conceived and developed on and for Unix.

Linux "developers", having no ideas of their own, used perl to create a
variety of system utilities and tools, to the point where a Linux distro
apparently won't even boot without perl installed.

But it never was nor ever will be native to Linux.


> Perl is NOT native to Microshit Windows.  On the official CPAN web
> site there is NO binary or source available for Microshit.

Show us where on CPAN is the official binary for Linux.


The official source for perl for Windows:
http://www.cpan.org/src/5.0/perl-5.22.1.tar.gz


And: "Perl compiles on over 100 platforms"

Every compilation using the official source is just as official as every 
other compilation.



> Unofficial third-parties are the only solution for Microshit.

There's nothing unofficial about ActivePerl for Windows.  It uses the 
same perl source code found in your Gentoo slopware system, which is:

http://www.cpan.org/src/5.0/perl-5.22.1.tar.gz

[toc] | [prev] | [next] | [standalone]


#351490

FromFabian Russell <fb@zen.info>
Date2016-04-23 15:25 +0000
Message-ID<nfg45q02h8e@news6.newsguy.com>
In reply to#351349
On Fri, 22 Apr 2016 19:39:53 -0400, DFS wrote:

> 
> No, lying sack of shit, your single line does NOT do all the required 
> processing.
> 
> Splitting a string is 100% useless if you can't use the parts of the 
> string you just split.
> 

Heee, ha, ha, ha, heee, ha, ha, ha, ha!

The Dumb Fuck can't stand it!

All of his toil and sweat with VBA have been bested by a SINGLE LINE
of Perl script that was composed in about 2 minutes.

And the Dumb Fuck can't stand it!

Heee, ha, ha, ha, heee, ha, ha, ha, ha!


> 
> There's nothing unofficial about ActivePerl for Windows. 
>

For Perl to be truly native to Microshit Windows, the bosses at
Microshit would have had made the decision to include Perl
as part of the official MS Windows package.  But they did not.
Perl is NOT distributed as part of the official MS Windows package
and THEREFORE it is NOT native to Microshit Windows.

A third-party package is COMPLETELY INDEPENDENT of the official
Microshit Windows distribution.

If Perl ever became popular enough, the corrupt bastards at Microshit
would develop their own duplicate copy of Perl (like they did with
XPS for PostScript and PDF) that they would then officially distribute.

You are a cheap advocate of a cheap OS and stupidity is your main
personal characteristic.

[toc] | [prev] | [next] | [standalone]


#351505

FromDFS <nospam@dfs.com>
Date2016-04-23 13:14 -0400
Message-ID<nfgabb$45e$1@dont-email.me>
In reply to#351490
On 4/23/2016 11:25 AM, Fabian Russell wrote:
> On Fri, 22 Apr 2016 19:39:53 -0400, DFS wrote:
>
>>
>> No, lying sack of shit, your single line does NOT do all the required
>> processing.
>>
>> Splitting a string is 100% useless if you can't use the parts of the
>> string you just split.
>>
>
> Heee, ha, ha, ha, heee, ha, ha, ha, ha!
>
> The Dumb Fuck can't stand it!
>
> All of his toil and sweat with VBA have been bested by a SINGLE LINE
> of Perl script that was composed in about 2 minutes.


It doesn't work.

------------------------
my @vals;
my $val="";
foreach $val (@vals) {
print "$val\n";
------------------------

"Hey, I need some vals.  Anybody have any extra vals?"   LMAO!

You don't know how to parse the line into variables.  What a fucking idiot.

It's another one of your many code failures.




> And the Dumb Fuck can't stand it!
>
> Heee, ha, ha, ha, heee, ha, ha, ha, ha!
>
>
>>
>> There's nothing unofficial about ActivePerl for Windows.
>>
>
> For Perl to be truly native to Microshit Windows, the bosses at
> Microshit would have had made the decision to include Perl
> as part of the official MS Windows package.  But they did not.
> Perl is NOT distributed as part of the official MS Windows package
> and THEREFORE it is NOT native to Microshit Windows.
>
> A third-party package is COMPLETELY INDEPENDENT of the official
> Microshit Windows distribution.
>
> If Perl ever became popular enough, the corrupt bastards at Microshit
> would develop their own duplicate copy of Perl (like they did with
> XPS for PostScript and PDF) that they would then officially distribute.


Like the corrupt, unoriginal, cloneware FOSS bastards at Ximian did with C#?

At least MS creates their own variations.



> You are a cheap advocate of a cheap OS and stupidity is your main
> personal characteristic.

You are a low-income idiot who can't make a living with your beloved 
Linux hobbyware, and insecurity and self-aggrandizement are your main 
personal characteristics.


[toc] | [prev] | [next] | [standalone]


#351520

Fromowl <owl@rooftop.invalid>
Date2016-04-23 18:37 +0000
Message-ID<ghjdo03.af@rooftop.invalid>
In reply to#351505
DFS <nospam@dfs.com> wrote:
> On 4/23/2016 11:25 AM, Fabian Russell wrote:
>> On Fri, 22 Apr 2016 19:39:53 -0400, DFS wrote:
>>
>>>
>>> No, lying sack of shit, your single line does NOT do all the required
>>> processing.
>>>
>>> Splitting a string is 100% useless if you can't use the parts of the
>>> string you just split.
>>>
>>
>> Heee, ha, ha, ha, heee, ha, ha, ha, ha!
>>
>> The Dumb Fuck can't stand it!
>>
>> All of his toil and sweat with VBA have been bested by a SINGLE LINE
>> of Perl script that was composed in about 2 minutes.
> 
> 
> It doesn't work.
> 
> ------------------------
> my @vals;
> my $val="";
> foreach $val (@vals) {
> print "$val\n";
> ------------------------
> 
> "Hey, I need some vals.  Anybody have any extra vals?"   LMAO!
> 
> You don't know how to parse the line into variables.  What a fucking idiot.
> 
> It's another one of your many code failures.
> 

The line is parsed into variables.
To see, change:

------------------------
foreach $val (@vals) {
print "$val\n";
}
------------------------

to:

------------------------
my $i=0;
foreach $val (@vals) {
#print "$val\n";
print "\$vals[$i]: $val\n";
$i++;
}
------------------------

anon@lowtide:~/code/dfs/nah$ ./fab
state
GA
name
Burger King
zip
303*
anon@lowtide:~/code/dfs/nah$ ./fabvals
$vals[0]: state
$vals[1]: GA
$vals[2]: name
$vals[3]: Burger King
$vals[4]: zip
$vals[5]: 303*
anon@lowtide:~/code/dfs/nah$ 

[toc] | [prev] | [next] | [standalone]


#351540

FromDFS <nospam@dfs.com>
Date2016-04-23 16:50 -0400
Message-ID<nfgn1d$h5k$1@dont-email.me>
In reply to#351520
On 4/23/2016 2:37 PM, owl wrote:
> DFS <nospam@dfs.com> wrote:
>> On 4/23/2016 11:25 AM, Fabian Russell wrote:
>>> On Fri, 22 Apr 2016 19:39:53 -0400, DFS wrote:
>>>
>>>>
>>>> No, lying sack of shit, your single line does NOT do all the required
>>>> processing.
>>>>
>>>> Splitting a string is 100% useless if you can't use the parts of the
>>>> string you just split.
>>>>
>>>
>>> Heee, ha, ha, ha, heee, ha, ha, ha, ha!
>>>
>>> The Dumb Fuck can't stand it!
>>>
>>> All of his toil and sweat with VBA have been bested by a SINGLE LINE
>>> of Perl script that was composed in about 2 minutes.
>>
>>
>> It doesn't work.
>>
>> ------------------------
>> my @vals;
>> my $val="";
>> foreach $val (@vals) {
>> print "$val\n";
>> ------------------------
>>
>> "Hey, I need some vals.  Anybody have any extra vals?"   LMAO!
>>
>> You don't know how to parse the line into variables.  What a fucking idiot.
>>
>> It's another one of your many code failures.
>>
>
> The line is parsed into variables.


$vals[i] is the address of an item in array @vals.  I guess it's 
technically a scalar variable, but it's not what was asked for.

The lying Fabian clown couldn't do it.  That's why he posted his 
half-finished crapola and whined about it 'needing refinement'.  Since 
then, he's been feverishly working on it, hoping to get it right.

Well here it is:
---------------------------------------------------------------------
$line =~ s/( like )|( = )|( ; )|[=;]/!/ig; @vals = split /!/, $line;
$fld1=$vals[0];$val1=$vals[1];$fld2=$vals[2];$val2=$vals[3];$fld3=$vals[4];$val3=$vals[5];
---------------------------------------------------------------------

And now I made myself hurl with a 2-line solution I contributed to.

I couldn't get it below 20 lines in VBScript.  I might've saved 10 lines 
in regular VB or VBA with the IIf() function, but no way it could be 
done in 2 lines.

VB/Script is definitely not the right tool for the text job.





Below is my first ever perl script.

Will you make the print lines work right? I want it to output:
name - *pizza
  -
  -
name - *pizza
zip - 30303"
  -
name - *pizza
zip - 30303"
street - *Buford Hwy


I've tried all kinds of variations with quotes and backslashes and \n 
and I can't get it right.



dfstest.pl
---------------------------------------------------------------------
for (1..1) {
  parseString("name like *pizza");
  parseString("name like *pizza ; zip=30303");
  parseString("name like *pizza ; zip=30303 ; street like *Buford Hwy");
}

sub parseString{
  my $line = shift;

  #splitter from Fabian
  $line =~ s/( like )|( = )|( ; )|[=;]/!/ig;
  @vals = split /!/, $line;

  $fld1=$vals[0];$val1=$vals[1];
  $fld2=$vals[2];$val2=$vals[3];
  $fld3=$vals[4];$val3=$vals[5];

  print $fld1 - $val1;
  print $fld2 - $val2;
  print $fld3 - $val3;
}
---------------------------------------------------------------------


Thanks!





> To see, change:
>
> ------------------------
> foreach $val (@vals) {
> print "$val\n";
> }
> ------------------------
>
> to:
>
> ------------------------
> my $i=0;
> foreach $val (@vals) {
> #print "$val\n";
> print "\$vals[$i]: $val\n";
> $i++;
> }
> ------------------------
>
> anon@lowtide:~/code/dfs/nah$ ./fab
> state
> GA
> name
> Burger King
> zip
> 303*
> anon@lowtide:~/code/dfs/nah$ ./fabvals
> $vals[0]: state
> $vals[1]: GA
> $vals[2]: name
> $vals[3]: Burger King
> $vals[4]: zip
> $vals[5]: 303*
> anon@lowtide:~/code/dfs/nah$


[toc] | [prev] | [next] | [standalone]


#351548

Fromowl <owl@rooftop.invalid>
Date2016-04-23 21:15 +0000
Message-ID<ghvnjd0w9f.kk@rooftop.invalid>
In reply to#351540
DFS <nospam@dfs.com> wrote:

> 
> 
> Below is my first ever perl script.
> 
> Will you make the print lines work right? I want it to output:
> name - *pizza
>  -
>  -
> name - *pizza
> zip - 30303"
>  -
> name - *pizza
> zip - 30303"
> street - *Buford Hwy
> 
> 
> I've tried all kinds of variations with quotes and backslashes and \n 
> and I can't get it right.
> 

 print "$fld1 - $val1\n";
 print "$fld2 - $val2\n";
 print "$fld3 - $val3\n";

[toc] | [prev] | [next] | [standalone]


#351556

FromDFS <nospam@dfs.com>
Date2016-04-23 18:36 -0400
Message-ID<nfgt6t$9jk$1@dont-email.me>
In reply to#351548
On 4/23/2016 5:15 PM, owl wrote:
> DFS <nospam@dfs.com> wrote:

>> I've tried all kinds of variations with quotes and backslashes and \n
>> and I can't get it right.
>>
>
>   print "$fld1 - $val1\n";
>   print "$fld2 - $val2\n";
>   print "$fld3 - $val3\n";


I thought I tried that 8x.

Thanks



$ cscript /nologo parser.vbs 1000
0.156

$ perl parser.pl 1000
0.103

hmmm... not seeing the enormous performance increase from VBS to perl.


parser.pl
--------------------------------------------------------------------------
use Time::HiRes qw(gettimeofday tv_interval);
$t0 = [gettimeofday];
for (1..$ARGV[0]) {
  parseString("name like *pizza");
  parseString("name like *pizza ;zip=30303");
  parseString("name like *pizza ;zip=30303;street like *Buford Hwy");
  parseString("state=GA");
  parseString("state=GA;name=Burger King");
  parseString("state=GA;name=Burger King;ziplike303*");
}
$t1 = [gettimeofday];
print tv_interval $t0, $t1;

sub parseString{
  my $line = shift;
  $line =~ s/( like )|( = )|( ; )|[=;]/!/ig;
  @vals = split /!/, $line;
  $fld1=$vals[0];$val1=$vals[1];
  $fld2=$vals[2];$val2=$vals[3];
  $fld3=$vals[4];$val3=$vals[5];
}
--------------------------------------------------------------------------


How fast does the .pl code run on your system?

[toc] | [prev] | [next] | [standalone]


#351558

Fromowl <owl@rooftop.invalid>
Date2016-04-23 23:24 +0000
Message-ID<hjgdi03.arapp@rooftop.invalid>
In reply to#351556
DFS <nospam@dfs.com> wrote:
> On 4/23/2016 5:15 PM, owl wrote:
>> DFS <nospam@dfs.com> wrote:
> 
>>> I've tried all kinds of variations with quotes and backslashes and \n
>>> and I can't get it right.
>>>
>>
>>   print "$fld1 - $val1\n";
>>   print "$fld2 - $val2\n";
>>   print "$fld3 - $val3\n";
> 
> 
> I thought I tried that 8x.
> 
> Thanks
> 
> 
> 
> $ cscript /nologo parser.vbs 1000
> 0.156
> 
> $ perl parser.pl 1000
> 0.103
> 
> hmmm... not seeing the enormous performance increase from VBS to perl.
> 
> 
> parser.pl
> --------------------------------------------------------------------------
> use Time::HiRes qw(gettimeofday tv_interval);
> $t0 = [gettimeofday];
> for (1..$ARGV[0]) {
>  parseString("name like *pizza");
>  parseString("name like *pizza ;zip=30303");
>  parseString("name like *pizza ;zip=30303;street like *Buford Hwy");
>  parseString("state=GA");
>  parseString("state=GA;name=Burger King");
>  parseString("state=GA;name=Burger King;ziplike303*");
> }
> $t1 = [gettimeofday];
> print tv_interval $t0, $t1;
> 
> sub parseString{
>  my $line = shift;
>  $line =~ s/( like )|( = )|( ; )|[=;]/!/ig;
>  @vals = split /!/, $line;
>  $fld1=$vals[0];$val1=$vals[1];
>  $fld2=$vals[2];$val2=$vals[3];
>  $fld3=$vals[4];$val3=$vals[5];
> }
> --------------------------------------------------------------------------
> 
> 
> How fast does the .pl code run on your system?

0.073098

[toc] | [prev] | [next] | [standalone]


#351244

FromNorman Peelman <npeelman@cfl.rr.com>
Date2016-04-22 08:21 -0400
Message-ID<nfd4pn$lmi$1@dont-email.me>
In reply to#350996
On 04/20/2016 11:37 AM, DFS wrote:
> Parse a search string composed of 1, 2 or 3 parts, separated by a
> semicolon, into 2, 4 or 6 variables (field1, value1, etc)
>
> Search string:
> use 1 part : state=GA
> use 2 parts: state=GA ; name = Burger King
> use 3 parts: state=GA ; name = Burger King ; zip like 303*
>
> The goal is to split it up like this:
>
> if 1 part used:
>   var field1 = 'state'
>   var value1 = 'GA'
>   other vars empty
>
> if 2 parts used:
>   var field1 = 'state'
>   var value1 = 'GA'
>   var field2 = 'name'
>   var value2 = 'Burger King'
>   other vars empty
>
> if 3 parts used:
>   var field1 = 'state'
>   var value1 = 'GA'
>   var field2 = 'name'
>   var value2 = 'Burger King'
>   var field3 = 'zip'
>   var value3 = '303*'
>
> It's harder than it looks, because the code has to handle 1, 2 or 3
> parts, you have to split on = or like, there's no quotes to keep Burger
> King together, and there can be no leading or trailing spaces when the
> values are stored.  Your code also has to declare at least those 6
> variables.
>
> =======================================================================
>
> My VBScript solution, which works fine, is:
> 21 lines of parsing logic
>   1 line for the variables
>   4 lines of procedure declaration
>   5 comments
>   4 'for testing' lines
>
>
> call parseString("state=GA")
> call parseString("state=GA ; name = Burger King")
> call parseString("state=GA ; name = Burger King ; zip like 303*")
>
>
> Private Function parseString(srLine)
>
> dim criteria,fld1,val1,fld2,val2,fld3,val3
>
>
> 'count semicolons in search line, and add 1
> 'this is how many search criteria are being used
> criteria = (Len(srLine)-Len(replace(srLine,";",""))) + 1
>
>
>
> 'parse search string into components
> If criteria >= 1 Then
>   fld1  = Trim(Split(srLine,spChar(srLine))(0))
>   val1  = Trim(Split(srLine,spChar(srLine))(1))
> End If
>
> If criteria >= 2 Then
>   fld1  = Trim(Split(Split(srLine,";")(0),spChar(Split(srLine,";")(0)))(0))
>   val1  = Trim(Split(Split(srLine,";")(0),spChar(Split(srLine,";")(0)))(1))
>   fld2  = Trim(Split(Split(srLine,";")(1),spChar(Split(srLine,";")(1)))(0))
>   val2  = Trim(Split(Split(srLine,";")(1),spChar(Split(srLine,";")(1)))(1))
> End If
>
> If criteria = 3 Then
>   fld1  = Trim(Split(Split(srLine,";")(0),spChar(Split(srLine,";")(0)))(0))
>   val1  = Trim(Split(Split(srLine,";")(0),spChar(Split(srLine,";")(0)))(1))
>   fld2  = Trim(Split(Split(srLine,";")(1),spChar(Split(srLine,";")(1)))(0))
>   val2  = Trim(Split(Split(srLine,";")(1),spChar(Split(srLine,";")(1)))(1))
>   fld3  = Trim(Split(Split(srLine,";")(2),spChar(Split(srLine,";")(2)))(0))
>   val3  = Trim(Split(Split(srLine,";")(2),spChar(Split(srLine,";")(2)))(1))
> End If
>
> 'for testing
> wscript.echo "'" & fld1 & "' - '" & val1 & "'"
> wscript.echo "'" & fld2 & "' - '" & val2 & "'"
> wscript.echo "'" & fld3 & "' - '" & val3 & "'"
> wscript.echo "----------------------------"
>
> End Function
>
>
> 'parse on = or like
> Function spChar(lineToSplit)
>    spChar = "="
>    If InStr(lineToSplit,"like") > 0 Then spChar = "like"
> End Function
> =======================================================================
>
>
> If someone posts a 2-line perl solution, I'm hurling.
>


So, wouldn't it be more efficient as:

tmpc = Split(srLine,";")
criteria = tmpc.Length

...

if criteria = 1 then
   fld1 = Split(srLine,spChar(Split(srLine))
endif

if criteria = 2 then
   fld1 = Split(srLine,spChar(Split(srLine))
   fld2 = Split(srLine,spChar(Split(srLine))
endif

if criteria = 3 then
   fld1 = Split(srLine,spChar(Split(srLine))
   fld2 = Split(srLine,spChar(Split(srLine))
   fld3 = Split(srLine,spChar(Split(srLine))
endif

...

wscript.echo "'" & Trim(fld1(0)) & "' - '" & Trim(fld1(1)) & "'"
wscript.echo "'" & Trim(fld2(0)) & "' - '" & Trim(fld2(1)) & "'"
wscript.echo "'" & Trim(fld3(0)) & "' - '" & Trim(fld3(1)) & "'"



   No code tested... just thoughts.

[toc] | [prev] | [next] | [standalone]


#351253

FromDFS <nospam@dfs.com>
Date2016-04-22 10:04 -0400
Message-ID<nfdark$dld$1@dont-email.me>
In reply to#351244
On 4/22/2016 8:21 AM, Norman Peelman wrote:
> On 04/20/2016 11:37 AM, DFS wrote:
>> Parse a search string composed of 1, 2 or 3 parts, separated by a
>> semicolon, into 2, 4 or 6 variables (field1, value1, etc)
>>
>> Search string:
>> use 1 part : state=GA
>> use 2 parts: state=GA ; name = Burger King
>> use 3 parts: state=GA ; name = Burger King ; zip like 303*
>>
>> The goal is to split it up like this:
>>
>> if 1 part used:
>>   var field1 = 'state'
>>   var value1 = 'GA'
>>   other vars empty
>>
>> if 2 parts used:
>>   var field1 = 'state'
>>   var value1 = 'GA'
>>   var field2 = 'name'
>>   var value2 = 'Burger King'
>>   other vars empty
>>
>> if 3 parts used:
>>   var field1 = 'state'
>>   var value1 = 'GA'
>>   var field2 = 'name'
>>   var value2 = 'Burger King'
>>   var field3 = 'zip'
>>   var value3 = '303*'
>>
>> It's harder than it looks, because the code has to handle 1, 2 or 3
>> parts, you have to split on = or like, there's no quotes to keep Burger
>> King together, and there can be no leading or trailing spaces when the
>> values are stored.  Your code also has to declare at least those 6
>> variables.
>>
>> =======================================================================
>>
>> My VBScript solution, which works fine, is:
>> 21 lines of parsing logic
>>   1 line for the variables
>>   4 lines of procedure declaration
>>   5 comments
>>   4 'for testing' lines
>>
>>
>> call parseString("state=GA")
>> call parseString("state=GA ; name = Burger King")
>> call parseString("state=GA ; name = Burger King ; zip like 303*")
>>
>>
>> Private Function parseString(srLine)
>>
>> dim criteria,fld1,val1,fld2,val2,fld3,val3
>>
>>
>> 'count semicolons in search line, and add 1
>> 'this is how many search criteria are being used
>> criteria = (Len(srLine)-Len(replace(srLine,";",""))) + 1
>>
>>
>>
>> 'parse search string into components
>> If criteria >= 1 Then
>>   fld1  = Trim(Split(srLine,spChar(srLine))(0))
>>   val1  = Trim(Split(srLine,spChar(srLine))(1))
>> End If
>>
>> If criteria >= 2 Then
>>   fld1  =
>> Trim(Split(Split(srLine,";")(0),spChar(Split(srLine,";")(0)))(0))
>>   val1  =
>> Trim(Split(Split(srLine,";")(0),spChar(Split(srLine,";")(0)))(1))
>>   fld2  =
>> Trim(Split(Split(srLine,";")(1),spChar(Split(srLine,";")(1)))(0))
>>   val2  =
>> Trim(Split(Split(srLine,";")(1),spChar(Split(srLine,";")(1)))(1))
>> End If
>>
>> If criteria = 3 Then
>>   fld1  =
>> Trim(Split(Split(srLine,";")(0),spChar(Split(srLine,";")(0)))(0))
>>   val1  =
>> Trim(Split(Split(srLine,";")(0),spChar(Split(srLine,";")(0)))(1))
>>   fld2  =
>> Trim(Split(Split(srLine,";")(1),spChar(Split(srLine,";")(1)))(0))
>>   val2  =
>> Trim(Split(Split(srLine,";")(1),spChar(Split(srLine,";")(1)))(1))
>>   fld3  =
>> Trim(Split(Split(srLine,";")(2),spChar(Split(srLine,";")(2)))(0))
>>   val3  =
>> Trim(Split(Split(srLine,";")(2),spChar(Split(srLine,";")(2)))(1))
>> End If
>>
>> 'for testing
>> wscript.echo "'" & fld1 & "' - '" & val1 & "'"
>> wscript.echo "'" & fld2 & "' - '" & val2 & "'"
>> wscript.echo "'" & fld3 & "' - '" & val3 & "'"
>> wscript.echo "----------------------------"
>>
>> End Function
>>
>>
>> 'parse on = or like
>> Function spChar(lineToSplit)
>>    spChar = "="
>>    If InStr(lineToSplit,"like") > 0 Then spChar = "like"
>> End Function
>> =======================================================================
>>
>>
>> If someone posts a 2-line perl solution, I'm hurling.
>>
>
>
> So, wouldn't it be more efficient as:
>
> tmpc = Split(srLine,";")
> criteria = tmpc.Length
>
> ...
>
> if criteria = 1 then
>    fld1 = Split(srLine,spChar(Split(srLine))
> endif
>
> if criteria = 2 then
>    fld1 = Split(srLine,spChar(Split(srLine))
>    fld2 = Split(srLine,spChar(Split(srLine))
> endif
>
> if criteria = 3 then
>    fld1 = Split(srLine,spChar(Split(srLine))
>    fld2 = Split(srLine,spChar(Split(srLine))
>    fld3 = Split(srLine,spChar(Split(srLine))
> endif
>
> ...
>
> wscript.echo "'" & Trim(fld1(0)) & "' - '" & Trim(fld1(1)) & "'"
> wscript.echo "'" & Trim(fld2(0)) & "' - '" & Trim(fld2(1)) & "'"
> wscript.echo "'" & Trim(fld3(0)) & "' - '" & Trim(fld3(1)) & "'"
>
>
>
>    No code tested... just thoughts.


Thanks, but it won't run in VBSCript.



[toc] | [prev] | [next] | [standalone]


Page 2 of 7 — ← Prev page 1 [2] 3 4 5 6 7  Next page →

Back to top | Article view | comp.os.linux.advocacy


csiph-web