Reader small image

You're reading from  From PHP to Ruby on Rails

Product typeBook
Published inDec 2023
Reading LevelBeginner
PublisherPackt
ISBN-139781804610091
Edition1st Edition
Languages
Right arrow
Author (1)
Bernard Pineda
Bernard Pineda
author image
Bernard Pineda

Bernard Pineda is a seasoned developer with 20 years of web development experience. Proficient in PHP, Ruby, Python, and other backend technologies, he has taught PHP and PHP-based frameworks through video courses on platforms like LinkedIn Learning. His extensive work with Ruby and Ruby on Rails, along with curiosity in frontend development and game development, bring a diverse perspective to this book. Currently working as a Site Reliability Engineer in Silicon Valley, Bernard is always seeking new adventures.
Read more about Bernard Pineda

Right arrow

Command-line arguments

So far, we’ve added both variable and fixed (either numeric or string) values to our code. To make our scripts more generic and more usable for other folks, we can add parameters that won’t be hardcoded within the code. If you’re not familiar with the term, hardcoded is the practice of writing fixed variable values within code. In our previous examples, we added the filename that we were going to open as a fixed value – that is, to change it, we would have to change the source code. To avoid that, we could pass the script a value (a filename, in this case) that whoever runs the script can change. Passing values to a script is what we commonly refer to as command-line arguments. We can have multiple arguments, a single argument, or as we’ve done so far, no arguments. Let’s start with a simple example, then work our way up to more complex examples that will help us make our scripts more generic.

Let’s start by...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
From PHP to Ruby on Rails
Published in: Dec 2023Publisher: PacktISBN-13: 9781804610091

Author (1)

author image
Bernard Pineda

Bernard Pineda is a seasoned developer with 20 years of web development experience. Proficient in PHP, Ruby, Python, and other backend technologies, he has taught PHP and PHP-based frameworks through video courses on platforms like LinkedIn Learning. His extensive work with Ruby and Ruby on Rails, along with curiosity in frontend development and game development, bring a diverse perspective to this book. Currently working as a Site Reliability Engineer in Silicon Valley, Bernard is always seeking new adventures.
Read more about Bernard Pineda