Wim De Hul <[EMAIL PROTECTED]> writes:
> my $var = shift;
>
> I thought that shift puts a variable in an array? What does this mean?
Did you check the documentation on "shift" *before* posting
the question?
>From "Programming Perl":
3.2.143 shift
shift ARRAY
shift
This fu
"Tomasi, Chuck" <[EMAIL PROTECTED]> writes:
> For a normal array (@MyArray), one can use $#MyArray to
> get the position of the last element.
"index" is a better term
You usually don't need to use that syntax, however. Use
@MyArray in a scalar context.
$MyLen = @MyArray;
o
"Gary Hawkins" <[EMAIL PROTECTED]> writes:
> > my
> > $line=qw(1,6.944,"methane",29.6576,70617.28,"*BB",8533.32,2381.0883,0.21);
>
> Bonk. When using qw (quote words) I thought they had to be separated by white
> space:
>
> $line=qw(1 6.944 "methane" 29.6576 70617.28 "*BB" 8533.32 2381.0883 0.
"John W. Krahn" <[EMAIL PROTECTED]> writes:
> > > my $MBody = `who`;
> > > my $MBody = qx(who); # same thing
> >
> > IMHO qx() is more readable. I often miss seeing the
> > back-ticks, or see them as single-quotes during a code skim.
>
> You need an editor with good syntax highlighting. :-)
"John W. Krahn" <[EMAIL PROTECTED]> writes:
> $ perl -le'$data = "one two three four five six";
> $test = $data =~ /(\S+)\s+(\S+)\s+(\S+)/;
> print "Test 1: $test";
> ($test) = $data =~ /(\S+)\s+(\S+)\s+(\S+)/;
> print "Test 2: $test";
> $test = $data =~ /(\S+)\s+(\S+)\s+(\S+)/g;
> print "Test
> my
> $line=qw(1,6.944,"methane",29.6576,70617.28,"*BB",8533.32,2381.0883,0.21);
Bonk. When using qw (quote words) I thought they had to be separated by white
space:
$line=qw(1 6.944 "methane" 29.6576 70617.28 "*BB" 8533.32 2381.0883 0.21);
which brings up a question, what if one of the
Thanks Bob, Andrea and Members !
For those who did not follow my previous post, what I want is to have an
expression that matches something but not an empty string.
> From: "Bob Showalter"
> Hmm, why do you want to use a regex?
(1) Of course, I could use if ($key==$cid) {};
However, I just wa
- Original Message -
From: "Steve Few" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
> PROBLEM - unresolved error messages...
>
> $line= 1,6.944,"methane",29.6576,70617.28,"*BB",8533.32,2381.0883,0.21
> I use split (/,/,$line) to send each of the nine elements to an array.
>
> I get these
Herb Martin wrote:
>
> > s/%//; # replaces any '%' signs in $_ with nothing
> >
> > but, I want to replace any '%' signs in
> > $iAmAVariableHearMeRoar with nothing
>
> (Correct) Answer given by another poster:
> >> $iAmAVariableHearMeRoar =~ s/%//;
>
> The original message did IMPLY there mig
"Michael R. Wolf" wrote:
>
> "John W. Krahn" <[EMAIL PROTECTED]> writes:
>
> > my $MBody = `who`;
> > my $MBody = qx(who); # same thing
>
> IMHO qx() is more readable. I often miss seeing the
> back-ticks, or see them as single-quotes during a code skim.
You need an editor with good syntax h
James Kipp wrote:
>
> Hello
Hello,
> If I have an array of dir names and I want to capture the sub dir names and
> file
> names into an array, what is the best way to do this without overwriting the
> array each time thru? (see code below) Can I do a push or concatenate or
> something else ?
p
Andrea Holstein wrote:
>
> Wim De Hul wrote:
> >
> > I tried with:
> >
> > $_ = &snmpget($sysdescr);
> > $IOS_version = /Version (.*?)\, /i;
> >
> > When I do now: print "$1\n"; I get the IOS version
> > But when I type print "$IOS_version\n"; It displays just 1...
> > Can I get r
Wim De Hul wrote:
>
> Hey folks,
Hello,
> I'm writen a script to manage my router configuration.
> To get the IOS version I use regular expressions.
> First, I did it with:
>
> $_ = &getparameter($sysdescr_mib,"System description");# Get
> the SysDescr via SNMP
> /Version /
Correct. Sorry I did not check it before sending. It is localtime to breakout
and timelocal to come up with an epoch time.
Again, sorry for not verifying before sending.
Wags ;)
-Original Message-
From: Jonathan E. Paton [mailto:[EMAIL PROTECTED]]
Sent: Friday, December
--- Scott Lutz <[EMAIL PROTECTED]> wrote:
> I am trying to get the date to create a file named after the current
> date.
> ( running under win32 )
>
> here is the code :
> my $datestamp=`date`;
> print "File name created : $datestamp\n";
'date', on a Windows box, allows you to display or set t
> I believe you would be better off (again matter of
> opinion) using timelocal like
>
> [SNIP]
Aww... timelocal isn't in the Perl5 Pocket Reference -
which Larry Wall says is perfect. I did manage to find
localtime, maybe that might do instead. :)
Compare the documentation for timelocal and
> I am trying to get the date to create a file named
> after the current date.
> ( running under win32 )
>
> here is the code :
> my $datestamp=`date`;
> print "File name created : $datestamp\n";
Don't do that! The Win32 date command is interactive - it
expects you to change the date. Beside
1 dec 2001 the value 20011221.
Wags ;)
-Original Message-
From: Scott Lutz [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 21, 2001 15:52
To: Beginners (E-mail)
Subject: executing system call
I am trying to get the date to create a file named after the current
date.
( running under win32
I am trying to get the date to create a file named after the current
date.
( running under win32 )
here is the code :
my $datestamp=`date`;
print "File name created : $datestamp\n";
gives me no output.
any ideas??
Scott Lutz
technical support
Pacific Online
http://www.paconline.net
--
To
--- Scott Lutz <[EMAIL PROTECTED]> wrote:
> below is a snip of a script that is to monitor disk usage, and I want to
> format the output in a fashion
> like this :
>
> ___usage_in_bytes___\t___directory_name___
>
> the problem being that I can't find out what the formatting characters
> mean in
"Sharat Hegde" <[EMAIL PROTECTED]> writes:
> I need to delete an element from a list (array). The
> delete function does not seem to work.
[snip]
> delete ($myList[$i]);
Check the documentation for 'delete' and 'splice'. You'll
find that delete works on hashes, splice works on arrays.
--
Mich
below is a snip of a script that is to monitor disk usage, and I want to
format the output in a fashion
like this :
___usage_in_bytes___\t___directory_name___
the problem being that I can't find out what the formatting characters
mean in any of my books here.
Can anyone explain them ??
Thanks!
Actually there are three (maybe 4) ways...
use lib '/path/to/your/library/';
...or..
BEGIN {
@INC = ('/path/to/lib', '/path/to/sitelib/');
# ...or usr push or unshift to
# add to the current @INC
}
or...
Add the path in your environment vars...
PERL5LIB='/path/to
I never got a response for this, but I am pretty sure you can put the line
below at the top of your script and it will search where-ever you would
like...
#!C:/Perl/bin/Perl.exe -I R:/SomeOtherDir/Frameworks/
Where the path after the '-I' tells the script to include this path as a
'search' path.
Hey Curtis,
> Your "Incorrect" statement is puzzling. Sure, that code is incorrect, but
it's not what I posted.
Yes, you are correct, the two examples that I gave were not what you posted.
That is why I posted yours above mine with the indents. You asked me for an
example. I was giving you on
I am looking for some advice on where to look/start for creating a log
filter. I am looking at setting up a remote loghost and sending all system
events to it. (this in no problem.) However, I am looking at writing a
wrapper that will listen to the port and when it sees certain strings, i.e.
Yup, you need the Perl Dev Kit (unless anyone else knows another way)
http://www.activestate.com/Products/Perl_Dev_Kit/
You can either use PerlCOM to put the Perl right inside VB, or you can use
PerlCtrl (my preference) to build COM object in Perl which can then be used
by everything that support
--- Bob Showalter <[EMAIL PROTECTED]> wrote:
> > With the '=>' (a.k.a. 'fat comma'), the left side of the operator
> > does no (sic) need to be quoted IF IT DOES NOT CONTAIN WHITESPACE.
>
> Actually, it needs to be quoted if it doesn't look like an identifier,
> (with an optional leading
I know Perl is used in C and C++ but is there a way to do the same in Visual
Basic?
/g
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
> -Original Message-
> From: Curtis Poe [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 21, 2001 2:25 PM
> To: Shawn; [EMAIL PROTECTED]
> Subject: Re: resetting foreach loops and @lists
>
> ...
> With the '=>' (a.k.a. 'fat comma'), the left side of the operator
> does no (sic)
> PROBLEM - unresolved error messages...
>
> $line= 1,6.944,"methane",29.6576,70617.28,"*BB",8533.32,2381.0883,0.21
> I use split (/,/,$line) to send each of the nine elements to an array.
Try quotes enclosing the entire string and a semicolon at the end of the line,
and 'use diagnostics -verbo
> -Original Message-
> From: Michael Fowler [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 21, 2001 2:20 PM
> To: Bob Showalter
> Cc: [EMAIL PROTECTED]
> Subject: Re: Deleting from a list
>
>
> On Fri, Dec 21, 2001 at 11:36:58AM -0500, Bob Showalter wrote:
> > What version of Perl a
> -Original Message-
> From: Pierre Carette [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 21, 2001 12:40 PM
> To: Casey West
> Cc: [EMAIL PROTECTED]
> Subject: Re: How to set @INC
>
>
> There must be a config file somewhere since I uninstalled the
> regular perl
> and installed ac
Hello Mr. Showalter,
Friday, December 21, 2001, 7:14:40 AM, you wrote:
BS> As Michael said, your code looks OK. The &'s don't need to be
BS> escaped.
BS> When you construct a URL, you should run it through URI::Escape's
BS> uri_escape() method to encode any URI-special chars.
Thanks for the a
On Fri, Dec 21, 2001 at 10:17:58AM -0200, Gregory wrote:
> I try the inflate example . and dont work again
And the uncompress method?
Michael
--
Administrator www.shoebox.net
Programmer, System Administrator www.gallanttech.com
--
--
To unsubscribe, e-mail: [E
On Fri, Dec 21, 2001 at 09:36:03AM +, Sharat Hegde wrote:
> I need to delete an element from a list (array).
Array is correct. You can't delete elements from a list.
> The delete function does not seem to work. For example if I need to delete
> element number "i" from the list "myList", th
--- Shawn <[EMAIL PROTECTED]> wrote:
>
> > #!/usr/bin/perl -w
> > use strict;
> > my %test_hash = (
> > one => 'no problem',
> > two => 'still no problem'
> > );
> > print $test_hash{ one }; # prints 'no problem' (without quotes)
>
> #!/usr/bin/perl -w
>
On Fri, Dec 21, 2001 at 04:09:21AM -0600, Steve Maroney wrote:
> looks like you're using [] instead of {} ... PHP instead of PERL maybe ??
>
> %myList = ("1","a","2","b");
I'm not sure if you're serious, joking, or trying to subtly provide an
alternative solution. Whichever way you've gone, you
On Fri, Dec 21, 2001 at 11:36:58AM -0500, Bob Showalter wrote:
> What version of Perl are you using? delete() for array elements
> seems to be a 5.6 feature.
>
> If you are using an earlier version, use splice().
delete and splice behave differently in certain cases; the preferred methods
are to
I just had to put in some filler so the message would send. If you can help
me please do. Thanks in advance.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
These Perl articles are of the highest quality.
The complete developerWorks "Cultured Perl" series:
A programmer's Linux-oriented setup
http://www-106.ibm.com/developerworks/linux/library/l-plset/index.html?t=gr,p=PerlSetup
Application configuration with Perl
http://www-106.ibm.com/developerwo
thanks. worked !!
> -Original Message-
> From: Hanson, Robert [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 21, 2001 11:36 AM
> To: 'Kipp, James'; [EMAIL PROTECTED]
> Subject: RE: getting multiple dir and file names into array
>
>
> This should work...
>
> @filenames = ( @filenam
> #!/usr/bin/perl -w
> use strict;
> my %test_hash = (
> one => 'no problem',
> two => 'still no problem'
> );
> print $test_hash{ one }; # prints 'no problem' (without quotes)
#!/usr/bin/perl -w
use strict;
my %test_hash = (
my one => 'no problem',
--- Shawn <[EMAIL PROTECTED]> wrote:
> > > Bare words as hash keys.
> >
> > And that's a problem how?
>
> It's a big problem when using 'strict'...
Shawn,
Could you give an example of that?
#!/usr/bin/perl -w
use strict;
my %test_hash = (
one => 'no problem',
> s/%//; # replaces any '%' signs in $_ with nothing
>
> but, I want to replace any '%' signs in
> $iAmAVariableHearMeRoar with nothing
(Correct) Answer given by another poster:
>> $iAmAVariableHearMeRoar =~ s/%//;
The original message did IMPLY there might be MULTIPLE
'%' characters (perhaps n
There must be a config file somewhere since I uninstalled the regular perl
and installed active Perl, when I run a perlscript perl is complaining that
it can't find some standard libraries and is looking in the old perl5.6.0
directory structure,
Pierre
- Original Message -
From: "Casey W
Hi-
Can somebody please help with the following error:
install_driver(Oracle) failed: Can't load
'/usr/local/lib/perl5/site_perl/5.005/sun4-solaris/auto/DBD/Oracle/Oracle.so
' for module DBD::Oracle: ld.so.1: /usr/local/bin/perl: fatal:
libclntsh.so.1.0: open failed: No such file or directory at
$iAmAVariableHearMeRoar =~ s/%//;
Rob
-Original Message-
From: McCollum, Frank [mailto:[EMAIL PROTECTED]]
Subject: substitution
I want to replace a '%' symbol in a given string, but this string is not $_.
Maybe this is a stupid question, but how do you specify the variable that
you wan
I want to replace a '%' symbol in a given string, but this string is not $_.
Maybe this is a stupid question, but how do you specify the variable that
you want the substitution to go against??
i.e.
s/%//; # replaces any '%' signs in $_ with nothing
but, I want to replace any '%' signs in $iAmA
"John W. Krahn" <[EMAIL PROTECTED]> writes:
> my $MBody = `who`;
> my $MBody = qx(who); # same thing
IMHO qx() is more readable. I often miss seeing the
back-ticks, or see them as single-quotes during a code skim.
--
Michael R. Wolf
All mammals learn by playing!
[EMAIL PROTECTED]
> -Original Message-
> From: Shawn [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 21, 2001 11:45 AM
> To: Bob Showalter; 'John W. Krahn'; [EMAIL PROTECTED]
> Subject: Re: resetting foreach loops and @lists
>
>
>
> > > -Original Message-
> > > From: John W. Krahn [mailto:[EM
> strict won't have a problem with bareword hash keys unless they have
spaces
> and maybe some special characters. If your hash keys are always single
> words strict won't complain.
>
> Rob
Hmmm, well, I have always gotten runtime errors with it. I guess I use a
lot of spaces in my hashes... ne
> -Original Message-
> From: Ashish Srivastava [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 21, 2001 7:06 AM
> To: [EMAIL PROTECTED]
> Subject: child process in background
>
>
> hi all,
>
> how can i get:
> 1. run the child process in the back ground using
>open function.
>
strict won't have a problem with bareword hash keys unless they have spaces
and maybe some special characters. If your hash keys are always single
words strict won't complain.
Rob
-Original Message-
From: Shawn [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 21, 2001 11:45 AM
To: Bob
> > -Original Message-
> > From: John W. Krahn [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, December 20, 2001 6:10 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: resetting foreach loops and @lists
> >
> >
> > James Lum wrote:
> > ...
> > > last if ($hash{city} eq $hash2{city});
>
> -Original Message-
> From: Leon [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 21, 2001 5:05 AM
> To: [EMAIL PROTECTED]
> Subject: how to construct regexes so that it do not match null
>
>
> Without using $key == $cid,
> How to construct a pattern so that $key match $cid.
> I do
> -Original Message-
> From: Sharat Hegde [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 21, 2001 4:36 AM
> To: [EMAIL PROTECTED]
> Subject: Deleting from a list
>
>
> Hello,
>
> I need to delete an element from a list (array). The delete
> function does
> not seem to work. For e
This should work...
@filenames = ( @filenames, grep (!/^\.\.?$/ , readdir (DIR)) );
Rob
-Original Message-
From: Kipp, James [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 21, 2001 11:28 AM
To: [EMAIL PROTECTED]
Subject: getting multiple dir and file names into array
Hello
If I ha
Hello
If I have an array of dir names and I want to capture the sub dir names and
file
names into an array, what is the best way to do this without overwriting the
array each time thru? (see code below) Can I do a push or concatenate or
something else ?
Thanks
---
@dirs = qw( /dbm1/user/ /dbm2/
RE: "Use of uninitialized value in string eq at..."
>From the perldiag manpage:
Use of uninitialized value%s
(W uninitialized) An undefined value was used as if it
were already defined. It was interpreted as a "" or a
0, but maybe it was a mistake. To suppress this
warning assi
Unless you must write a client app you could always just write some CGI
scripts. Lincoln Stein's other book, Programming with CGI.pm, shows you
among other things how to upload a file through the browser (fairly trivial
actually after seeing his example). I did something like that recently
using
I use:
Windows NT(TM)
(C) Copyright 1985-1996 Microsoft Corp.
C:\>perl -v
This is perl, v5.6.1 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2001, Larry Wall
Binary build 629 provided by ActiveState Tool Corp.
http://www.ActiveState.com
B
On Dec 20, 2001 at 04:03 -0800, Pierre Carette took the soap box and proclaimed:
: I have installed Active Perl on top of the regular Perl and now the @INC is
: not pointing to the right directories anymore. Is there a config file I can
: modify to fix that?
Nope, not a config file. Provided tha
> -Original Message-
> From: John W. Krahn [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, December 20, 2001 6:10 PM
> To: [EMAIL PROTECTED]
> Subject: Re: resetting foreach loops and @lists
>
>
> James Lum wrote:
> ...
> > last if ($hash{city} eq $hash2{city});
>
> -Original Message-
> From: K.L. Hayes [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, December 20, 2001 7:34 PM
> To: [EMAIL PROTECTED]
> Subject: Interpolate in Location:
>
>
> Hello All,
>
> Could somebody please help me with this?
>
>
> print "Location:
> https://secure.whatever.co
Wim De Hul wrote:
>
> Hey folks,
>
> I'm writen a script to manage my router configuration.
> To get the IOS version I use regular expressions.
> First, I did it with:
>
> $_ = &getparameter($sysdescr_mib,"System description");# Get
> the SysDescr via SNMP
> /Version /;
>
Krish wrote:
>
> Hi,
Hello,
> I am a beginner in Perl and have a very trivial query. I have some .expect
> files in my directory structure which are spread all throughout. I want to
> convert these files (only expect files) to .expect.bak. Please let me know
> as to how this can be done using
Hi ,
I try the inflate example . and dont work again
The error is -3 (Z_DATA_ERROR) , but i can uncompress or zcat in the file
at the line command of unix.
WHAT IS WRONG or the module dont work ???
the sample is :
use strict ;
use warnings ;
use Compress::Zlib ;
hi all,
how can i get:
1. run the child process in the back ground using
open function.
2. print the "child process is running" repeadtly
while the child process is running.
3. then kill the child process only using control-C.
rgds
**
Hey folks,
I'm writen a script to manage my router configuration.
To get the IOS version I use regular expressions.
First, I did it with:
$_ = &getparameter($sysdescr_mib,"System description");# Get
the SysDescr via SNMP
/Version /;
$_ = $';
(/, /);
$
Leon wrote:
>
> Without using $key == $cid,
> How to construct a pattern so that $key match $cid.
> I do not understand why in the undermentioned script, $key match $cid.
> All explanations would be very much appreciated.
> Thanks
>
> use strict;
> my $cid = '';
> my $key = '1234';
> if ($key=~/
Walter Valenti wrote:
>
> Hi,
> someone knows, how insert text gron STDIN, without see this on the
> shell??
>
> For example for insert a password..
>
> Thanks
For reading a password, there's a CPAN module:
Term::ReadPassword.
Greetings,
Andrea
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
F
Without using $key == $cid,
How to construct a pattern so that $key match $cid.
I do not understand why in the undermentioned script, $key match $cid.
All explanations would be very much appreciated.
Thanks
use strict;
my $cid = '';
my $key = '1234';
if ($key=~/\b$cid\b/) {
print 'true';
TMTWTDI, here's my way:
sub check_pass {
local $_ = shift; # I assume a sub with one argument the password
>
> I am new here. But I need to ask what I hope is a relatively easy question.
> I am writing a script that checks a password that someone enters. I have
> what can be allowed in th
Use splice (perldoc -f splice)
To delete array index $i
splice (@myList, $i, 1)
hth,
Sudarsan
Sharat Hegde wrote:
> Hello,
>
> I need to delete an element from a list (array). The delete function does
> not seem to work. For example if I need to delete element number "i" from
> the list "myList
James Lum wrote:
> ...
> a sample of my code looks like:
>
> foreach $zrec (@file) # file with agent and city
> { chomp($zrec);
>foreach $zkey (@template) # put agent city data into hash
>{ $hash{$zkey},$zrec)=split(/\//,$zrec,2);
>}
>foreach $zrec2 (@list)
worked for me :)
looks like you're using [] instead of {} ... PHP instead of PERL maybe ??
%myList = ("1","a","2","b");
print "Before: \n";
while (($key,$val) = each(%myList)) {
print "$key --> $val\n";
}
delete($myList{"1"});
print "\n\n\n After: \n";
while (($key,$val) = each(%myLis
WOW!!! Amazing explanation !! Thank you very very much Ovid =)
But is there anyway to do the "re-converting" without using any module ?
my homework requirement is allow me to do so... ( and I don't know how to
use module yet too). Please give me a hand for a little bit more help, thank
you
very m
Prabhu Gurumurthy wrote:
>
> Hi All,
>
> I have a C program which i want to convert it into perl
> In the C program it is given like this
>
> typedef unsigned short u_int16;
> #define dataLen 4
> #define keyLen 52
> #define userkeyLen 8
> #define DataT(v) u_int1
Hello,
I need to delete an element from a list (array). The delete function does
not seem to work. For example if I need to delete element number "i" from
the list "myList", then the code
delete ($myList[$i]);
does not seem to be working. Gives a compilation error.
What is the alternative?
Looks like you are running Windows based on Outlook in header. So something
like this ought to do it:
BASIC
#!perl.exe -w
@files = `dir /s /b C:\\*.expect`;
chomp @files;
for (@files) {
s#\\##g;
$newfile = $_ . ".bak";
`move \"$_\" \"$newfi
Perl modules and functions that will be useful for this are
File::Find (type perldoc File::Find at the command prompt)
substr (perldoc -f substr)
rindex (perldoc -f rindex)
rename (perldoc -f rename)
After you have read through these docs you will be able to figure out
the perl script yourself.
h
Hi,
I am a beginner in Perl and have a very trivial query. I have some .expect
files in my directory structure which are spread all throughout. I want to
convert these files (only expect files) to .expect.bak. Please let me know
as to how this can be done using Perl script. Even pointers to shel
83 matches
Mail list logo