Using CGI.pm to obtain a list of params - Oops! 
Author Message
 Using CGI.pm to obtain a list of params - Oops!



Quote:
>    s/(G)(\d+)/$1,sprintf($1.($2+1))/ge;

Mea culpa! Out, gremlins! I wrote the above when I should have written:

   s/(G)(\d+)/sprintf($1.($2+1))/ge;

Thanks again to Alan, Benjamin, Jon, and Mark for their excellent
suggestions.

Bill Segraves
Auburn, AL

P.S. Unless someone sees a more concise way to do the above s///, let's end
this "off subject" tangent from the original thread. I'm moving on to a
version of the program that uses CGI.pm. With the suggestions y'all have
contributed, the end result should be much better than it would have been
otherwise.



Sun, 16 May 2004 22:57:10 GMT  
 Using CGI.pm to obtain a list of params - Oops!



  >> s/(G)(\d+)/$1,sprintf($1.($2+1))/ge;

  WAS> Mea culpa! Out, gremlins! I wrote the above when I should have written:

  WAS>    s/(G)(\d+)/sprintf($1.($2+1))/ge;

that sprintf has no arguments other than the format string so it us
useless. a simple $1 . ($2 + 1) will do.

also why even grab the G? grabbing a fixed string makes little sense as
it has to do an extra copy. it may make life a little nicer in defining
the grab part but you could just remove the () and put a G in the
replacement string.

          s/G(\d+)/'G'.($1+1)/ge;

  WAS> P.S. Unless someone sees a more concise way to do the above s///,
  WAS> let's end this "off subject" tangent from the original
  WAS> thread. I'm moving on to a version of the program that uses
  WAS> CGI.pm. With the suggestions y'all have contributed, the end
  WAS> result should be much better than it would have been otherwise.

was that more concise?

uri

--

-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org



Sun, 16 May 2004 23:40:48 GMT  
 Using CGI.pm to obtain a list of params - Oops!

Quote:
>   WAS> Mea culpa! Out, gremlins! I wrote the above when I should have
written:

>   WAS>    s/(G)(\d+)/sprintf($1.($2+1))/ge;

> that sprintf has no arguments other than the format string so it us
> useless. a simple $1 . ($2 + 1) will do.

Gee, I dunno. I thought the argument was $1.($2+1). Regardless, it works
well. I'll certainly try your suggestion, though, after dinner.

Quote:
> also why even grab the G? grabbing a fixed string makes little sense as
> it has to do an extra copy. it may make life a little nicer in defining
> the grab part but you could just remove the () and put a G in the
> replacement string.

>   s/G(\d+)/'G'.($1+1)/ge;

I agree. This appears to be best. Let's try it.

Bless you, Uri! Your code works; and is more concise, as well. Thank you,
thank you, thank you!

Quote:
>   WAS> P.S. Unless someone sees a more concise way to do the above s///,
>   WAS> let's end this "off subject" tangent from the original
>   WAS> thread. I'm moving on to a version of the program that uses
>   WAS> CGI.pm. With the suggestions y'all have contributed, the end
>   WAS> result should be much better than it would have been otherwise.

> was that more concise?

Indeed it was. Thanks again, Uri.

Bill Segraves
Auburn, AL



Mon, 17 May 2004 01:47:19 GMT  
 Using CGI.pm to obtain a list of params - Oops!


Quote:


> >   WAS> Mea culpa! Out, gremlins! I wrote the above when I should have
> written:

> >   WAS>    s/(G)(\d+)/sprintf($1.($2+1))/ge;

> > that sprintf has no arguments other than the format string so it us
> > useless. a simple $1 . ($2 + 1) will do.

> Gee, I dunno. I thought the argument was $1.($2+1). Regardless, it works
> well. I'll certainly try your suggestion, though, after dinner.

O.K. Let's try your version.

   s/(G)(\d+)/$1.($2+1)/ge;

Your suggestion worked, as well. Thanks again.

Bill Segraves
Auburn, AL



Mon, 17 May 2004 02:04:04 GMT  
 Using CGI.pm to obtain a list of params - Oops!



  WAS> Mea culpa! Out, gremlins! I wrote the above when I should have
  WAS> written:
  >>
  WAS> s/(G)(\d+)/sprintf($1.($2+1))/ge;
  >>
  >> that sprintf has no arguments other than the format string so it us
  >> useless. a simple $1 . ($2 + 1) will do.
  >>

  WAS> Gee, I dunno. I thought the argument was $1.($2+1). Regardless, it works
  WAS> well. I'll certainly try your suggestion, though, after dinner.

well you SHOULD know. sprintf works fine with one argument. but then it
doesn't DO ANYTHING USEFUL. it is a NO-OP without format descriptions
and arguments for them. sprintf is the above case is superfluous.

  >> s/G(\d+)/'G'.($1+1)/ge;

  WAS> Bless you, Uri! Your code works; and is more concise, as
  WAS> well. Thank you, thank you, thank you!

blessing i don't need. heeding my comments above is usually a better
thing. :)

uri

--

-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org



Mon, 17 May 2004 05:54:34 GMT  
 Using CGI.pm to obtain a list of params - Oops!

Quote:
>   WAS> Mea culpa! Out, gremlins! I wrote the above when I should have
>   written:

>   WAS>    s/(G)(\d+)/sprintf($1.($2+1))/ge;

> that sprintf has no arguments other than the format string so it us
> useless. a simple $1 . ($2 + 1) will do.

> also why even grab the G? grabbing a fixed string makes little
> sense as it has to do an extra copy. it may make life a little
> nicer in defining the grab part but you could just remove
> the () and put a G in the replacement string.

>   s/G(\d+)/'G'.($1+1)/ge;

Hi Uri,

This is *exactly* what I suggested earlier in this thread. William said it
did not work, but it does. :)

- Mark



Mon, 17 May 2004 06:55:04 GMT  
 Using CGI.pm to obtain a list of params - Oops!



  >> s/G(\d+)/'G'.($1+1)/ge;

  M> Hi Uri,

  M> This is *exactly* what I suggested earlier in this thread. William said it
  M> did not work, but it does. :)

so you did. i wasn't following this thread then. dunno why it didn't
work for him then and it does now. definitely his problem though.

uri

--

-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org



Mon, 17 May 2004 07:11:34 GMT  
 Using CGI.pm to obtain a list of params - Oops!


Quote:


> >   WAS> Mea culpa! Out, gremlins! I wrote the above when I should have
> >   written:

> >   WAS>    s/(G)(\d+)/sprintf($1.($2+1))/ge;

> > that sprintf has no arguments other than the format string so it us
> > useless. a simple $1 . ($2 + 1) will do.

> > also why even grab the G? grabbing a fixed string makes little
> > sense as it has to do an extra copy. it may make life a little
> > nicer in defining the grab part but you could just remove
> > the () and put a G in the replacement string.

> >   s/G(\d+)/'G'.($1+1)/ge;

> Hi Uri,

> This is *exactly* what I suggested earlier in this thread. William said it
> did not work, but it does. :)

> - Mark

Gentlemen,

Well, not *exactly*, as what Mark suggested was:

s/G(\d+)/"G".($1 + 1)/e;

which lacks the "g" modifier needed for global replacement.

I stated in response:

"Mark, thanks for your suggestions; but your code doesn't perform the
intended function. ... Note: The intent is for ALL instances of the names,
as well as values, to enjoy the shift by one generation, in every place
where the generation number is cited."

Later, when Uri posted a suggestion similar to Mark's, which *did* work as
intended (Actually Uri's suggestion was unrelated to the global replacement,
i.e., "g" modifier, I had already incorporated in my code). Clearly Mark's
suggestion is not *exactly* the same as Uri's, as it does not perform the
required global replacement.

Gentlemen, both of you contributed greatly to the improvement of my code,
for which I am grateful. I wish you enough and thank you for your
suggestions.

Bill Segraves
Auburn, AL



Mon, 17 May 2004 16:47:34 GMT  
 Using CGI.pm to obtain a list of params - Oops!

Quote:



>   >> s/G(\d+)/'G'.($1+1)/ge;

>   M> Hi Uri,

>   M> This is *exactly* what I suggested earlier in this thread. William
said it
>   M> did not work, but it does. :)

> so you did. i wasn't following this thread then. dunno why it didn't
> work for him then and it does now. definitely his problem though.

Enter "sheepish" mode

Gentlemen, the reason why Mark's code didn't work for me at first was that I
had copied and pasted directly into a maintenance version of my code, and in
doing so, I accidentally wiped out the "#" at the beginning of the comment.

This was discovered on examination of the code a few minutes ago, after I
saw that two experts (Uri and Mark) were in apparent agreement that their
suggestions were identical. IMO, they are still not identical, as previously
stated.

After fixing *my* error in the comment, Mark's code, as he stated it, did
indeed work, but still does not perform the intended function. I expect that
adding the "g" modifier, as I had already done in other versions, would make
Mark's code perform the same as Uri's.

Exit "sheepish" mode"

Thanks again for your help.

Bill Segraves
Auburn, AL



Mon, 17 May 2004 17:10:03 GMT  
 Using CGI.pm to obtain a list of params - Oops!

Quote:
> well you SHOULD know. sprintf works fine with one argument. but then it
> doesn't DO ANYTHING USEFUL. it is a NO-OP without format descriptions
> and arguments for them. sprintf is the above case is superfluous.

Ouch! The AGC on my eyes/ears is not fast enough for such rapid-fire
shouting. ;-)

For now, I'll take your word for it. Thanks for your insight.

Quote:
>   >> s/G(\d+)/'G'.($1+1)/ge;

>   WAS> Bless you, Uri! Your code works; and is more concise, as
>   WAS> well. Thank you, thank you, thank you!

> blessing i don't need. heeding my comments above is usually a better
> thing. :)

Sorry. I can't retract what I wrote; but I'll take note that a simple "Thank
You" would be more appropriate for clpm.

I'm still curious why you and Mark agreed that your improvement of my Perl
code was identical to his earlier suggestion, when in fact he used double
quotes, and did not use the g-modifier. No response needed or desired,
unless it's a Perl issue.

Bill Segraves
Auburn, AL



Fri, 21 May 2004 21:15:47 GMT  
 Using CGI.pm to obtain a list of params - Oops!

Quote:

writes:



>   WAS> Mea culpa! Out, gremlins! I wrote the above when I should have
>   WAS> written:

>   WAS> s/(G)(\d+)/sprintf($1.($2+1))/ge;

>   >> that sprintf has no arguments other than the format string so it us
>   >> useless. a simple $1 . ($2 + 1) will do.

Now that I've done my homework, I think I understand what you meant when you
wrote the about; but what *you* didn't understand was what *I * meant when I
wrote what I wrote. ;-)

Based on what you wrote, it appears you thought I meant to use $1.($2+1) as
the format string, which is not what I meant at all.

So far, I've found nothing that describes the default behaviour of sprintf
in Perl, when the field specifiers are missing. That's why I took your word
for your statement in your post.

Quote:
>   WAS> Gee, I dunno. I thought the argument was $1.($2+1). Regardless, it
works
>   WAS> well. I'll certainly try your suggestion, though, after dinner.

I see I was confused by your statement about the format string, which
clearly (to me) had no correlation with what I had written (or mean to
write). Is it possible you misinterpreted what I wrote because of its
similarity to a field specifier? Personally, I doubt it, as the %-sign
associated with a field specifier is not present.

Quote:
> well you SHOULD know. sprintf works fine with one argument. but then it
> doesn't DO ANYTHING USEFUL. it is a NO-OP without format descriptions
> and arguments for them. sprintf is the above case is superfluous.

I agree, now; however, I don't see why you describe my argument as a format
string in one sentence, and then later call it the argument. As the expert,
can you tell me the default behaviour of sprintf for the above case, i.e.,
does it interpret what I specified as the field specifier or the argument?

TIA.

Bill Segraves
Auburn, AL



Sat, 22 May 2004 00:01:35 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. Using CGI.pm to obtain a list of params

2. Scrolling Lists using CGI.pm

3. Using cgi.pm's scrolling list

4. passing params to cgi prog using POST

5. Passing CGI Params to a 2nd CGI

6. Printing while simultaneously using CGI.pm and Mail::Internet.pm

7. Looking for examples using cgi.pm or form.pm

8. How to expire a cgi page using CGI.pm

9. Problems with http file upload using cgi.pm and cgi-lib.pl

10. Obtaining list of all files and subdirectories in a directory

11. values obtained from a browser in a multiple option list

12. CGI.pm: scrolling list w/o quoting

 

 
Powered by phpBB® Forum Software