Splunk Search

What is the difference between == and = in SPL ?

HeinzWaescher
Motivator

Hi,

I've seen it several times but don't know the difference and when to use == instead of = .
Like in these samples from the docs:

  1. | eval description=case(status == 200, "OK", status ==404, "Not found", status == 500, "Internal Server Error")

  2. | eval action=if(action=="view",...)

Thanks in advance

Tags (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

The == operator means "is equal to". The = operator means either "is equal to" or "is assigned to" depending on the context.
Either operator can be used to compare two fields/values with == more clearly indicating a comparison rather than an assignment.
Use = to assign a value to a field.

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

The == operator means "is equal to". The = operator means either "is equal to" or "is assigned to" depending on the context.
Either operator can be used to compare two fields/values with == more clearly indicating a comparison rather than an assignment.
Use = to assign a value to a field.

---
If this reply helps you, Karma would be appreciated.

HeinzWaescher
Motivator

Thanks a lot. I never used == and never ran into problems, that's why I was wondering.
So in the end it is more a cosmetical thing to use ==.

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to November Tech Talks, Office Hours, and Webinars!

🍂 Fall into November with a fresh lineup of Community Office Hours, Tech Talks, and Webinars we’ve ...

Transform your security operations with Splunk Enterprise Security

Hi Splunk Community, Splunk Platform has set a great foundation for your security operations. With the ...

Splunk Admins and App Developers | Earn a $35 gift card!

Splunk, in collaboration with ESG (Enterprise Strategy Group) by TechTarget, is excited to announce a ...