It is in $0. If you type
perl .\foo.pl arg1 ... argn
$0 will be '.\foo.pl'. You can break this apart with functions in the
File::Basename package if you need to.
Tim
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://li
"Does anybody know whether there is some equivalent in Perl to VB's
IsObject function?"
It would be helpful to have a description of the VB IsObject function, but
judging by the name, you could do something like this (untested)
sub isObject {
my %types = map {$_=>$_} qw(SCALAR ARR
"Is there an existing (semi-built-in?) solution to this problem?"
I'm not sure if this qualifies as semi-built-in, but it uses only one
"sort".
@versions =("4.0.0.10", "4.0.0.9", "4.0.1.0");
@versions = sortVersions(@versions);
print join "\n", @versions;
sub sortVersions {
# Works for
Use ref(). For example, the following
print ref bless {}; # object reference (in package main)
print "\m", ref []; # array reference
print "\n", ref {}; # hash reference
results in
main
ARRAY
HASH
Tim
This will do it
push @{$hash{$key}}, $item;
Tim
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Change
if($regvals{$envVar}->[2] == "Microsoft SML Parser")
to
if($regvals{$envVar}->[2] eq "Microsoft SML Parser")
Tim
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
The problem here
$dir =~ s/\///g;
is that the two characters you are dealing with have special meaning. The
/ is interpreted as a quote delimiter because you are using s///. The
strings inside of s/// are interpolated, so the \ is interpreted as an
escape character. Try escaping both
You are looping over all of the %ext keys, and provided that $ext{$6}
exists, assigning a value to $tad for each key. Therefore, the final value
of $tad will always be the same, i.e. the one determined by the last key.
> foreach $key ( keys %ext ) {#
> if (exists
It works for me. I suspect that your $line variable is not what you think
it is.
$line = "*line";
print "Match! $line\n" if $line =~ /^\*/;
Tim
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveS
There is nothing inherently wrong with the statement
@list = glob($filename);
but you need to provide more information. What is the value of $filename?
What is the name of a file that you expect to see in @list? What is the
working directory set to?
Tim
___
>Dear Tim,
> I might be wrong on this.
>I believe that, we can open the file for both read and write
( perl).
>something like,
> open("AA"," +>>philips.txt");
### Using this we >can read/write/a
You can't read from a file that is opened for writing. Your script actually crashes
perl on my machine. I'm not exactly sure
what you intended to do there, so I can't offer any suggestions unless you
provide more detail.
Tim
___
Perl-Win32-Users mail
Try
...
if (-T "dston"){
...
Without the quotes, dston is interpreted as a filehandle.
Tim
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
You would do it like this
while ($file =~ //g) {
# do something here based on the match data
}
See perlop in the documentation that came with your perl distribution for
further explanation. Search for //g.
Unless the patterns you match span across line boundarie
Please provide a minimal test script that exhibits the problem.
Tim
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>You're right, I was trying to figure out what's wrong and I left exec
`thaw.pl`;
>Here is the siuation:
>the following script reads the log file and starts the other scripts.
Most of them need the same data from the database.
>I'm trying to avoid running database queries again and again by stor
$srl_num_item is undefined in the child process, hence the error. What are you trying
to do, exactly? The line
exec `thaw.pl`;
is very odd---you are exec'ing the output of backticks operation,
`thaw.pl` (which executes thaw.pl in a new process).
Tim
___
John,
I am not clear on what you want to do with the data structure; but from
what you describe, the syntax looks correct. Why do you say that it does
not work?
Tim
p.s.
You can write
foreach () {
print $_;
$config{$custnum}->{$filename}->[$cnt]=$_;
h position to the beginning of
the string, but you can avoid that by adding the /c modifier (e.g. m//gc). Modifying
the target string also resets the search position.
Tim
_________
Tim Moose | T R I L O G Y
voice (51
m//gc). Modifying
the target string also resets the search position.
Tim
_________
Tim Moose | T R I L O G Y
voice (512) 874-5342
fax (512) 874-8500
"Joseph Youngquist" <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED]
03/04/2002
James,
Does the following code do what you want? The first step is ro cache the
indices of the most recent files. This can be done with a hash table,
keyed off of file name, that saves date and index. When a later date is
found, replace the current hash record. The final step is to strip all b
Greg,
Look into the Storable package.
http://aspn.activestate.com/ASPN/CodeDoc/Storable/Storable.html
Tim
_
Tim Moose | T R I L O G Y
voice (512) 874-5342
fax (512) 874-8500
___
Perl-Win32-Users mailing
One way is to use to use //g and pos. The program
while () {
while (/@(\w)/g) {
# The pos function returns the position
# where the last //g search left off. The next //g
# search wil
Better yet...
perl -ni.bak -e "print unless /^\s*subnet/" input.txt
will update input.txt and backup the original file in input.txt.bak.
Tim
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo
>Hi, I would like to parse a file and delete the entire line if it begins
with
>subnet.
>How can I do this in Perl?
>Thanks.
Step one: Type the command
perl -e "print unless /^\s*subnet/" -n infile.txt >outfile.txt
where infile.txt and outfile.txt have the obvious meaning.
Step two:
I've run into a strange performance problem that has me stumped. When processing large files, in this case 30MB, the performance of my script drags to a crawl. I've boiled the original problem down to a much smaller size and included the code at the end of the message. Here is the main loop. The l
26 matches
Mail list logo