$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
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)
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)
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)
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)
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)
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)
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)
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)
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
LEARN ABOUT DEBIAN
class::makemethods::attribute
MakeMethods::Attribute(3pm) User Contributed Perl Documentation MakeMethods::Attribute(3pm)NAME
Class::MakeMethods::Attribute - Declare generated subs with attribute syntax
SYNOPSIS
package MyObject;
use Class::MakeMethods::Attribute 'Standard::Hash';
sub new :MakeMethod('new');
sub foo :MakeMethod('scalar');
sub bar :MakeMethod('scalar', { hashkey => 'bar_data' });
sub debug :MakeMethod('Standard::Global:scalar');
DESCRIPTION
This package allows common types of methods to be generated via a subroutine attribute declaration. (Available in Perl 5.6 and later.)
Adding the :MakeMethod() attribute to a subroutine declaration causes Class::MakeMethods to create and install a subroutine based on the
parameters given to the :MakeMethod attribute.
You can declare a default method-generation class by passing the name of a MakeMethods subclass in the use Class::MakeMethods::Attribute
statement. This default method-generation class will also apply as the default to any subclasses declared at compile time. If no default
method-generation class is selected, you will need to fully-qualify all method type declarations.
EXAMPLE
Here's a typical use of Class::MakeMethods::Attribute:
package MyObject;
use Class::MakeMethods::Attribute 'Standard::Hash';
sub new :MakeMethod('new');
sub foo :MakeMethod('scalar');
sub bar :MakeMethod('scalar', { hashkey => 'bar_data' });
sub debug :MakeMethod('Standard::Global:scalar');
package MySubclass;
use base 'MyObject';
sub bazzle :MakeMethod('scalar');
This is equivalent to the following explicit Class::MakeMethods invocations:
package MyObject;
use Class::MakeMethods (
-MakerClass => 'Standard::Hash',
new => 'new',
scalar => 'foo',
scalar => [ 'ba', { hashkey => 'bar_data' } ],
'Standard::Global:scalar' => 'debug',
);
package MySubclass;
use base 'MyObject';
use Class::MakeMethods (
-MakerClass => 'Standard::Hash',
scalar => 'bazzle',
);
DIAGNOSTICS
The following warnings and errors may be produced when using Class::MakeMethods::Attribute to generate methods. (Note that this list does
not include run-time messages produced by calling the generated methods, or the standard messages produced by Class::MakeMethods.)
Can't apply MakeMethod attribute to %s declaration.
You can not use the ":MakeMethod" attribute with lexical or anonymous subroutine declarations.
No method type provided for MakeMethod attribute.
You called ":MakeMethod()" without the required method-type argument.
SEE ALSO
See Attribute::Handlers byEDamian Conway.
See Class::MakeMethods for general information about this distribution.
perl v5.10.1 2004-09-06 MakeMethods::Attribute(3pm)