Questions tagged [special-variables]

25 questions
2
votes
1 answer

How to get a defined ${^OPEN}?

What changes are required in this code to get a defined ${^OPEN}? #!/usr/bin/env perl use warnings; use strict; use open qw( :std :utf8 ); print ${^OPEN}; Use of uninitialized value $^OPEN in print at ./perl.pl line 6.
sid_com
  • 24,137
  • 26
  • 96
  • 187
1
vote
2 answers

The future of deprecated special variables

Are deprecated special variables (like $# and $*) lost forever or would it be possible the reuse them in a future Perl version?
sid_com
  • 24,137
  • 26
  • 96
  • 187
1
vote
2 answers

Is it possible to "dump" all of the bash special variables via a command, like env?

#!/bin/bash env This spits out a bunch of environment variables. $0, $@, $_, etc. are not output. Is there a way to dump them out, similar to how env or set dumps the rest of the environment? I don't mean anything like echo $0 or something, I…
ND Geek
  • 398
  • 6
  • 21
1
vote
2 answers

How can I find position of matched regex of a single string in Perl?

Let's say my $string = "XXXXXTPXXXXTPXXXXTP"; If I want to match: $string =~ /TP/; multiple times and return the position for each, how would I do so? I have tried$-[0], $-[1], $-[2] but I only get a position for $-[0]. EDIT: I have also tried the…
Matt
  • 13
  • 2
1
vote
3 answers

Tracking of number of elements in an array iterated?

Is there any way that number of elements iterated in an for loop can be traced in perl: Like using special variables: @arrayElements = (2,3,4,5,6,7,67); foreach (@arrayElements) { # Do something # Want to know how may elements been iterated…
0
votes
0 answers

Why is the special variables class missing from my pycharm console?

Without this class, all the special variables are displayed, which is particularly messy! I installed the same pycharm on the other computer, but did not experience the same problems.
0
votes
0 answers

Substitute variable inside another variable in bash

This is my sample bash code: exec_command(){ command_1="" command_2="" command_3="" now=$@ echo $now } for (( i=1; i<=3; i++ )); do exec_command "command_$i" Here the…
Muradin
  • 3
  • 4
0
votes
2 answers

Perl special variable "@_" in a subroutine not working

This script rips out the urls from a downloaded webpage. I had some trouble with this script - when I use the "my $csv_html_line = @_ ;" and then print out the "@html_LineArray" - it just prints out "1's". When I replace the "my $csv_html_line = @_…
capser
  • 2,442
  • 5
  • 42
  • 74
0
votes
1 answer

In Perl the IRS ($/) is changed but it seems to scroll back the reading

I did a lot of searching on the scoping when using local. I understand from here: http://www.perlmonks.org/?node_id=94007 that it changes temporarily the value of a variable in between when the "local" line is executed and when the next end of…
xor007
  • 976
  • 2
  • 12
  • 21
-1
votes
2 answers

What do $/ and $\ do?

I've found $\ = $/ when I was investigating how to merge 2 arrays, but I don't understand this at all. An example with it: use strict; $\ = $/; my @array1 = ("string1", "string2"); my @array2 = ("string3", "string4"); my @array = (@array1,…
xaxes
  • 397
  • 9
  • 21
1
2