Sponsored Content
Full Discussion: [Perl] Printing - Scalars
Top Forums Shell Programming and Scripting [Perl] Printing - Scalars Post 302345191 by NDxiak on Tuesday 18th of August 2009 04:15:21 PM
Old 08-18-2009
Quote:
Originally Posted by pludi
$1 and $2 are quite volatile variables, in the sense that they only start being defined after a regex with matching groups, and that they'll have a different value after the next one. Better save it to a new variable as soon as possible after the regex.

Aside from that, this is always a good idea at the beginning of your script:
Code:
#!/usr/bin/perl -W

use strict;
use warnings;

This will enable strict variable declaration (using my or our) and a few warnings that might turn into bugs down the road.
Hey,

Thank you ...

Code:
Global symbol "$content" requires explicit package name at test2.pl line 10.
Global symbol "$content" requires explicit package name at test2.pl line 11.
Global symbol "$plain_text" requires explicit package name at test2.pl line 13.
Global symbol "$content" requires explicit package name at test2.pl line 13.
Global symbol "$mystringa" requires explicit package name at test2.pl line 16.
Global symbol "$plain_text" requires explicit package name at test2.pl line 16.
Global symbol "$mystringa" requires explicit package name at test2.pl line 17.
Global symbol "$mystringb" requires explicit package name at test2.pl line 23.
Global symbol "$plain_text" requires explicit package name at test2.pl line 23.
Global symbol "$mystringb" requires explicit package name at test2.pl line 24.
Global symbol "$plain_text" requires explicit package name at test2.pl line 34.

Not sure how to fix it ?
Could you please post some example of re saving variables

Thx
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

comparing scalars contaning "DOUBLE QUOTES" as data

Hello to all, Does anyone know the solution ? Two strings A and B are present. I want to check whether B is a Substring of A. 1. The value of A is - 29 * * * /bin/ls "test" "tmp*" "log*" (Note: Pl note that A contains DOUBLEQUOTES, ASTERISK & FRONTSLASH) 2. The value of B is -... (5 Replies)
Discussion started by: rssrik
5 Replies

2. UNIX for Dummies Questions & Answers

Perl, printing a string into columns

How can I use Perl to a take a string of 10 characters and print the last five characters of the string in columns 1-5 and the first five in columns 6-10? Result: 0123456789 5 0 6 1 7 2 8 3 9 4 (5 Replies)
Discussion started by: doubleminus
5 Replies

3. Shell Programming and Scripting

Perl printing error

Hi Scripting Gurus, I am new bee in perl, and trying to write a script which must print the free disk space availability of C and E drives. Please advice. Here is the script snippet and expected output: #!/usr/bin/perl use CGI qw/:html3 :standard/; $spaceuselog =... (4 Replies)
Discussion started by: ccsaviour
4 Replies

4. Shell Programming and Scripting

Need help in printing a sql query in perl

Hi All, I have the following sql query select abcd from udbadm.log where xyz='1'. I have 16k queries similar to this with different values for xyz. I want to print the values of 'abcd' for each row. I have the following perl code, but not sure how i can print that particular... (1 Reply)
Discussion started by: userscript
1 Replies

5. Shell Programming and Scripting

Printing between 2 matches with Perl

Can we please modify this perl one-liner to print lines between pattern1 and pattern2 in a file? Currently it prints lines till pattern2. (4 Replies)
Discussion started by: anand_bh
4 Replies

6. Emergency UNIX and Linux Support

Perl - Retrieving and Printing Security Token

My script below is supposed to log in to my vB account on any vB forum I'm registered on and retrieve + print my security token. However it seems to be hit and miss. The logging in works perfectly just will not retrieve and print the security token for every forum I log in to. Code Below: ... (3 Replies)
Discussion started by: AndrewTwain
3 Replies

7. Shell Programming and Scripting

Perl: selective printing of lines

Hi, I have a file with lines like this. 2 7 18 ggcgt anna 2 7 18 hhchc sam 3 7 18 hhdjcc ross 4 7 18 hhcjd jenny 0 8 21 jjdhs sam 3 8 21 kkok bush 2 9 24 kosss BrenhamIf the values of the second column are equal, print only those lines with the least first column value. So in... (5 Replies)
Discussion started by: polsum
5 Replies

8. Shell Programming and Scripting

help with perl database printing

Hey guys i am using perl and trying to pull a list of books from a database and then populate the list in a separate TT2 file. When the list is generated there should be 39 book names. When I do the foreach statement in my tt2 below, the first statement gives me 39 Array(random number) and the... (1 Reply)
Discussion started by: Joey12
1 Replies

9. Shell Programming and Scripting

Need help in Perl Script for printing next line

I got multiple of documents in which i have to extract a line coming after a ID..The scenario is Customer ID: none VT : 002/89 Customer ID: Yes VT: 001/89 Customer ID: none VT: 006/85 Customer ID: Yes VT: 003/56 I have to extract the id which is coming after YES..The output... (7 Replies)
Discussion started by: rajkrishna89
7 Replies

10. Shell Programming and Scripting

Printing a message in file without opening it in perl

Hello friends, i have a perl script as below ... for (0 ..$#values) { ##want to print some message here in Report.txt file print `find /abc/xyz/pqr/$values" -type f -ls` >> Report.txt } I am able to get output of print `find /abc/xyz/pqr/$values" -type f -ls` >> Report.txt in... (2 Replies)
Discussion started by: harpal singh
2 Replies
libapache2-mod-perl2-2.0.7::docs::api::ModPerl::Global(3User Contributed Perl Documentalibapache2-mod-perl2-2.0.7::docs::api::ModPerl::Global(3pm)

NAME
ModPerl::Global -- Perl API for manipulating special Perl lists Synopsis use ModPerl::Global (); my $package = 'MyApache2::Package'; # make the END blocks of this package special ModPerl::Global::special_list_register(END => $package); # Execute all encoutered END blocks from this package now ModPerl::Global::special_list_call( END => $package); # delete the list of END blocks ModPerl::Global::special_list_clear( END => $package); Description "ModPerl::Global" provides an API to manipulate special perl lists. At the moment only the "END" blocks list is supported. This API allows you to change the normal Perl behavior, and execute special lists when you need to. For example "ModPerl::RegistryCooker" uses it to run "END" blocks in the scripts at the end of each request. Before loading a module containing package $package, you need to register it, so the special blocks will be intercepted by mod_perl and not given to Perl. "special_list_register" does that. Later on when you want to execute the special blocks, "special_list_call" should be called. Unless you want to call the list more than once, clear the list with "special_list_clear". API
"ModPerl::Global" provides the following methods: "special_list_call" Call the special list $ok = special_list_call($key => $package); arg1: $key ( string ) The name of the special list. At the moment only 'END' is supported. arg2: $package ( string ) what package to special list is for ret: $ok ( boolean ) true value if $key is known, false otherwise. since: 2.0.00 "special_list_clear" Clear the special list $ok = special_list_clear($key => $package); arg1: $key ( string ) The name of the special list. At the moment only 'END' is supported. arg2: $package ( string ) what package to special list is for ret: $ok ( boolean ) true value if $key is known, false otherwise. since: 2.0.00 "special_list_register" Register the special list $ok = special_list_call($key => $package); arg1: $key ( string ) The name of the special list. At the moment only 'END' is supported. arg2: $package ( string ) what package to special list is for ret: $ok ( boolean ) true value if $key is known, false otherwise. since: 2.0.00 Notice that you need to register the package before it is loaded. If you register it after, Perl has already compiled the "END" blocks and there are no longer under your control. See Also mod_perl 2.0 documentation. Copyright mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0. Authors The mod_perl development team and numerous contributors. perl v5.14.2 2011-02-08 libapache2-mod-perl2-2.0.7::docs::api::ModPerl::Global(3pm)
All times are GMT -4. The time now is 05:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy