Re: What are these numbers (gmtime, slice)

2019-07-08 Thread Uri Guttman

On 7/8/19 4:00 PM, Mike Small wrote:

Uri Guttman  writes:


On 7/4/19 2:41 PM, Mike Small wrote:

A co-worker was trying to take some of the elements from gmtime's return
value. He did something like the following:

$ perl -E'$,="\t";say gmtime[1..5]'

that is calling gmtime with the argument of [1..5] which is an
arrayref. so the arg to gmtime is some large address number. it is
then parsed as the timestamp and broken out. garbage in, garbage out!

Thanks Uri! That makes perfect sense now that I see it explained.

that is one reason a rule i use is to always (mostly!) use () for the 
args list to builtins. it eliminates funny arg parsing and also shows to 
the reader there is a function call with no args. it would have caught 
the error as:


    gmtime()[1..5]

should be a syntax error (didn't check).

also a better way to slice out gmtime is to assign it to an list of 
scalars or an array slice (untested):


    (undef, @gmt_parts[1..5) ) = gmtime() ;

and you can pass the list from gmtime directly to strftime (in POSIX) to 
get a formatted date.


and in scalar context, you get a formatted date too. slicing into gmtime 
isn't needed that often.


all the notes above cover localtime as well. gmtime is the basis for 
localtime and the only difference is dealing with the local timezone and 
its offset from GMT (same as UTC).


remember, write your code as if the maintainer is a homicidal maniac who 
knows where you live!!


uri

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: What are these numbers (gmtime, slice)

2019-07-08 Thread Mike Small
Uri Guttman  writes:

> On 7/4/19 2:41 PM, Mike Small wrote:
>> A co-worker was trying to take some of the elements from gmtime's return
>> value. He did something like the following:
>>
>> $ perl -E'$,="\t";say gmtime[1..5]'
>
> that is calling gmtime with the argument of [1..5] which is an
> arrayref. so the arg to gmtime is some large address number. it is
> then parsed as the timestamp and broken out. garbage in, garbage out!

Thanks Uri! That makes perfect sense now that I see it explained.

-- 
Mike Small
sma...@sdf.org

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: stupid question about to protect source code of perl web application scripting

2019-07-08 Thread Shlomi Fish
On Mon, 8 Jul 2019 15:07:41 +0700
Eko Budiharto  wrote:

> >> 2. if someone has a problem, he does not want to try to find a way to
> >> solve the problem first, and then he asks your help and then problem
> >> solved, then he is blaming the person who already helped him and
> >> claimed, that is his work. what will you do?
> >>  
> > What do you mean?
> >
> >  
> dear Shlomi,
> 
> what I mean in this one is the person has a problem, but he does not 
> make any efforts first, he just ask the solution from someone else. 
> After the problem is solved, he blames the person.
> 
> For example:
> 
> I have a problem and then I do not do anything or make my own effort and 
> then I ask your help to solve it for me. After the problem solved 
> because you helped me, I blame you instead you being grateful and thank 
> you and plus I said to anyone that I am the one who solved if instead of 
> your name.
> 

I understand now, thanks. That seems like a very ungrateful and "bastard"y
thing to do. I won't like it, but not sure how i'll act.

-- 
-
Shlomi Fish   http://www.shlomifish.org/
http://youtu.be/xZLwtc9x4yA - Anime in Real Life!! (Parody)

An apple a day keeps the doctor away.
Two apples a day will keep two doctors away.
— one of Shlomi Fish’s relatives

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: stupid question about to protect source code of perl web application scripting

2019-07-08 Thread Eko Budiharto




2. if someone has a problem, he does not want to try to find a way to
solve the problem first, and then he asks your help and then problem
solved, then he is blaming the person who already helped him and
claimed, that is his work. what will you do?


What do you mean?



dear Shlomi,

what I mean in this one is the person has a problem, but he does not 
make any efforts first, he just ask the solution from someone else. 
After the problem is solved, he blames the person.


For example:

I have a problem and then I do not do anything or make my own effort and 
then I ask your help to solve it for me. After the problem solved 
because you helped me, I blame you instead you being grateful and thank 
you and plus I said to anyone that I am the one who solved if instead of 
your name.


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: stupid question about to protect source code of perl web application scripting

2019-07-08 Thread Shlomi Fish
Hi,

On Mon, 8 Jul 2019 08:44:46 +0700
Eko Budiharto  wrote:

> dear all,
> 
> first of all, thank you for the respond of my inquiry. And then, there 
> is a few questions I would like to ask:
> 
> 1. if someone takes your works and then he steals the credit by claiming 
> the work is his work instead of your work, what will you do?
> 

First note that it never happened to me.

Anyway, in this case, I will try to find evidence that I originated the works
first, e.g:

* https://en.wikipedia.org/wiki/Wayback_Machine

* https://en.wikipedia.org/wiki/Version_control histories

* https://en.wikipedia.org/wiki/Internet_forum archives

Note that I think the most restrictive licences I used are
https://en.wikipedia.org/w/index.php?title=CC-by-nc-sa&redirect=no and
https://en.wikipedia.org/wiki/Affero_General_Public_License which also allow
asserting copyright on derivative changes.

If the person who claims my work is theirs does not sue me for infringement, I
will likely not care much:

* https://fc-solve.shlomifish.org/faq.html#abuse_of_fc_solve

* https://www.mail-archive.com/linux-il@cs.huji.ac.il/msg56378.html

> 2. if someone has a problem, he does not want to try to find a way to 
> solve the problem first, and then he asks your help and then problem 
> solved, then he is blaming the person who already helped him and 
> claimed, that is his work. what will you do?
> 

What do you mean?

> This is kind of some images of this dishonest person.
> 
> I do not mind to share my code to the person, if he does not have that 
> character.
> 
> So far, I am using the perl code for web application in a hosting 
> server. But this time, I have to create a web application on a on 
> premise server.
> 
> I am not an expert yet in perl and still learning although I know perl 
> when I got still in my university 19 years ago.
> 
> regards,
> 
> Eko Budiharto
> 
> 

-- 
-
Shlomi Fish   http://www.shlomifish.org/
The Case for File Swapping - http://shlom.in/file-swap

Do you always begin conversations this way?
— https://en.wikipedia.org/wiki/The_Princess_Bride_%28film%29

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/