program name -> perl's $0 
Author Message
 program name -> perl's $0

Anyone have a reference to all the special variable names? In particular
the perl equiv of $0, the program name?

db

--
Jan 28  First ski tow, Woodstock VT, 1914
Jan 28  Space Shuttle Challenger (51-L) explodes 74 seconds after liftoff
        killing Scobee, Smith, McNair, Resnick, Jarvis, Onizuka and McAuliffe,
        1986
Jan 28  Jimi Hendrix headlines Madison Square Garden, 1970
Jan 28* Tu bi-Shevat



Sun, 17 Jul 2005 07:50:59 GMT  
 program name -> perl's $0

$ cat >example.rb
puts $0
$ ruby example.rb
example.rb

Quote:

> Anyone have a reference to all the special variable names? In particular
> the perl equiv of $0, the program name?

> db

> --
> Jan 28     First ski tow, Woodstock VT, 1914
> Jan 28     Space Shuttle Challenger (51-L) explodes 74 seconds after liftoff
>    killing Scobee, Smith, McNair, Resnick, Jarvis, Onizuka and McAuliffe,
>    1986
> Jan 28     Jimi Hendrix headlines Madison Square Garden, 1970
> Jan 28*    Tu bi-Shevat

--
Daniel Carrera
Graduate Teaching Assistant.  Math Dept.
University of Maryland.  (301) 405-5137


Sun, 17 Jul 2005 07:55:02 GMT  
 program name -> perl's $0
Gah, I keep shooting myself in the foot when trying to use it in quotes,
thats my problem. it should ofcourse be #{$0} then. anyway, a complete
list of such variables, or a link to a page containg them would still be
nice.

db

Quote:

> $ cat >example.rb
> puts $0
> $ ruby example.rb
> example.rb


> > Anyone have a reference to all the special variable names? In particular
> > the perl equiv of $0, the program name?

> > db

> > --
> > Jan 28        First ski tow, Woodstock VT, 1914
> > Jan 28        Space Shuttle Challenger (51-L) explodes 74 seconds after liftoff
> >       killing Scobee, Smith, McNair, Resnick, Jarvis, Onizuka and McAuliffe,
> >       1986
> > Jan 28        Jimi Hendrix headlines Madison Square Garden, 1970
> > Jan 28*       Tu bi-Shevat

> --
> Daniel Carrera
> Graduate Teaching Assistant.  Math Dept.
> University of Maryland.  (301) 405-5137

--
Jan 28  First ski tow, Woodstock VT, 1914
Jan 28  Space Shuttle Challenger (51-L) explodes 74 seconds after liftoff
        killing Scobee, Smith, McNair, Resnick, Jarvis, Onizuka and McAuliffe,
        1986
Jan 28  Jimi Hendrix headlines Madison Square Garden, 1970
Jan 28* Tu bi-Shevat


Sun, 17 Jul 2005 08:03:47 GMT  
 program name -> perl's $0

Quote:

> Anyone have a reference to all the special variable names? In particular
> the perl equiv of $0, the program name?

I'm sure you can find information like that in the Pickaxe.  If not,
see lib/English.rb in the Ruby distribution.

Gavin



Sun, 17 Jul 2005 08:17:52 GMT  
 program name -> perl's $0

I don't know of any such list.  The best I can find is this (probably
incomplete) list from the ruby source:

$$: pid
$?: last status
$!: error string
$/: input record separator
$\: output record separator
$;: field separator
$,: output field separator
$.: last read line number
$=: ignorecase
$:: load path
$<: reading filename
$>: default output handle
$": already loaded files

Since most, if not all, are copied from Perl, we can probably look at the
Perl list.

Quote:

> Gah, I keep shooting myself in the foot when trying to use it in quotes,
> thats my problem. it should ofcourse be #{$0} then. anyway, a complete
> list of such variables, or a link to a page containg them would still be
> nice.

> db


> > $ cat >example.rb
> > puts $0
> > $ ruby example.rb
> > example.rb


> > > Anyone have a reference to all the special variable names? In particular
> > > the perl equiv of $0, the program name?

> > > db

> > > --
> > > Jan 28   First ski tow, Woodstock VT, 1914
> > > Jan 28   Space Shuttle Challenger (51-L) explodes 74 seconds after liftoff
> > >  killing Scobee, Smith, McNair, Resnick, Jarvis, Onizuka and McAuliffe,
> > >  1986
> > > Jan 28   Jimi Hendrix headlines Madison Square Garden, 1970
> > > Jan 28*  Tu bi-Shevat

> > --
> > Daniel Carrera
> > Graduate Teaching Assistant.  Math Dept.
> > University of Maryland.  (301) 405-5137

> --
> Jan 28     First ski tow, Woodstock VT, 1914
> Jan 28     Space Shuttle Challenger (51-L) explodes 74 seconds after liftoff
>    killing Scobee, Smith, McNair, Resnick, Jarvis, Onizuka and McAuliffe,
>    1986
> Jan 28     Jimi Hendrix headlines Madison Square Garden, 1970
> Jan 28*    Tu bi-Shevat

--
Daniel Carrera
Graduate Teaching Assistant.  Math Dept.
University of Maryland.  (301) 405-5137


Sun, 17 Jul 2005 08:21:22 GMT  
 program name -> perl's $0

Quote:

> Anyone have a reference to all the special variable names? In particular
> the perl equiv of $0, the program name?

> db

Have a look in English.rb

Quote:

> --
> Jan 28     First ski tow, Woodstock VT, 1914
> Jan 28     Space Shuttle Challenger (51-L) explodes 74 seconds after liftoff
>    killing Scobee, Smith, McNair, Resnick, Jarvis, Onizuka and McAuliffe,
>    1986
> Jan 28     Jimi Hendrix headlines Madison Square Garden, 1970
> Jan 28*    Tu bi-Shevat

--


Sun, 17 Jul 2005 08:53:54 GMT  
 program name -> perl's $0

Quote:


>> Anyone have a reference to all the special variable names? In particular
>> the perl equiv of $0, the program name?

> I'm sure you can find information like that in the Pickaxe.  If not,
> see lib/English.rb in the Ruby distribution.

> Gavin

Speaking of the Pickaxe, I see that amazon.com is offering used copies for
as little as US$10.70. I guess this is good for Rubyists in general if
bad for Dave & Andy in particular.

Also, Gavin, Matz's "Ruby Language Reference Manual" (a part of your
doc bundle) contains a list of pre-defined variables. Although the
document is a bit out-of-date, it certainly includes a description of $0.



Sun, 17 Jul 2005 08:57:38 GMT  
 program name -> perl's $0

Quote:

> Anyone have a reference to all the special variable names? In particular
> the perl equiv of $0, the program name?

http://www.ruby-lang.org/en/man-1.4/variable.html#variables

--

All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E  7C11 332A 551C 796C 9F04

  application_pgp-signature_part
< 1K Download


Sun, 17 Jul 2005 09:52:44 GMT  
 program name -> perl's $0


Quote:
> Gah, I keep shooting myself in the foot when trying to use it
> in quotes, thats my problem. it should ofcourse be #{$0}
> then. anyway, a complete list of such variables, or a link to
> a page containg them would still be nice.

fr my winpc...
C:\ruby\lib\ruby\1.7>type english.rb

alias $ERROR_INFO              $!

alias $LOADED_FEATURES         $"
alias $FS                      $;
alias $FIELD_SEPARATOR         $;
alias $OFS                     $,
alias $OUTPUT_FIELD_SEPARATOR  $,
alias $RS                      $/
alias $INPUT_RECORD_SEPARATOR  $/
alias $ORS                     $\
alias $OUTPUT_RECORD_SEPARATOR $\
alias $INPUT_LINE_NUMBER       $.
alias $NR                      $.
alias $LAST_READ_LINE          $_
alias $DEFAULT_OUTPUT          $>
alias $DEFAULT_INPUT           $<
alias $PID                     $$
alias $PROCESS_ID              $$
alias $CHILD_STATUS            $?
alias $LAST_MATCH_INFO         $~
alias $IGNORECASE              $=
alias $PROGRAM_NAME            $0
alias $ARGV                    $*
alias $MATCH                   $&
alias $PREMATCH                $`
alias $POSTMATCH               $'
alias $LAST_PAREN_MATCH        $+

Quote:
> db

kind regards -botp


Sun, 17 Jul 2005 16:22:03 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. Python equivalent of Perl's assignment to $0

2. Changing a program's name at run time via $0...

3. Perl Program to Sort CONTAINed Routines by Name

4. Appending to $0 or $_

5. variable as search-pattern: if ($0 ~ myVar)

6. executable awk scripts and shell var $(basename $0)

7. Newbie Help required: Deleting double entries in a line ($0)

8. !x[$0]++

9. mechanism of application ($0 or the line)

10. $0 == false ??

11. $0 == __FILE__ idiom for Unix only?

 

 
Powered by phpBB® Forum Software