Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
SynVisions
Jun 29, 2003

http://perldoc.perl.org/perlvar.html posted:

# $PROCESS_ID
# $PID
# $$

The process number of the Perl running this script. You should consider this variable read-only, although it will be altered across fork() calls. (Mnemonic: same as shells.)

Just as it says, you get the same behavior with your shell, try echo $$ which will return the PID of the current shell.

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->
$$ is a variable, the pid of the process iirc.

You want "\$" for a literal $

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

Bob Morales posted:

Why does
code:
print "$$";
Give me the following result:
code:
22324

http://perldoc.perl.org/perlvar.html is your friend if you see a special variable you don't recognize (Ctrl+F for the variable, $$ in this case):

quote:

$PROCESS_ID
$PID
$$

The process number of the Perl running this script. You should consider this variable read-only, although it will be altered across fork() calls. (Mnemonic: same as shells.)

Note for Linux users: on Linux, the C functions getpid() and getppid() return different values from different threads. In order to be portable, this behavior is not reflected by $$ , whose value remains consistent across threads. If you want to call the underlying getpid() , you may use the CPAN module Linux::Pid .

e: whoa <quake 3 guy voice>TRIPLE KILL</quake 3 guy voice>

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

Otto Skorzeny posted:

http://perldoc.perl.org/perlvar.html is your friend if you see a special variable you don't recognize (Ctrl+F for the variable, $$ in this case):

Awesome. Searching "Perl $$" on Google didn't help much.

tripwire
Nov 19, 2004

        ghost flow

Bob Morales posted:

Awesome. Searching "Perl $$" on Google didn't help much.

Somewhat of a non-perl question, but on that note, is there any way of forcing google to NOT ignore punctuation and other non-alphanumeric characters?

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

tripwire posted:

Somewhat of a non-perl question, but on that note, is there any way of forcing google to NOT ignore punctuation and other non-alphanumeric characters?

Iirc they convert all letters to lowercase and ignore non-word characters, so effectively their index just contains words made of [a-z0-9_] :(

slipped
Jul 12, 2001

Bob Morales posted:

Awesome. Searching "Perl $$" on Google didn't help much.
all perl docs are available in .... perldoc
perldoc perlvar
/\$\$

alternatively, perldoc -v '$$' or perldoc -v \$\$ produces a narrowed down result

Vanadium
Jan 8, 2005

Otto Skorzeny posted:

Iirc they convert all letters to lowercase and ignore non-word characters, so effectively their index just contains words made of [a-z0-9_] :(

Except for "C++" :c00lbert:

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

tripwire posted:

Somewhat of a non-perl question, but on that note, is there any way of forcing google to NOT ignore punctuation and other non-alphanumeric characters?

Cuil returns the answer I wanted, but a lot of their links are to dead sites. :(

Oh well, enough search engines-back to Perl.

uG
Apr 23, 2003

by Ralp
Is there a way to tell if the perl my host is running is fastcgi savvy?

The FCGI module doesn't even mention anything about needing a different perl build. Catalyst just says you need mod_fastcgi installed and configured. So I finally talk my host into installing mod_fastcgi, and now i'm reading that I need a special perl build? Good grief...

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

uG posted:

Is there a way to tell if the perl my host is running is fastcgi savvy?

The FCGI module doesn't even mention anything about needing a different perl build. Catalyst just says you need mod_fastcgi installed and configured. So I finally talk my host into installing mod_fastcgi, and now i'm reading that I need a special perl build? Good grief...

This was true when FCGI was new, but is no longer the case.

uG
Apr 23, 2003

by Ralp

Otto Skorzeny posted:

This was true when FCGI was new, but is no longer the case.
Thank loving god. I was about to give up catalyst for a minute...

uG
Apr 23, 2003

by Ralp
So i've been messing with Catalyst more and more and i've run into something that i'm sure DBIx::Class can take care of that i'm accomplishing in a completely foolish manner.

I have the follow tables: posts and users. posts has a belongs_to(user) and users has a has_many(posts). Now say I want to update posts, i'd do

code:
my $title = 'something';
my $new_post = $post_resultset->update({title => $title, body => 'some more something'});
And say I want to update users such that
code:
$user_resultset->update({last_post => $title});
(Ignore that its stupid to store a users last post inside the users row, its just to explain my problem)

As you can see i'm using two updates. However i'm pretty sure I should be able to do it all in one. Something like

code:
$post_resultset->update({title => $title, body => 'some more something'}, users_accessor => {last_post => $title})
So, is there a way to update all related results at once? Am I even making sense?

Mario Incandenza
Aug 24, 2000

Tell me, small fry, have you ever heard of the golden Triumph Forks?
Not really; update() doesn't take any arguments other than column values, so it's not really possible to specify a join condition as part of your update. Plus not all databases support joined updates (SQLite doesn't, anyway). However, there's nothing from stopping you from getting direct access to the underlying $dbh inside your resultset class and writing some SQL that does what you need.

uG
Apr 23, 2003

by Ralp

Mario Incandenza posted:

Not really; update() doesn't take any arguments other than column values, so it's not really possible to specify a join condition as part of your update. Plus not all databases support joined updates (SQLite doesn't, anyway). However, there's nothing from stopping you from getting direct access to the underlying $dbh inside your resultset class and writing some SQL that does what you need.
So is there a good way using FormFu to update multiple tables? Originally I was doing all the param checking manually and calling each table's resultset to update, but this makes for a giant mess of code. I'm hoping FormFu has a way to easily update multiple tables, it's just I dont think I quite understand html::formfu::model::dbic that well. To populate the form im using a $form->model->default_values for each table's row_object. Should I use that same approach for doing the updates?

EDIT: i'm looking at HTML::FormBuilder instead now as I think it can accomplish this easier than HTML::FormFu

uG fucked around with this message at 05:25 on Mar 30, 2010

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Anybody know of a good module that lets me embed a graph (G={V,E}, as opposed to a chart) in a PerlTK/GTK/etc canvas, and would let me set up mouse handler callbacks, etc? Neither GraphViz nor Graph::Easy seem to have anything like this, and the only things I've found in CPAN (Tk::GraphViz, Gtk2::Ex::GraphViz) seem to be broken. :(

uG
Apr 23, 2003

by Ralp
DBIX::Class question...

code:
sub wide {
	my ($self) = @_;

	return $self->search(undef, {where => 'x > y', order_by => \'RAND()'});
}
That is a resultset method package WebApp::Schema::ResultSet::Banner;. When I do $rs = $c->model('DBIC::Banner')->wide which searches all DBIC::Banner's tables to see which ones x column is greater than their y column and returns a resultset.

However, when I do

code:
my $rs = $schema->resultset('DBIC::Affiliate')->search(some search);
# Affiliate has_many bar, bar has_many banners (model('DBIC::Banner'))
my $rs2 = $Affiliate_resultset->bar->banners->wide;
in the above code, I *think* it should be as simple as running the wide method on banners, which I thought would be the same as $Affiliate_resultset->bar->banners->search(undef, {where => 'x > y', order_by => \'RAND()'}); but i'm guessing searching through the accessor doesn't work like searching on a resultset class since its not returning any resultsets? Or is something else likely the target, since i'm not getting any actual errors?

uG fucked around with this message at 08:00 on Apr 5, 2010

Mario Incandenza
Aug 24, 2000

Tell me, small fry, have you ever heard of the golden Triumph Forks?
5.12.0 is out :toot:

Lots of changes and new stuff, perl5120delta here

Mario Incandenza fucked around with this message at 08:07 on Apr 13, 2010

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
Reading the core module updates introduced me to several things I either didn't know existed or didn't know were in core. Hello, Text::Soundex

Mario Incandenza
Aug 24, 2000

Tell me, small fry, have you ever heard of the golden Triumph Forks?
Anybody had much experience with the various distributed worker libraries like Gearman, TheSchwartz, and Cantella? Any advice to offer, or other libraries that would be worth trying out while I'm at it?

leedo
Nov 28, 2000

Anyone else going to YAPC this year? I met a few of you last year and had a pretty good time (apart from getting sick after the big dinner.)

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

leedo posted:

Anyone else going to YAPC this year? I met a few of you last year and had a pretty good time (apart from getting sick after the big dinner.)

Sartak/Filburt Shellback mentioned he's giving a talk again

I'm broke and thus working 10x6 for the summer so I can't be there :(

leedo
Nov 28, 2000

Otto Skorzeny posted:

Sartak/Filburt Shellback mentioned he's giving a talk again

I'm broke and thus working 10x6 for the summer so I can't be there :(

Bummer, I managed to get my employer to send me again (yay!) I am definitely going to be checking out Sartak's "Nonhierarchical OOP‎" talk since I still have trouble recognizing good uses for roles.

Mithaldu
Sep 25, 2007

Let's cuddle. :3:

leedo posted:

Sartak's "Nonhierarchical OOP‎"
Is there an online version of that somewhere? Or a book or whatever?

leedo
Nov 28, 2000

Mithaldu posted:

Is there an online version of that somewhere? Or a book or whatever?

http://yapc2010.com/yn2010/talk/2634

Not sure that slides exist yet since it is still more than a month off.

This looks like a pretty comprehensive collection of links on the topic. Chromatic also wrote a big series of posts about it.

Mithaldu
Sep 25, 2007

Let's cuddle. :3:

leedo posted:

slides
Ugh, I wonder why people bother publishing those. Without the talk to accompany them (even if it's only in note form) they're not much more than cruel teasers. :(

leedo posted:

This looks like a pretty comprehensive collection of links on the topic. Chromatic also wrote a big series of posts about it.
Thanks for those though, I've really taken a liking to chromatic's blog, so those entries should be good. :)

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!

Mithaldu posted:

Is there an online version of that somewhere? Or a book or whatever?

Yes but only because I gave the talk during OSDC.tw last weekend: http://sartak.org/talks/osdc.tw-2010/nonhierarchical-oop/

I'm also giving a twenty minute talk on my Path::Dispatcher (which is not yet written).

I look forward to actually meeting some of you dudes at YAPC. Last year I was kinda shy about goons.

Filburt Shellbach fucked around with this message at 03:13 on May 4, 2010

Mithaldu
Sep 25, 2007

Let's cuddle. :3:

Filburt Shellbach posted:

Yes but only because I gave the talk during OSDC.tw last weekend: http://sartak.org/talks/osdc.tw-2010/nonhierarchical-oop/

:aaaaa:

Thanks a lot for this! That's the best way to represent a talk I've ever seen.

Filburt Shellbach
Nov 6, 2007

Apni tackat say tujay aaj mitta juu gaa!
Nonhierarchical Poop

yatagan
Aug 31, 2009

by Ozma
I'm using Net:FTP and retrieving a large directory listing, and I get the following output:

Net::FTP=GLOB(0x285454)>>> LIST outgoing
Net::FTP=GLOB(0x285454)<<< 150 Connecting to port 64474
Net::FTP=GLOB(0x285454)<<< 226-ASCII
Net::FTP=GLOB(0x285454)<<< 226-Options: -l
Net::FTP=GLOB(0x285454)<<< 226 Output truncated to 2000 matches

I'm trying to iterate through the entire list like this:

code:
for my $fileName ($ftp_>dir($remoteDir)) {
   ...
}
Is this a problem with the FTP server or Net::FTP? I don't get truncation when using built in solaris ftp binary.

Rohaq
Aug 11, 2006

yatagan posted:

I'm using Net:FTP and retrieving a large directory listing, and I get the following output:

Net::FTP=GLOB(0x285454)>>> LIST outgoing
Net::FTP=GLOB(0x285454)<<< 150 Connecting to port 64474
Net::FTP=GLOB(0x285454)<<< 226-ASCII
Net::FTP=GLOB(0x285454)<<< 226-Options: -l
Net::FTP=GLOB(0x285454)<<< 226 Output truncated to 2000 matches

I'm trying to iterate through the entire list like this:

code:
for my $fileName ($ftp_>dir($remoteDir)) {
   ...
}
Is this a problem with the FTP server or Net::FTP? I don't get truncation when using built in solaris ftp binary.
'Output truncated to 2000 matches' is an FTP error message, usually from a Pure-FTP server I think? There's an option in the server configuration to alter the limit, if you have access.

mister_gosh
May 24, 2002

I'm setting up a bunch of client machines with some custom programs. Most are working except one. I'm getting the error:

code:
Can't locate FooBar.pm in @INC (@INC contains: C:\Acme C:\Perl\LIB 
C:\FooBar C:/Perl/site/lib C:/Perl/lib)
The package FooBar.pm is definitely in C:\FooBar so I'm not getting why it won't find it. It finds it on other client installs.

Rohaq
Aug 11, 2006

mister_gosh posted:

I'm setting up a bunch of client machines with some custom programs. Most are working except one. I'm getting the error:

code:
Can't locate FooBar.pm in @INC (@INC contains: C:\Acme C:\Perl\LIB 
C:\FooBar C:/Perl/site/lib C:/Perl/lib)
The package FooBar.pm is definitely in C:\FooBar so I'm not getting why it won't find it. It finds it on other client installs.
Looking at your error, I'm thinking use forward slashes in your paths instead of backslashes?

It doesn't make a difference in Windows, but it does in unix, and since perl has its roots in unix, that could be a likely cause.

Mithaldu
Sep 25, 2007

Let's cuddle. :3:

mister_gosh posted:

I'm setting up a bunch of client machines with some custom programs. Most are working except one. I'm getting the error:

code:
Can't locate FooBar.pm in @INC (@INC contains: C:\Acme C:\Perl\LIB 
C:\FooBar C:/Perl/site/lib C:/Perl/lib)
The package FooBar.pm is definitely in C:\FooBar so I'm not getting why it won't find it. It finds it on other client installs.

Download Process Monitor from windows technet, run it, and run your script once. Then check the log to see where it actually searches for FooBar.pm.

mister_gosh
May 24, 2002

Wow, so this is how the PERL5LIB was defined:

code:
C:\PERL\LIB;C:\FOOBAR 
                      ^
I put in an extra line with a caret to note where the rogue space was. Really? It doesn't just chop that off?

Thanks guys!

Ninja Rope
Oct 22, 2005

Wee.
I don't recall if this was covered already, but can someone give me a rundown of the various web frameworks? CGI::Application/Titanium, Maypole, Catalyst, Jifty, etc?

I've been putting together a simple site for a non-work project and I figured it would be a good excuse to learn a framework but it seemed like none of them integrated well with fastcgi, and the ones that did would take too long to learn. They're all probably too large for something simple like what I'm working on, but I'd still like recommendations for what to look at for the next time a big project comes along.

Mario Incandenza
Aug 24, 2000

Tell me, small fry, have you ever heard of the golden Triumph Forks?
CGI::App's great for simple web apps with only a few different pages. Once you pass ~5 screens, or you need to glue together a bunch of different models, start looking at Catalyst. Stick to the same template system and ORM across the board if you can help it, Template::Toolkit and DBIC are usually good enough for most people's needs. Both CGI::App and Catalyst support FastCGI easily - Catalyst does it out-of-the-box, CGI::App has a helper module on CPAN.

mister_gosh
May 24, 2002

This code is printing, simply "Error: 18":

code:
  my $iError = &foo();
  if ($iError) {
    print "Error: $iError\n";
    exit(1);
  }
  
  sub foo {
   
   my $iError;

   if($^O eq "MSWin32") {
      eval "use Win32::Process";
      my $oProcess;
      Win32::Process::Create($oProcess,$something,'"'.$something.'"
           "'.$somethingElse.'"',0,NORMAL_PRIORITY_CLASS|DETACHED_PROCESS,$dir);
      $iError=Win32::GetLastError();
   }
    return $iError;
  }
What is "18" and is it related to the process it is running (an error code from that?) or is it an error code from the Win32 package itself?

slipped
Jul 12, 2001
Win32::GetLastError()

[CORE] Returns the last error value generated by a call to a Win32 API function. Note that $^E used in a numeric context amounts to the same value.

Adbot
ADBOT LOVES YOU

mister_gosh
May 24, 2002

Right but what would "18" be?

I should mention that this used to work fine, but there has been some upgrades of multiple components.

The process I am calling as well as Perl going from 5.8.3 to 5.10.0.

Is it possible that an older version of Win32 is being called? I really doubt this.

  • Locked thread